diff --git a/configure.in b/configure.in index 37405e5..9299100 100644 --- a/configure.in +++ b/configure.in @@ -8,7 +8,7 @@ AC_INIT(acconfig.h) AC_CANONICAL_SYSTEM AC_ARG_PROGRAM -AM_INIT_AUTOMAKE(sualibrary,0.1.0) +AM_INIT_AUTOMAKE(sualibrary,0.1.2) AC_PREFIX_DEFAULT(/usr/local) if test "x$prefix" = "xNONE"; then @@ -16,10 +16,10 @@ if test "x$prefix" = "xNONE"; then ac_configure_args="$ac_configure_args --prefix $prefix" fi -dnl keep this order because automake gets confused apart from the authors +# keep this order because automake gets confused apart from the authors AM_CONFIG_HEADER(config.h:config.h.in) -dnl Checks for programs. +# Checks for programs. AC_PROG_AWK AC_PROG_CC AC_PROG_INSTALL @@ -28,23 +28,23 @@ AC_PROG_CXX AC_PROG_RANLIB -dnl Checks for libraries. -dnl create only shared libtool-libraries (add --enable-shared) +# Checks for libraries. +# create only shared libtool-libraries (add --enable-shared) AC_ENABLE_SHARED(no) -dnl AM_DISABLE_SHARED +# AM_DISABLE_SHARED -dnl set the following to yes, if you want to create static -dnl libtool-libraries, else no +# set the following to yes, if you want to create static +# libtool-libraries, else no AC_ENABLE_STATIC(yes) -dnl create a working libtool-script +# create a working libtool-script if test -z "$LIBTOOL"; then AC_LANG_SAVE AC_LANG_CPLUSPLUS AC_LIBTOOL_DLOPEN AM_PROG_LIBTOOL - dnl LIBTOOL="$LIBTOOL --silent" - dnl AC_SUBST(LIBTOOL) + # LIBTOOL="$LIBTOOL --silent" + # AC_SUBST(LIBTOOL) AC_LANG_RESTORE LIBTOOL_SHELL='/bin/sh ./libtool' else @@ -52,8 +52,8 @@ else fi -dnl activate the following for some additional tests -dnl (compat, crypt, socket, nsl, ...) +# activate the following for some additional tests +# (compat, crypt, socket, nsl, ...) all_libraries="$USER_LDFLAGS $all_libraries" all_includes="$all_includes $USER_INCLUDES" @@ -61,7 +61,7 @@ AC_SUBST(all_includes) AC_SUBST(all_libraries) AC_SUBST(AUTODIRS) -dnl Checks for header files. +# Checks for header files. AC_HEADER_STDC AC_HEADER_TIME @@ -70,24 +70,24 @@ sys/socket.h netinet/icmp6.h) AC_CHECK_HEADERS(sys/poll.h, AC_DEFINE(HAVE_SYS_POLL_H)) -dnl Checks for typedefs, structures, and compiler characteristics. +# Checks for typedefs, structures, and compiler characteristics. -dnl ---------------------- -dnl Packages configuration - Blatantly stolen from zebra ! -dnl ---------------------- +# ---------------------- +# Packages configuration - Blatantly stolen from zebra ! +# ---------------------- AC_ARG_ENABLE(ipv6, [ --disable-ipv6 turn off IPv6 support ]) -dnl ---------- -dnl IPv6 check -dnl ---------- +# ---------- +# IPv6 check +# ---------- AC_MSG_CHECKING(whether this OS does have IPv6 stack) if test "${enable_ipv6}" = "no"; then AC_MSG_RESULT(disabled) else -dnl ---------- -dnl INRIA IPv6 -dnl ---------- +# ---------- +# INRIA IPv6 +# ---------- if grep IPV6_INRIA_VERSION /usr/include/netinet/in.h >/dev/null 2>&1; then cv_ipv6=yes AC_DEFINE(HAVE_IPV6) @@ -95,9 +95,9 @@ if grep IPV6_INRIA_VERSION /usr/include/netinet/in.h >/dev/null 2>&1; then LIB_IPV6="" AC_MSG_RESULT(INRIA IPv6) fi -dnl --------- -dnl KAME IPv6 -dnl --------- +# --------- +# KAME IPv6 +# --------- if grep WIDE /usr/include/netinet6/in6.h >/dev/null 2>&1; then cv_ipv6=yes AC_DEFINE(HAVE_IPV6) @@ -107,9 +107,9 @@ if grep WIDE /usr/include/netinet6/in6.h >/dev/null 2>&1; then fi AC_MSG_RESULT(KAME) fi -dnl --------- -dnl NRL check -dnl --------- +# --------- +# NRL check +# --------- if grep NRL /usr/include/netinet6/in6.h >/dev/null 2>&1; then cv_ipv6=yes AC_DEFINE(HAVE_IPV6) @@ -121,11 +121,11 @@ if grep NRL /usr/include/netinet6/in6.h >/dev/null 2>&1; then AC_MSG_RESULT(NRL) fi fi -dnl ---------- -dnl Linux IPv6 -dnl ---------- +# ---------- +# Linux IPv6 +# ---------- if test "${enable_ipv6}" = "yes"; then - AC_EGREP_CPP(yes, [dnl + AC_EGREP_CPP(yes, [# #include /* 2.1.128 or later */ #if LINUX_VERSION_CODE >= 0x020180 @@ -159,15 +159,15 @@ fi fi -dnl ----------------------- -dnl Set IPv6 related values -dnl ----------------------- +# ----------------------- +# Set IPv6 related values +# ----------------------- LIBS="$LIB_IPV6 $LIBS" AC_SUBST(LIB_IPV6) -dnl ----------------------------------- -dnl check sin6_scope_id of sockaddr_in6 -dnl ----------------------------------- +# ----------------------------------- +# check sin6_scope_id of sockaddr_in6 +# ----------------------------------- if test "$cv_ipv6" = yes; then AC_MSG_CHECKING(whether struct sockaddr_in6 has a sin6_scope_id field) AC_TRY_COMPILE([#include @@ -178,9 +178,9 @@ if test "$cv_ipv6" = yes; then AC_MSG_RESULT(no)) fi -dnl ----------------------------------- -dnl Check for New Socket API (RFC2292BIS) -dnl ----------------------------------- +# ----------------------------------- +# Check for New Socket API (RFC2292BIS) +# ----------------------------------- AC_MSG_CHECKING(for rfc2292bis support) AC_TRY_COMPILE([#include #include ], @@ -198,9 +198,9 @@ AC_TRY_COMPILE([#include AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)]) -dnl This is taken from the ethereal configuration scripts. -dnl We check whether user wants to build gtk-based programs -dnl These need to be enabled explicitly +# This is taken from the ethereal configuration scripts. +# We check whether user wants to build gtk-based programs +# These need to be enabled explicitly GTK_OK=yes # GTK checks @@ -236,12 +236,12 @@ AM_PATH_GLIB(1.2.0, CFLAGS="$CFLAGS $GLIB_CFLAGS", AC_MSG_ERROR(GLib distributio AC_SUBST(sctp_SUBDIRS) -dnl Checks for library functions. +# Checks for library functions. AC_CHECK_LIB(socket, socket) AC_CHECK_LIB(nsl, gethostbyname) AC_CHECK_LIB(sctp, sctp_eventloop) -dnl removed libefence....this should be used though, when we REALLY debug :-) +# removed libefence....this should be used though, when we REALLY debug :-) AC_CHECK_LIB(efence, malloc) AC_CHECK_LIB(glib, g_main_add_poll) @@ -287,14 +287,14 @@ AC_CHECK_LIB(c, inet_ntop, [AC_DEFINE(HAVE_INET_NTOP)]) AC_CHECK_LIB(c, inet_pton, [AC_DEFINE(HAVE_INET_PTON)]) AC_CHECK_LIB(c, inet_aton, [AC_DEFINE(HAVE_INET_ATON)]) -dnl Checks for library functions. +# Checks for library functions. AC_FUNC_VPRINTF AC_FUNC_MEMCMP AC_CHECK_FUNCS(gettimeofday socket strerror poll getuid setuid geteuid random) AC_CHECK_FUNCS(getaddrinfo, [have_getaddrinfo=yes], [have_getaddrinfo=no]) -dnl checks for host/build/target system type +# checks for host/build/target system type AC_CANONICAL_HOST case $host_os in bsdi*) @@ -356,7 +356,7 @@ AC_SUBST(thread_LIBS) -dnl Checks for typedefs, structures, and compiler characteristics. +# Checks for typedefs, structures, and compiler characteristics. AC_C_CONST AC_TYPE_SIZE_T AC_STRUCT_TM @@ -379,5 +379,5 @@ AC_TRY_COMPILE([#include -dnl add here all your Makefiles. These will be created by configure +# add here all your Makefiles. These will be created by configure AC_OUTPUT(Makefile sualibrary/Makefile sualibrary/docs/Makefile sualibrary/docs/en/Makefile sualibrary/sua/Makefile sualibrary/testup/Makefile ) diff --git a/sualibrary.kdevprj b/sualibrary.kdevprj index 5dbacfa..d1e728b 100644 --- a/sualibrary.kdevprj +++ b/sualibrary.kdevprj @@ -1,290 +1,347 @@ -# KDE Config File -[sualibrary/docs/en/index-6.html] -install_location= +[AUTHORS] dist=true install=false +install_location= type=DATA -[Workspace_1] -openfiles=Untitled.h,Untitled.cpp,/home/p82609/siemens/sualibrary/sualibrary/sua/sua_datassoc.cpp,/home/p82609/siemens/sualibrary/sualibrary/sua/sua_distribution.cpp, -show_outputview=true -show_treeview=true -header_file=Untitled.h -cpp_file=/home/p82609/siemens/sualibrary/sualibrary/sua/sua_datassoc.cpp -browser_file=file:/opt/kde/share/doc/HTML/default/kdevelop/reference/C/LIBRARIES/libraries.html + [COPYING] -install_location= dist=true install=false +install_location= type=DATA -[sualibrary/sua/sua_adapt.cpp] -install_location= -dist=true -install=false -type=SOURCE -[sualibrary/sua/sua_logging.cpp] -install_location= -dist=true -install=false -type=SOURCE -[sualibrary/sua/sua_logging.h] -install_location= -dist=true -install=false -type=HEADER -[sualibrary/sua/sua_database.h] -install_location= -dist=true -install=false -type=HEADER -[Config for BinMakefileAm] -ldflags= -addcxxflags= -ldadd= -cxxflags=-O0 -g3 -Wall -bin_program=sualibrary -[sualibrary/sua/sua.h] -install_location= -dist=true -install=false -type=HEADER -[sualibrary/sua/sua_tcb.h] -install_location= -dist=true -install=false -type=HEADER -[sualibrary/testup/main.cpp] -install_location= -dist=true -install=false -type=SOURCE -[README] -install_location= -dist=true -install=false -type=DATA -[sualibrary/sua/sua_asp_mgnt.h] -install_location= -dist=true -install=false -type=HEADER -[sualibrary/sua/sua_file.h] -install_location= -dist=true -install=false -type=HEADER -[sualibrary/docs/en/index-1.html] -install_location= -dist=true -install=false -type=DATA -[sualibrary.kdevprj] -install_location= -dist=true -install=false -type=DATA -[LFV Groups] -GNU=AUTHORS,COPYING,ChangeLog,INSTALL,README,TODO,NEWS, -Others=*, -groups=Headers,Sources,GNU,Others, -Sources=*.cpp,*.c,*.cc,*.C,*.cxx,*.ec,*.ecpp,*.lxx,*.l++,*.ll,*.l, -Headers=*.h,*.hh,*.hxx,*.hpp,*.H, -[sualibrary/docs/en/index-2.html] -install_location= -dist=true -install=false -type=DATA -[sualibrary/docs/en/Makefile.am] -files=sualibrary/docs/en/index.html,sualibrary/docs/en/index-1.html,sualibrary/docs/en/index-2.html,sualibrary/docs/en/index-3.html,sualibrary/docs/en/index-4.html,sualibrary/docs/en/index-5.html,sualibrary/docs/en/index-6.html, -sub_dirs= -type=normal -[sualibrary/sua/sua_sual.cpp] -install_location= -dist=true -install=false -type=SOURCE -[sualibrary/docs/en/index.html] -install_location= -dist=true -install=false -type=DATA -[sualibrary/docs/en/index-3.html] -install_location= -dist=true -install=false -type=DATA -[sualibrary/sua/sua_asp_mgnt.cpp] -install_location= -dist=true -install=false -type=SOURCE -[sualibrary/sua/sua_dataname.cpp] -install_location= -dist=true -install=false -type=SOURCE -[sualibrary/sua/sua_file.cpp] -install_location= -dist=true -install=false -type=SOURCE -[sualibrary/testup/assoc.sua] -install_location= -dist=false -install=false -type=DATA -[sualibrary/docs/Makefile.am] -sub_dirs=en, -type=normal -[sualibrary/docs/en/index-4.html] -install_location= -dist=true -install=false -type=DATA -[sualibrary/sua/sua_distribution.h] -install_location= -dist=true -install=false -type=HEADER -[sualibrary/sua/sua_syntax.cpp] -install_location= -dist=true -install=false -type=SOURCE -[sualibrary/testup/testuser.h] -install_location= -dist=true -install=false -type=HEADER -[sualibrary.lsm] -install_location= -dist=true -install=false -type=DATA -[sualibrary/Makefile.am] -files= -sub_dirs=docs,sua,testup, -type=prog_main -[sualibrary/sua/sua_tcb.cpp] -install_location= -dist=true -install=false -type=SOURCE -[sualibrary/docs/en/index-5.html] -install_location= -dist=true -install=false -type=DATA -[sualibrary/sua/sua_datassoc.cpp] -install_location= -dist=true -install=false -type=SOURCE + [ChangeLog] -install_location= dist=true install=false +install_location= type=DATA -[sualibrary/sua/sua_cl.cpp] -install_location= -dist=true -install=false -type=SOURCE + +[Config for BinMakefileAm] +addcxxflags= +bin_program=sualibrary +cxxflags=-O0 -g3 -Wall +ldadd= +ldflags= + [General] -make_options=-j1 -makefiles=Makefile.am,sualibrary/Makefile.am,sualibrary/docs/Makefile.am,sualibrary/docs/en/Makefile.am,sualibrary/sua/Makefile.am,sualibrary/testup/Makefile.am, -version_control=None -author=Lode Coene -project_type=normal_cpp -sub_dir=sualibrary/ -lfv_open_groups= -workspace=1 -version=0.1 -project_name=Sualibrary AMChanged=false -sgml_file=/home/p82609/sualibrary/sualibrary/docs/en/index.sgml -short_info=, +author=Lode Coene +configure_args= email=lode.coene@siemens.atea.be kdevprj_version=1.2 -configure_args= +lfv_open_groups= +make_options=-j1 +makefiles=Makefile.am,sualibrary/Makefile.am,sualibrary/docs/Makefile.am,sualibrary/docs/en/Makefile.am,sualibrary/sua/Makefile.am,sualibrary/testup/Makefile.am, modifyMakefiles=true -[sualibrary/sua/Makefile.am] -files=sualibrary/sua/sua.h,sualibrary/sua/sua_adapt.cpp,sualibrary/sua/sua_adapt.h,sualibrary/sua/sua_asp_mgnt.cpp,sualibrary/sua/sua_asp_mgnt.h,sualibrary/sua/sua_cl.cpp,sualibrary/sua/sua_cl.h,sualibrary/sua/sua_datassoc.cpp,sualibrary/sua/sua_co.cpp,sualibrary/sua/sua_co.h,sualibrary/sua/sua_database.cpp,sualibrary/sua/sua_database.h,sualibrary/sua/sua_dataname.cpp,sualibrary/sua/sua_debug.h,sualibrary/sua/sua_distribution.cpp,sualibrary/sua/sua_distribution.h,sualibrary/sua/sua_file.cpp,sualibrary/sua/sua_file.h,sualibrary/sua/sua_logging.cpp,sualibrary/sua/sua_logging.h,sualibrary/sua/sua_sual.cpp,sualibrary/sua/sua_sual.h,sualibrary/sua/sua_syntax.cpp,sualibrary/sua/sua_syntax.h,sualibrary/sua/sua_tcb.cpp,sualibrary/sua/sua_tcb.h, -type=static_library -[TODO] -install_location= -dist=true -install=false -type=DATA +project_name=Sualibrary +project_type=normal_cpp +sgml_file=/home/p82609/sualibrary/sualibrary/docs/en/index.sgml +short_info=, +sub_dir=sualibrary/ +version=0.1 +version_control=None +workspace=1 + [INSTALL] -install_location= dist=true install=false +install_location= type=DATA -[sualibrary/sua/sua_syntax.h] -install_location= -dist=true -install=false -type=HEADER -[sualibrary/testup/local.sua] -install_location=local.sua -dist=false -install=false -type=DATA -[sualibrary/sua/sua_co.h] -install_location= -dist=true -install=false -type=HEADER -[sualibrary/sua/sua_adapt.h] -install_location= -dist=true -install=false -type=HEADER -[sualibrary/sua/sua_co.cpp] -install_location= -dist=true -install=false -type=SOURCE -[sualibrary/sua/sua_database.cpp] -install_location= -dist=true -install=false -type=SOURCE -[sualibrary/testup/testuser.cpp] -install_location= -dist=true -install=false -type=SOURCE + +[LFV Groups] +GNU=AUTHORS,COPYING,ChangeLog,INSTALL,README,TODO,NEWS, +Headers=*.h,*.hh,*.hxx,*.hpp,*.H, +Others=*, +Sources=*.cpp,*.c,*.cc,*.C,*.cxx,*.ec,*.ecpp,*.lxx,*.l++,*.ll,*.l, +groups=Headers,Sources,GNU,Others, + [Makefile.am] files=sualibrary.kdevprj,AUTHORS,COPYING,ChangeLog,INSTALL,README,TODO,sualibrary.lsm, sub_dirs=sualibrary, type=normal -[sualibrary/sua/sua_cl.h] -install_location= + +[README] dist=true install=false -type=HEADER -[sualibrary/sua/sua_distribution.cpp] install_location= -dist=true -install=false -type=SOURCE -[sualibrary/sua/sua_sual.h] -install_location= -dist=true -install=false -type=HEADER -[AUTHORS] -install_location= -dist=true -install=false type=DATA -[sualibrary/testup/Makefile.am] -files=sualibrary/testup/main.cpp,sualibrary/testup/testuser.cpp,sualibrary/testup/testuser.h,sualibrary/testup/local.sua,sualibrary/testup/assoc.sua, -type=static_library -sub_dirs= -[sualibrary/sua/sua_debug.h] -install_location= + +[TODO] dist=true install=false +install_location= +type=DATA + +[Workspace_1] +browser_file=file:/opt/kde/share/doc/HTML/default/kdevelop/reference/C/LIBRARIES/libraries.html +cpp_file=/home/p82609/sualibrary/sualibrary/testup/testuser.cpp +header_file=/home/p82609/sualibrary/sualibrary/testup/testuser.h +openfiles=Untitled.h,Untitled.cpp,/home/p82609/sualibrary/sualibrary/testup/main.cpp,/home/p82609/sualibrary/sualibrary/testup/testuser.cpp,/home/p82609/sualibrary/sualibrary/testup/testuser.h, +show_outputview=true +show_treeview=true + +[sualibrary.kdevprj] +dist=true +install=false +install_location= +type=DATA + +[sualibrary.lsm] +dist=true +install=false +install_location= +type=DATA + +[sualibrary/Makefile.am] +files= +sub_dirs=docs,sua,testup, +type=prog_main + +[sualibrary/docs/Makefile.am] +sub_dirs=en, +type=normal + +[sualibrary/docs/en/Makefile.am] +files=sualibrary/docs/en/index.html,sualibrary/docs/en/index-1.html,sualibrary/docs/en/index-2.html,sualibrary/docs/en/index-3.html,sualibrary/docs/en/index-4.html,sualibrary/docs/en/index-5.html,sualibrary/docs/en/index-6.html, +sub_dirs= +type=normal + +[sualibrary/docs/en/index-1.html] +dist=true +install=false +install_location= +type=DATA + +[sualibrary/docs/en/index-2.html] +dist=true +install=false +install_location= +type=DATA + +[sualibrary/docs/en/index-3.html] +dist=true +install=false +install_location= +type=DATA + +[sualibrary/docs/en/index-4.html] +dist=true +install=false +install_location= +type=DATA + +[sualibrary/docs/en/index-5.html] +dist=true +install=false +install_location= +type=DATA + +[sualibrary/docs/en/index-6.html] +dist=true +install=false +install_location= +type=DATA + +[sualibrary/docs/en/index.html] +dist=true +install=false +install_location= +type=DATA + +[sualibrary/sua/Makefile.am] +files=sualibrary/sua/sua.h,sualibrary/sua/sua_adapt.cpp,sualibrary/sua/sua_adapt.h,sualibrary/sua/sua_asp_mgnt.cpp,sualibrary/sua/sua_asp_mgnt.h,sualibrary/sua/sua_cl.cpp,sualibrary/sua/sua_cl.h,sualibrary/sua/sua_datassoc.cpp,sualibrary/sua/sua_co.cpp,sualibrary/sua/sua_co.h,sualibrary/sua/sua_database.cpp,sualibrary/sua/sua_database.h,sualibrary/sua/sua_dataname.cpp,sualibrary/sua/sua_debug.h,sualibrary/sua/sua_distribution.cpp,sualibrary/sua/sua_distribution.h,sualibrary/sua/sua_file.cpp,sualibrary/sua/sua_file.h,sualibrary/sua/sua_logging.cpp,sualibrary/sua/sua_logging.h,sualibrary/sua/sua_sual.cpp,sualibrary/sua/sua_sual.h,sualibrary/sua/sua_syntax.cpp,sualibrary/sua/sua_syntax.h,sualibrary/sua/sua_tcb.cpp,sualibrary/sua/sua_tcb.h,sualibrary/sua/sua_snm_mgnt.cpp,sualibrary/sua/sua_snm_mgnt.h +sharedlib_LDFLAGS= +sharedlib_rootname= +sub_dirs= +type=static_library + +[sualibrary/sua/sua.h] +dist=true +install=false +install_location= +type=HEADER + +[sualibrary/sua/sua_adapt.cpp] +dist=true +install=false +install_location= +type=SOURCE + +[sualibrary/sua/sua_adapt.h] +dist=true +install=false +install_location= +type=HEADER + +[sualibrary/sua/sua_asp_mgnt.cpp] +dist=true +install=false +install_location= +type=SOURCE + +[sualibrary/sua/sua_asp_mgnt.h] +dist=true +install=false +install_location= +type=HEADER + +[sualibrary/sua/sua_cl.cpp] +dist=true +install=false +install_location= +type=SOURCE + +[sualibrary/sua/sua_cl.h] +dist=true +install=false +install_location= +type=HEADER + +[sualibrary/sua/sua_co.cpp] +dist=true +install=false +install_location= +type=SOURCE + +[sualibrary/sua/sua_co.h] +dist=true +install=false +install_location= +type=HEADER + +[sualibrary/sua/sua_database.cpp] +dist=true +install=false +install_location= +type=SOURCE + +[sualibrary/sua/sua_database.h] +dist=true +install=false +install_location= +type=HEADER + +[sualibrary/sua/sua_dataname.cpp] +dist=true +install=false +install_location= +type=SOURCE + +[sualibrary/sua/sua_datassoc.cpp] +dist=true +install=false +install_location= +type=SOURCE + +[sualibrary/sua/sua_debug.h] +dist=true +install=false +install_location= +type=HEADER + +[sualibrary/sua/sua_distribution.cpp] +dist=true +install=false +install_location= +type=SOURCE + +[sualibrary/sua/sua_distribution.h] +dist=true +install=false +install_location= +type=HEADER + +[sualibrary/sua/sua_file.cpp] +dist=true +install=false +install_location= +type=SOURCE + +[sualibrary/sua/sua_file.h] +dist=true +install=false +install_location= +type=HEADER + +[sualibrary/sua/sua_logging.cpp] +dist=true +install=false +install_location= +type=SOURCE + +[sualibrary/sua/sua_logging.h] +dist=true +install=false +install_location= +type=HEADER + +[sualibrary/sua/sua_snm_mgnt.cpp] +dist=true +install=false +install_location= +type=SOURCE + +[sualibrary/sua/sua_snm_mgnt.h] +dist=true +install=false +install_location= +type=HEADER + +[sualibrary/sua/sua_sual.cpp] +dist=true +install=false +install_location= +type=SOURCE + +[sualibrary/sua/sua_sual.h] +dist=true +install=false +install_location= +type=HEADER + +[sualibrary/sua/sua_syntax.cpp] +dist=true +install=false +install_location= +type=SOURCE + +[sualibrary/sua/sua_syntax.h] +dist=true +install=false +install_location= +type=HEADER + +[sualibrary/sua/sua_tcb.cpp] +dist=true +install=false +install_location= +type=SOURCE + +[sualibrary/sua/sua_tcb.h] +dist=true +install=false +install_location= +type=HEADER + +[sualibrary/testup/Makefile.am] +files=sualibrary/testup/main.cpp,sualibrary/testup/testuser.cpp,sualibrary/testup/testuser.h, +sub_dirs= +type=static_library + +[sualibrary/testup/main.cpp] +dist=true +install=false +install_location= +type=SOURCE + +[sualibrary/testup/testuser.cpp] +dist=true +install=false +install_location= +type=SOURCE + +[sualibrary/testup/testuser.h] +dist=true +install=false +install_location= type=HEADER diff --git a/sualibrary.lsm b/sualibrary.lsm index a3639f5..3f5f191 100644 --- a/sualibrary.lsm +++ b/sualibrary.lsm @@ -1,6 +1,6 @@ Begin3 Title: Sualibrary -Version: 0.1 +Version: 0.1.2 Entered-date: Description: Keywords: @@ -9,6 +9,6 @@ Maintained-by: Lode Coene Primary-site: Home-page: http://www.sctp.be/sua Original-site: -Platforms: Linux and other Unices +Platforms: Linux, FreeBSD, Mac OSX and other Unixes Copying-policy: GNU Public License End diff --git a/sualibrary/Makefile.am b/sualibrary/Makefile.am index e778ee2..0c03538 100644 --- a/sualibrary/Makefile.am +++ b/sualibrary/Makefile.am @@ -1,9 +1,10 @@ ####### kdevelop will overwrite this part!!! (begin)########## +SUBDIRS = docs sua testup + ####### kdevelop will overwrite this part!!! (end)############ SUBDIRS = docs sua testup - diff --git a/sualibrary/sua/Makefile.am b/sualibrary/sua/Makefile.am index b7fa555..85b480e 100644 --- a/sualibrary/sua/Makefile.am +++ b/sualibrary/sua/Makefile.am @@ -1,10 +1,10 @@ ####### kdevelop will overwrite this part!!! (begin)########## noinst_LIBRARIES = libsua.a -libsua_a_SOURCES = sua_tcb.cpp sua_syntax.cpp sua_sual.cpp sua_logging.cpp sua_file.cpp sua_distribution.cpp sua_dataname.cpp sua_database.cpp sua_co.cpp sua_datassoc.cpp sua_cl.cpp sua_asp_mgnt.cpp sua_adapt.cpp +libsua_a_SOURCES = sua_snm_mgnt.cpp sua_tcb.cpp sua_syntax.cpp sua_sual.cpp sua_logging.cpp sua_file.cpp sua_distribution.cpp sua_dataname.cpp sua_database.cpp sua_co.cpp sua_datassoc.cpp sua_cl.cpp sua_asp_mgnt.cpp sua_adapt.cpp -EXTRA_DIST = sua.h sua_adapt.cpp sua_adapt.h sua_asp_mgnt.cpp sua_asp_mgnt.h sua_cl.cpp sua_cl.h sua_datassoc.cpp sua_co.cpp sua_co.h sua_database.cpp sua_database.h sua_dataname.cpp sua_debug.h sua_distribution.cpp sua_distribution.h sua_file.cpp sua_file.h sua_logging.cpp sua_logging.h sua_sual.cpp sua_sual.h sua_syntax.cpp sua_syntax.h sua_tcb.cpp sua_tcb.h +EXTRA_DIST = sua.h sua_adapt.cpp sua_adapt.h sua_asp_mgnt.cpp sua_asp_mgnt.h sua_cl.cpp sua_cl.h sua_datassoc.cpp sua_co.cpp sua_co.h sua_database.cpp sua_database.h sua_dataname.cpp sua_debug.h sua_distribution.cpp sua_distribution.h sua_file.cpp sua_file.h sua_logging.cpp sua_logging.h sua_sual.cpp sua_sual.h sua_syntax.cpp sua_syntax.h sua_tcb.cpp sua_tcb.h sua_snm_mgnt.cpp sua_snm_mgnt.h ####### kdevelop will overwrite this part!!! (end)############ SOMAJOR = 1 @@ -21,10 +21,16 @@ INCLUDES = -I/usr/local/include #build a libtool library for installation in libdir lib_LTLIBRARIES = libsua.la -libsua_la_SOURCES = sua_tcb.cpp sua_syntax.cpp sua_sual.cpp sua_logging.cpp sua_file.cpp sua_distribution.cpp sua_dataname.cpp sua_database.cpp sua_co.cpp sua_datassoc.cpp sua_cl.cpp sua_asp_mgnt.cpp sua_adapt.cpp +libsua_la_SOURCES = sua_tcb.cpp sua_syntax.cpp sua_sual.cpp sua_logging.cpp sua_file.cpp sua_distribution.cpp sua_dataname.cpp sua_database.cpp sua_co.cpp sua_datassoc.cpp sua_cl.cpp sua_asp_mgnt.cpp sua_adapt.cpp sua_snm_mgnt.cpp libsua_la_LDFLAGS = -no-undefined -version-info $(SOMAJOR):$(SOMINOR):$(SOSUBMINOR) $(LDFLAGS) + + + + + + diff --git a/sualibrary/sua/sua.h b/sualibrary/sua/sua.h index d0e5e02..84514d1 100644 --- a/sualibrary/sua/sua.h +++ b/sualibrary/sua/sua.h @@ -15,9 +15,9 @@ * * ***************************************************************************/ /* - * $Id: sua.h,v 1.3 2002/02/15 16:19:46 p82609 Exp $ + * $Id: sua.h,v 1.8 2002/11/12 11:02:49 p82609 Exp $ * - * SUA implementation according to SUA draft issue 6. + * SUA implementation according to SUA draft issue 13. * * Author(s): Lode Coene * @@ -102,6 +102,9 @@ #include +#ifdef DARWIN +#include +#endif /* turn on Posix 1g for compatible cmsg structure */ #ifdef USE_RFC2292BIS @@ -120,6 +123,8 @@ #include "sctp.h" /* SCTP library */ +using namespace std; + #define SUA_PORT 14001 #define SUA_PPI 4 #define IPPROTO_SCTP 132 @@ -128,6 +133,11 @@ /*#define HAVE_UNISTD_H TRUE */ +#ifndef FALSE +#define FALSE (0) +#define TRUE (!FALSE) +#endif + #define N_UNITDATA 1 #define N_NOTICE 2 #define N_CONNECT_REQ 10 @@ -140,12 +150,24 @@ #define N_RELEASE_REQ 30 #define N_RELEASE_CONF 31 +#define SUA_UDTS_NO_TRANSLATION_FOR_NATURE_OF_ADDRES 0x00 +#define SUA_UDTS_NO_TRANSLATION_FOR_SPECIFIC_ADDRES 0x01 +#define SUA_UDTS_SUBSYTEM_CONGESTION 0x02 +#define SUA_UDTS_SUBSYTEM_FAILURE 0x03 +#define SUA_UDTS_UNEQUIPPED_USER 0x04 +#define SUA_UDTS_MTP_FAILURE 0x05 +#define SUA_UDTS_NETWORK_CONGESTION 0x06 +#define SUA_UDTS_UNQUALIFIED 0x07 +#define SUA_UDTS_ERROR_IN_MSG_TRANSPORT 0x08 +#define SUA_UDTS_ERROR_IN_LOCAL_PROCESSING 0x09 +#define SUA_UDTS_DESTINATION_REASSEMBLY_FAILURE 0x0A +#define SUA_UDTS_SCCP_FAILURE 0x0B +#define SUA_UDTS_HOP_COUNTER_VIOLATION 0x0C +#define SUA_UDTS_SEGMENTATION_NOT_SUPPORTED 0x0D +#define SUA_UDTS_SEGMENTATION_FAILURE 0x0E + typedef unsigned char boolean; -#define FALSE (0) -#define TRUE (!FALSE) - - #define OK 0 #define PROTOCOL_CLASS_NOT_SPECIFIED -10 #define INVALID_CLG_ADDRESS -20 @@ -214,7 +236,7 @@ typedef enum { no_name_present, } name_gt_set; typedef enum { no_sap_present, - ssn_present, + ssn_present, portnumber_presentr } application_SAP_set; @@ -238,7 +260,13 @@ typedef struct { typedef char hostname_str[255]; -typedef char global_title_str[255]; +typedef struct { + short Translation_Type; + short Numbering_Plan; + short Nature_of_Address; + short nr_of_digits; + char digits[255]; +} global_title_str; typedef union { global_title_str GT; @@ -264,7 +292,7 @@ typedef struct { typedef enum { class0, // connectionless transport, non-sequenced class1, // connectionless transport, sequenced - class2, // connectionoriented + class2, // connectionoriented class3 // connectionoriented with flow control } protocol_class_set; @@ -279,26 +307,26 @@ typedef struct { typedef struct { void (*ulp_ClDataIndNotif) ( unsigned int local_sua_Id, - unsigned int primitive, - unsigned int datalen - ); + unsigned int primitive, + unsigned int datalen + ); void (*ulp_ConnIndNotif) ( unsigned int local_sua_id, - unsigned int local_sua_ref, - unsigned int datalen - ); + unsigned int local_sua_ref, + unsigned int datalen + ); void (*ulp_ConnConfIndNotif) ( unsigned int local_sua_id, - unsigned int local_sua_ref, - unsigned int datalen - ); + unsigned int local_sua_ref, + unsigned int datalen + ); void (*ulp_ConnDataIndNotif) ( unsigned int local_sua_id, - unsigned int local_sua_ref, - unsigned int datalen - ); + unsigned int local_sua_ref, + unsigned int datalen + ); void (*ulp_DisConnIndNotif) ( unsigned int local_sua_id, - unsigned int local_sua_ref, + unsigned int local_sua_ref, unsigned int reason, - unsigned int datalen - ); + unsigned int datalen + ); } Sua_ULP_CallBacks; @@ -317,9 +345,9 @@ unsigned int sua_read_config_file #define SUA_REG_NO_ERROR 0 unsigned int sua_registerInstance - ( short local_ssn, - Sua_ULP_CallBacks ulp_callback - ); +( short local_ssn, + Sua_ULP_CallBacks ulp_callback + ); #define SUA_ASS_NO_ERROR 0 @@ -337,12 +365,14 @@ typedef struct { #define SUA_PATH_NO_DEST_ADDR_PRESENT 1 unsigned int sua_getPath( unsigned int assoc_id, - sua_Path_str &pathinfo - ); + sua_Path_str &pathinfo + ); #define SUA_TERM_NO_ERROR 0 #define SUA_TERM_NO_DEST_ADDR_PRESENT 1 + +unsigned int sua_shutdown(); unsigned int sua_terminate(); diff --git a/sualibrary/sua/sua_adapt.cpp b/sualibrary/sua/sua_adapt.cpp index 5dcb396..26f35a3 100644 --- a/sualibrary/sua/sua_adapt.cpp +++ b/sualibrary/sua/sua_adapt.cpp @@ -15,9 +15,9 @@ * * ***************************************************************************/ /* - * $Id: sua_adapt.cpp,v 1.2 2002/02/15 16:19:46 p82609 Exp $ + * $Id: sua_adapt.cpp,v 1.5 2002/11/12 11:02:49 p82609 Exp $ * - * SUA implementation according to SUA draft issue 6. + * SUA implementation according to SUA draft issue 13. * * Author(s): Lode Coene * @@ -87,25 +87,31 @@ #include using namespace std; -/* definition of SUA local object and of remote object */ -db_Sua_LocalList local_sua; -db_Sua_RemoteList remote_sua; -db_Sua_AssociationList Assoc_sua; -db_Sua_NameList NameDB_sua; -db_Sua_ASList ApplicServ_sua; + +/* definition of SUA database objects */ +db_Sua_DatabaseList sua; /***********************************************************************/ /* sua_initialisation */ /***********************************************************************/ void sua_initialisation() { - int res; + int res; + SCTP_LibraryParameters params; + cout << "Initialising SCTP & SUA\n "; res = sctp_initLibrary(); + + /* set checksum to CRC32C */ + sctp_getLibraryParameters(¶ms); + params.checksumAlgorithm = SCTP_CHECKSUM_ALGORITHM_CRC32C; + params.supportPRSCTP = 0; + sctp_setLibraryParameters(¶ms); + init_logging_file(); - local_sua.initialize(); - remote_sua.initialize(); - Assoc_sua.initialize(); + sua.local_sua.initialize(); + sua.remote_sua.initialize(); + sua.AssocDB.initialize(); cout << "Finished initialising SUA data\n "; } /* end of sua_initialisation */ @@ -119,12 +125,13 @@ unsigned int sua_read_config_file( char *pConfFile) string sua_filename; sua_filename = pConfFile; result = read_sua_file( sua_filename, - local_sua, - remote_sua, - Assoc_sua, - NameDB_sua, - ApplicServ_sua + sua.local_sua, + sua.remote_sua, + sua.AssocDB, + sua.NameDB, + sua.ApplicServ ); + return(result); } @@ -146,12 +153,12 @@ unsigned int sua_registerInstance ( short local_ssn, SCTPCallbackFunctions.communicationErrorNotif = &sctp_CommunicationErrorNotif; SCTPCallbackFunctions.restartNotif = &sctp_RestartNotif; SCTPCallbackFunctions.shutdownCompleteNotif = &sctp_ShutDownCompleteNotif; - - result = Assoc_sua.register_instance ( SCTPCallbackFunctions, - ulp_callback, - local_sua - ); - + + result = sua.AssocDB.register_instance ( SCTPCallbackFunctions, + ulp_callback, + sua.local_sua + ); + return(result); } @@ -162,9 +169,9 @@ unsigned int sua_registerInstance ( short local_ssn, unsigned int sua_associate ( ) { unsigned int result = SUA_ASS_NO_ERROR; - result = Assoc_sua.associate_instance( local_sua, - remote_sua - ); + result = sua.AssocDB.associate_instance( sua.local_sua, + sua.remote_sua + ); return(result); } @@ -178,31 +185,75 @@ unsigned int sua_getPath( unsigned int assoc_id, ) { unsigned int result = SUA_PATH_NO_ERROR; - - if ( Assoc_sua.instance[assoc_id].Dest.nr_of_addrs > 0) + + if ( sua.AssocDB.instance[assoc_id].Dest.nr_of_addrs > 0) { /*pathinfo.remote_addr.*/ - pathinfo.remote_addr.pc.ipvx = Assoc_sua.instance[assoc_id].Dest.addrs[0]; - /*pathinfo.remote_addr.pc.ss7 = Assoc_sua.instance[assoc_id].Dest.pc;*/ - pathinfo.remote_addr.ssn = remote_sua.instance[Assoc_sua.instance[assoc_id].remote_sua_id].ssn.ssn; - - pathinfo.ASP_status = Assoc_sua.instance[assoc_id].asp.status; - + pathinfo.remote_addr.pc.ipvx = sua.AssocDB.instance[assoc_id].Dest.addrs[0]; + + /*memcpy( pathinfo.remote_addr.pc.ipvx.ch, sua.AssocDB.instance[assoc_id].Dest.addrs[0].ch, 24);*/ + + pathinfo.remote_addr.pc.ss7 = sua.AssocDB.instance[assoc_id].Dest.pc; + pathinfo.remote_addr.ssn = sua.remote_sua.instance[sua.AssocDB.instance[assoc_id].remote_sua_id].ssn.ssn; + + pathinfo.ASP_status = sua.AssocDB.instance[assoc_id].asp.status; + #ifdef DEBUG //cout << "remote ssn = " << pathinfo.remote_addr.ssn << "\n"; - //cout << "remote sua_id = " << Assoc_sua.instance[assoc_id].remote_sua_id << "\n"; + //cout << "remote sua_id = " << sua.AssocDB.instance[assoc_id].remote_sua_id << "\n"; #endif } else result = SUA_PATH_NO_DEST_ADDR_PRESENT; - pathinfo.local_addr.pc.ipvx = Assoc_sua.instance[assoc_id].Source.addrs[0]; - pathinfo.local_addr.pc.ss7 = Assoc_sua.instance[assoc_id].Source.pc; - pathinfo.local_addr.ssn = local_sua.instance[Assoc_sua.instance[assoc_id].local_sua_id].ssn.ssn; + + pathinfo.local_addr.pc.ipvx.ch = sua.AssocDB.instance[assoc_id].Source.addrs[0].ch; + + /*memcpy( pathinfo.local_addr.pc.ipvx.ch, sua.AssocDB.instance[assoc_id].Source.addrs[0].ch,24);*/ + + pathinfo.local_addr.pc.ss7 = sua.AssocDB.instance[assoc_id].Source.pc; + pathinfo.local_addr.ssn = sua.local_sua.instance[sua.AssocDB.instance[assoc_id].local_sua_id].ssn.ssn; + + return (result); + +} + +/***********************************************************************/ +/* get destination pointcode address */ +/***********************************************************************/ +pointcode_str get_destpc_addr( unsigned int sua_id) +{ + pointcode_str pc; + + pc.ipvx = sua.AssocDB.instance[sua_id].Dest.addrs[0]; + pc.ss7 = sua.AssocDB.instance[sua_id].Dest.pc; + return(pc); +} + +/***********************************************************************/ +/* get source pointcode address */ +/***********************************************************************/ +pointcode_str get_sourcepc_addr( unsigned int sua_id) +{ + pointcode_str pc; + pc.ipvx = sua.AssocDB.instance[sua_id].Source.addrs[0]; + pc.ss7 = sua.AssocDB.instance[sua_id].Source.pc; + return(pc); +} + +/***********************************************************************/ +/* sua_shutdown */ +/***********************************************************************/ +unsigned int sua_shutdown( ) +{ + unsigned int result = SUA_TERM_NO_ERROR; + + sua.AssocDB.shutdown(); return (result); } + /***********************************************************************/ /* sua_terminate */ /***********************************************************************/ @@ -210,7 +261,7 @@ unsigned int sua_terminate( ) { unsigned int result = SUA_TERM_NO_ERROR; - Assoc_sua.shutdown(); + sua.AssocDB.shutdown(); close_logging_file(); return (result); diff --git a/sualibrary/sua/sua_adapt.h b/sualibrary/sua/sua_adapt.h index 190c425..6655cca 100644 --- a/sualibrary/sua/sua_adapt.h +++ b/sualibrary/sua/sua_adapt.h @@ -15,7 +15,7 @@ * * ***************************************************************************/ /* - * $Id: sua_adapt.h,v 1.1.1.1 2002/02/04 14:30:41 p82609 Exp $ + * $Id: sua_adapt.h,v 1.2 2002/11/12 11:02:49 p82609 Exp $ * * SUA implementation according to SUA draft issue 6. * @@ -49,6 +49,7 @@ * - Nope */ +#include "sua.h" #include "sua_database.h" #ifdef LINUX @@ -70,8 +71,8 @@ using namespace std; - - +pointcode_str get_destpc_addr( unsigned int sua_id); +pointcode_str get_sourcepc_addr( unsigned int sua_id); // end of module sua_adapt.h diff --git a/sualibrary/sua/sua_asp_mgnt.cpp b/sualibrary/sua/sua_asp_mgnt.cpp index 93f0b9e..15f4d17 100644 --- a/sualibrary/sua/sua_asp_mgnt.cpp +++ b/sualibrary/sua/sua_asp_mgnt.cpp @@ -15,7 +15,7 @@ * * ***************************************************************************/ /* - * $Id: sua_asp_mgnt.cpp,v 1.1.1.1 2002/02/04 14:30:41 p82609 Exp $ + * $Id: sua_asp_mgnt.cpp,v 1.3 2002/11/12 11:02:49 p82609 Exp $ * * SUA implementation according to SUA draft issue 6. * @@ -79,12 +79,13 @@ #include "sua_tcb.h" #include +#include #include -extern db_Sua_LocalList local_sua; -extern db_Sua_RemoteList remote_sua; -extern db_Sua_AssociationList Assoc_sua; -extern db_Sua_ASList ApplicServ_sua; +using namespace std; + +extern db_Sua_DatabaseList sua; + extern tcb_Sua_msgqueue_pool msg_store; /***********************************************************************/ @@ -121,7 +122,7 @@ int sua_send_ASPUP( unsigned int Sua_assoc_id delivery_type = SCTP_UNORDERED_DELIVERY; - sctp_assoc_id = Assoc_sua.instance[Sua_assoc_id].SCTP_assoc_id; + sctp_assoc_id = sua.AssocDB.instance[Sua_assoc_id].SCTP_assoc_id; /* does association exist? */ if (sctp_assoc_id > 0) @@ -198,7 +199,7 @@ int sua_send_ASPUP_ACK( unsigned int Sua_assoc_id, delivery_type = SCTP_UNORDERED_DELIVERY; - sctp_assoc_id = Assoc_sua.instance[Sua_assoc_id].SCTP_assoc_id; + sctp_assoc_id = sua.AssocDB.instance[Sua_assoc_id].SCTP_assoc_id; /* does association exist? */ if (sctp_assoc_id > 0) @@ -268,7 +269,7 @@ int sua_send_ASPDOWN_ACK( unsigned int Sua_assoc_id delivery_type = SCTP_UNORDERED_DELIVERY; - sctp_assoc_id = Assoc_sua.instance[Sua_assoc_id].SCTP_assoc_id; + sctp_assoc_id = sua.AssocDB.instance[Sua_assoc_id].SCTP_assoc_id; /* does association exist? */ if (sctp_assoc_id > 0) @@ -338,7 +339,7 @@ int sua_send_BEAT( unsigned int Sua_assoc_id delivery_type = SCTP_UNORDERED_DELIVERY; - sctp_assoc_id = Assoc_sua.instance[Sua_assoc_id].SCTP_assoc_id; + sctp_assoc_id = sua.AssocDB.instance[Sua_assoc_id].SCTP_assoc_id; /* does association exist? */ if (sctp_assoc_id > 0) @@ -412,7 +413,7 @@ int sua_send_BEAT_ACK( unsigned int Sua_assoc_id, delivery_type = SCTP_UNORDERED_DELIVERY; - sctp_assoc_id = Assoc_sua.instance[Sua_assoc_id].SCTP_assoc_id; + sctp_assoc_id = sua.AssocDB.instance[Sua_assoc_id].SCTP_assoc_id; /* does association exist? */ if (sctp_assoc_id > 0) @@ -476,9 +477,10 @@ int sua_send_ASPAC( unsigned int Sua_assoc_id msg.sua_prim.hdr_msg_type.asptm = asptm_act; /* traffic mode is optional mandatory */ msg.sua_prim.traf_mode_pres = TRUE; - msg.sua_prim.traf_mode = tmt_loadshare; + msg.sua_prim.traf_mode = tmt_override; /* rest is optional */ - msg.sua_prim.rout_con_pres = FALSE; + msg.sua_prim.rout_con_pres = TRUE; + msg.sua_prim.rout_con = 1; msg.sua_prim.info_pres = FALSE; // encode the SUA unitdata message @@ -487,7 +489,7 @@ int sua_send_ASPAC( unsigned int Sua_assoc_id delivery_type = SCTP_UNORDERED_DELIVERY; - sctp_assoc_id = Assoc_sua.instance[Sua_assoc_id].SCTP_assoc_id; + sctp_assoc_id = sua.AssocDB.instance[Sua_assoc_id].SCTP_assoc_id; /* does association exist? */ if (sctp_assoc_id > 0) @@ -571,7 +573,7 @@ int sua_send_ASPAC_ACK( unsigned int Sua_assoc_id, delivery_type = SCTP_UNORDERED_DELIVERY; - sctp_assoc_id = Assoc_sua.instance[Sua_assoc_id].SCTP_assoc_id; + sctp_assoc_id = sua.AssocDB.instance[Sua_assoc_id].SCTP_assoc_id; /* does association exist? */ if (sctp_assoc_id > 0) @@ -617,7 +619,9 @@ int sua_send_ASPAC_ACK( unsigned int Sua_assoc_id, /***********************************************************************/ /* sua_send_ASPINAC_ACK */ /***********************************************************************/ -int sua_send_ASPINAC_ACK( unsigned int Sua_assoc_id +int sua_send_ASPINAC_ACK( unsigned int Sua_assoc_id, + boolean routing_context_present, + uint32_t routing_context ) { Sua_container msg; @@ -634,7 +638,8 @@ int sua_send_ASPINAC_ACK( unsigned int Sua_assoc_id // fill in the main sua header msg.sua_prim.hdr_msg_class = sua_asptm; msg.sua_prim.hdr_msg_type.asptm = asptm_inact_ack; - msg.sua_prim.rout_con_pres = FALSE; + msg.sua_prim.rout_con_pres = routing_context_present; + msg.sua_prim.rout_con = routing_context; msg.sua_prim.info_pres = FALSE; // encode the SUA unitdata message @@ -643,7 +648,7 @@ int sua_send_ASPINAC_ACK( unsigned int Sua_assoc_id delivery_type = SCTP_UNORDERED_DELIVERY; - sctp_assoc_id = Assoc_sua.instance[Sua_assoc_id].SCTP_assoc_id; + sctp_assoc_id = sua.AssocDB.instance[Sua_assoc_id].SCTP_assoc_id; /* does association exist? */ if (sctp_assoc_id > 0) @@ -704,7 +709,7 @@ int process_ASPUP_msg ( unsigned int sua_assoc_id, cout << "sua_asp_mgnt.c:ASPUP received, send back a ASPUP_ACK and set state to ASP-INACTIVE.\n"; #endif - Assoc_sua.up(sua_assoc_id,0); + sua.AssocDB.up(sua_assoc_id,0); error_value = sua_send_ASPUP_ACK( sua_assoc_id , sua_asp_msg.sua_prim.ASP_id_pres, @@ -712,7 +717,15 @@ int process_ASPUP_msg ( unsigned int sua_assoc_id, ); #ifdef DEBUG cout << "sua_asp_mgnt.c:result send ASPUP_ACK = "<< error_value << "\n"; - cout << "sua_asp_mgnt.c:ASPUP processing state = "<< Assoc_sua.instance[sua_assoc_id].asp.status << "\n"; + cout << "sua_asp_mgnt.c:ASPUP processing state = "<< sua.AssocDB.instance[sua_assoc_id].asp.status << "\n"; +#endif + +#ifdef IPSP_SINGLE + error_value = sua_send_ASPAC( sua_assoc_id ); +#ifdef DEBUG + cout << "sua_asp_mgnt.c:result send ASPAC = "<< error_value << "\n"; + cout << "sua_asp_mgnt.c:ASPAC processing state = "<< sua.AssocDB.instance[sua_assoc_id].asp.status << "\n"; +#endif #endif return(error_value); @@ -732,14 +745,18 @@ int process_ASPUP_ACK_msg ( unsigned int sua_assoc_id, cout << "sua_asp_mgnt.c:ASPUP_ACK received, looks like remote is inactive.\n"; #endif - Assoc_sua.up(sua_assoc_id,0); + sua.AssocDB.up(sua_assoc_id,0); +#ifndef IPSP_SINGLE /* send activation to remote */ error_value = sua_send_ASPAC( sua_assoc_id ); + #ifdef DEBUG cout << "sua_asp_mgnt.c:result send ASPAC = "<< error_value << "\n"; - cout << "sua_asp_mgnt.c:ASPUP_ACK processing state = "<< Assoc_sua.instance[sua_assoc_id].asp.status << "\n"; + cout << "sua_asp_mgnt.c:ASPUP_ACK processing state = "<< sua.AssocDB.instance[sua_assoc_id].asp.status << "\n"; #endif +#endif + return(error_value); } @@ -759,7 +776,7 @@ int process_ASPDOWN_msg ( unsigned int sua_assoc_id, cout << "sua_asp_mgnt.c:ASPDOWN received, send back a ASPDOWN_ACK and set state to ASP-DOWN.\n"; #endif - Assoc_sua.down(sua_assoc_id,0); + sua.AssocDB.down(sua_assoc_id,0); error_value = sua_send_ASPDOWN_ACK( sua_assoc_id ); @@ -784,7 +801,7 @@ int process_ASPDOWN_ACK_msg ( unsigned int sua_assoc_id, cout << "sua_asp_mgnt.c:ASPDOWN_ACK received, remote looks down.\n"; #endif - Assoc_sua.down(sua_assoc_id,0); + sua.AssocDB.down(sua_assoc_id,0); return(error_value); } @@ -853,10 +870,10 @@ int process_ASPAC_msg ( unsigned int sua_assoc_id, #endif if (sua_asp_msg.sua_prim.traf_mode_pres) - holdtraffic_pres = Assoc_sua.activate(sua_assoc_id, + holdtraffic_pres = sua.AssocDB.activate(sua_assoc_id, sua_asp_msg.sua_prim.traf_mode); else - holdtraffic_pres = Assoc_sua.activate(sua_assoc_id,0); + holdtraffic_pres = sua.AssocDB.activate(sua_assoc_id,0); error_value = sua_send_ASPAC_ACK( sua_assoc_id, sua_asp_msg.sua_prim.traf_mode_pres, @@ -867,7 +884,7 @@ int process_ASPAC_msg ( unsigned int sua_assoc_id, #ifdef DEBUG cout << "sua_asp_mgnt.c:result ASPAC_ACK send = "<< error_value << "\n"; - cout << "sua_asp_mgnt.c:ASPAC processing state = "<< Assoc_sua.instance[sua_assoc_id].asp.status << "\n"; + cout << "sua_asp_mgnt.c:ASPAC processing state = "<< sua.AssocDB.instance[sua_assoc_id].asp.status << "\n"; #endif if (holdtraffic_pres) @@ -886,7 +903,7 @@ int process_ASPAC_msg ( unsigned int sua_assoc_id, /* msg retrieved and copied, may now remove it from queue */ msg_store.delete_msg ( sua_assoc_id ); - sctp_assoc_id = Assoc_sua.instance[sua_assoc_id].SCTP_assoc_id; + sctp_assoc_id = sua.AssocDB.instance[sua_assoc_id].SCTP_assoc_id; #ifdef DEBUG display_byte_array(databuf , sua_msg.byte.length()); @@ -933,14 +950,14 @@ int process_ASPAC_ACK_msg ( unsigned int sua_assoc_id, int error_value = 0; bool holdtraffic_pres = FALSE; -#ifdef SG_ASP_MODE + /*#ifdef SG_ASP_MODE*/ if (sua_asp_msg.sua_prim.traf_mode_pres) - holdtraffic_pres = Assoc_sua.activate(sua_assoc_id, + holdtraffic_pres = sua.AssocDB.activate(sua_assoc_id, sua_asp_msg.sua_prim.traf_mode); else - holdtraffic_pres = Assoc_sua.activate(sua_assoc_id,0); + holdtraffic_pres = sua.AssocDB.activate(sua_assoc_id,0); -#endif + /*#endif*/ #ifdef DEBUG cout << "sua_asp_mgnt.c:ASPAC_ACK received, nothing further to do.\n"; @@ -963,9 +980,12 @@ int process_ASPINAC_msg ( unsigned int sua_assoc_id, #ifdef DEBUG cout << "sua_asp_mgnt.c:ASPINAC received, send back a ASPINAC_ACK and set state to ASP-INACTIVE.\n"; #endif - Assoc_sua.deactivate(sua_assoc_id,0); - - error_value = sua_send_ASPINAC_ACK( sua_assoc_id ); + sua.AssocDB.deactivate(sua_assoc_id,0); + + error_value = sua_send_ASPINAC_ACK( sua_assoc_id, + sua_asp_msg.sua_prim.rout_con_pres, + sua_asp_msg.sua_prim.rout_con + ); #ifdef DEBUG cout << "sua_asp_mgnt.c:result ASPINAC_ACK send = "<< error_value << "\n"; #endif @@ -997,20 +1017,26 @@ void Asp_mngt_standby ( unsigned int sua_AS_id, short mode ) { - ApplicServ_sua.override_ASP( sua_asp_id, - sua_AS_id, - mode - ); + sua.ApplicServ.override_ASP( sua_asp_id, + sua_AS_id, + mode + ); } +/***********************************************************************/ +/* Asp_activate_override */ +/***********************************************************************/ void asp_activate_override ( unsigned int asp_sua_assoc_id ) { - Assoc_sua.activate(asp_sua_assoc_id,0); + sua.AssocDB.activate(asp_sua_assoc_id,0); } +/***********************************************************************/ +/* Asp_asp_deactivate */ +/***********************************************************************/ void asp_deactivate ( unsigned int asp_sua_assoc_id) { - Assoc_sua.deactivate(asp_sua_assoc_id,0); + sua.AssocDB.deactivate(asp_sua_assoc_id,0); } diff --git a/sualibrary/sua/sua_cl.cpp b/sualibrary/sua/sua_cl.cpp index 10eaf6e..ab873fe 100644 --- a/sualibrary/sua/sua_cl.cpp +++ b/sualibrary/sua/sua_cl.cpp @@ -15,7 +15,7 @@ * * ***************************************************************************/ /* - * $Id: sua_cl.cpp,v 1.3 2002/03/01 12:57:38 p82609 Exp $ + * $Id: sua_cl.cpp,v 1.8 2002/10/29 16:00:54 p82609 Exp $ * * SUA implementation according to SUA draft issue 6. * @@ -52,9 +52,9 @@ * - send a SUA message(CL or CO) to SCTP * - route a SUA message(CL or CO) * - send a Unitdata msg to remote node - * (- send a Unitdata Service msg to remote node) + * - send a Unitdata Service msg to remote node * - Process a Unitdata msg - * (- Process a Unitdata Service msg) + * - Process a Unitdata Service msg */ @@ -85,9 +85,7 @@ using namespace std; // import the dataobjects of SUA -extern db_Sua_LocalList local_sua; -extern db_Sua_RemoteList remote_sua; -extern db_Sua_AssociationList Assoc_sua; +extern db_Sua_DatabaseList sua; extern tcb_Sua_msgqueue_pool msg_store; @@ -118,17 +116,16 @@ int sua_send_Message( signed int sctp_assoc_id, event_log("sua_cl.c",logstring); log_byte_array("sua_cl.c", databuf,datalen); - result = sctp_send ( sctp_assoc_id, - sctp_stream_id, - (unsigned char *) databuf, - datalen, - SUA_PPI, - SCTP_USE_PRIMARY, /* replace in future with sctp_loadshare*/ - SCTP_NO_CONTEXT, - SCTP_INFINITE_LIFETIME, - sctp_delivery_type, - SCTP_BUNDLING_DISABLED - ); + result = sctp_send ( sctp_assoc_id, + sctp_stream_id, + (unsigned char *) databuf, + datalen, + SUA_PPI, + SCTP_USE_PRIMARY, /* replace in future with sctp_loadshare*/ + SCTP_NO_CONTEXT, SCTP_INFINITE_LIFETIME, + sctp_delivery_type, + SCTP_BUNDLING_DISABLED + ); #ifdef DEBUG @@ -136,128 +133,18 @@ int sua_send_Message( signed int sctp_assoc_id, printf( "%d \n", result); #endif - return(result); + return(result); } -/***********************************************************************/ -/* sua_route_Message */ -/***********************************************************************/ -int sua_route_Message( unsigned int sctp_assoc_id, - unsigned int local_sua_id, - Sua_container &msg, - sccp_addr_str &called_pty_address, - sccp_addr_str &calling_pty_address - ) -{ - int result = 0; - short int sctp_stream_id = 0; - int sctp_delivery_type = SCTP_UNORDERED_DELIVERY; - signed int sctp_loadshare = SCTP_USE_PRIMARY; - int sua_assoc_id = 0; - int datalen = 0; - Sua_syntax_error_struct error; - - // call routing to figure out which association to take for sending - // out the message -#ifdef DEBUG - cout << "call routing function\n"; -#endif - sctp_assoc_id = Assoc_sua.route_msg( called_pty_address, - calling_pty_address, - sua_assoc_id - ); -#ifdef DEBUG - cout << "routed to SCTP assoc " << sctp_assoc_id << "/SUA assoc id " << sua_assoc_id <<"\n"; -#endif - - /* does association exist? */ - if (sctp_assoc_id > 0) - { - /* YES, encode the SUA unitdata message and ... */ - error = msg.sua_encode(); - - /* figure out SCTP delivery type, stream to send msg on,...and.. */ - if (msg.sua_prim.prot_class_pres) - { - switch(msg.sua_prim.prot_class.pcl) - { - case(prot_class_0): /* connectionless transport, non sequenced */ - sctp_delivery_type = SCTP_UNORDERED_DELIVERY; - break; - case(prot_class_1): /* connectionless transport, sequenced */ - sctp_delivery_type = SCTP_ORDERED_DELIVERY; - break; - case(prot_class_2): /* connection-oriented transport, ... */ - sctp_delivery_type = SCTP_ORDERED_DELIVERY; - break; - case(prot_class_3): /* connection-oriented transport, ... */ - sctp_delivery_type = SCTP_ORDERED_DELIVERY; - break; - default: - sctp_delivery_type = SCTP_UNORDERED_DELIVERY; - break; - } - sctp_stream_id = Assoc_sua.instance[sua_assoc_id].nr_of_outbound_streams; - sctp_stream_id = 0; - } - else - { - - sctp_stream_id = 0; - } - - /* copy data into buffer, then finally... */ - char* databuf = new char[msg.sua_msg.length()]; - msg.sua_msg.copy(databuf, msg.sua_msg.length()); - - datalen = msg.sua_msg.length(); - - // send data to SCTP - result = sua_send_Message( sctp_assoc_id, - sctp_stream_id, - sctp_delivery_type, - sctp_loadshare, - databuf, - datalen - ); - - delete databuf; - -#ifdef DEBUG - cout.setf(ios::internal); - cout << "sua_cl.c:result sua send = "<< result << "\n"; -#endif - - } - else if (sctp_assoc_id < 0) - { - /* NOPE, message is routable, but destination is blocked */ - /* due to administration or management descisions */ -#ifdef DEBUG - cout << "sua_cl.c:sending msg prohibited \n"; -#endif - result = -1; - } - else - { - /* NOPE message is NOT routable, destination not found. */ - /* drop the message, no route present for that address */ - result = 0; - } - - return(result); - -} /***********************************************************************/ -/* sua_send_Unitdata */ +/* sua_send_UDTService */ /***********************************************************************/ -int sua_send_Unitdata ( sccp_QOS_str &QOS, - sccp_addr_str &called_pty_address, - sccp_addr_str &calling_pty_address, - char *buffer, - unsigned int len - ) +int sua_send_UDTService ( Sua_container &org_msg, + sccp_addr_str &called_pty_address, + sccp_addr_str &calling_pty_address, + unsigned int UDTS_reason + ) { Sua_container msg; Sua_syntax_error_struct error; @@ -267,9 +154,243 @@ int sua_send_Unitdata ( sccp_QOS_str &QOS, int sua_assoc_id; short sctp_stream_id = 0; signed int sctp_loadshare = SCTP_USE_PRIMARY; - int sctp_delivery_type, result; + int sctp_delivery_type = 0 , result; tcb_Sua_msg_elem sua_msg; + // init the message + msg.sua_init(); + + // copy original msg into outgoing msg and change a few fields + msg.sua_prim = org_msg.sua_prim; + + // fill in the main sua header + msg.sua_prim.hdr_msg_class = sua_cl; + msg.sua_prim.hdr_msg_type.cl = cl_data_response; + + // UDTService cause + msg.sua_prim.SCCP_cause_pres = true; + msg.sua_prim.SCCP_cause.cause_type = ctp_return_cause; + msg.sua_prim.SCCP_cause.cause_value = UDTS_reason; + + // fill in the source address (=local sua address/CLG) + // destination of the received UDT, becomes source of sending UDTS + msg.sua_prim.source_addr = org_msg.sua_prim.dest_addr; + + + // fill in the destination address(=remote sua address/CLD) + // source of the received UDT, becomes destination of sending UDTS + msg.sua_prim.dest_addr = org_msg.sua_prim.source_addr; + + // encode the SUA unitdata message + error = msg.sua_encode(); + string_size = msg.sua_msg.size(); + + // call routing to figure out which association to take for sending + // out the message +#ifdef DEBUG + cout << "call routing function\n"; +#endif + sctp_assoc_id = sua.route_msg( called_pty_address, + calling_pty_address, + sua_assoc_id + ); +#ifdef DEBUG + cout << "routed to SCTP assoc " << sctp_assoc_id << "\n"; +#endif + /* does association exist? */ + if (sctp_assoc_id > 0) + { + /* copy data into buffer, then finally... */ + char* databuf = new char[msg.sua_msg.length()]; + msg.sua_msg.copy(databuf, msg.sua_msg.length()); + + datalen = msg.sua_msg.length(); + + // send data to SCTP + result = sua_send_Message( sctp_assoc_id, + sctp_stream_id, + sctp_delivery_type, + sctp_loadshare, + databuf, + datalen + ); + + delete databuf; +#ifdef DEBUG + cout << "sua_cl.c:result sctp send = "<< result << "\n"; +#endif + error_value = 0; + } + else if (sctp_assoc_id < 0) + { +#ifdef DEBUG + cout << "sua_cl.c:sending msg prohibited \n"; +#endif + error_value = -1; + } + else + { + /* NO it does NOT exist. */ + /* weird?? */ + /* - received a msg from a non existing association */ + /* - routing database is not correct, no return path for this msg */ + error_value = -1; + } + return(error_value); +} + + + + +/***********************************************************************/ +/* sua_route_Message */ +/***********************************************************************/ +int sua_route_Message( unsigned int sctp_assoc_id, + unsigned int local_sua_id, + Sua_container &msg, + sccp_addr_str &called_pty_address, + sccp_addr_str &calling_pty_address + ) +{ + int result = 0; + short int sctp_stream_id = 0; + int sctp_delivery_type = SCTP_UNORDERED_DELIVERY; + signed int sctp_loadshare = SCTP_USE_PRIMARY; + int sua_assoc_id = 0; + int datalen = 0; + int UDTS_reason = 0; + Sua_syntax_error_struct error; + + // call routing to figure out which association to take for sending + // out the message +#ifdef DEBUG + cout << "call routing function\n"; +#endif + sctp_assoc_id = sua.route_msg( called_pty_address, + calling_pty_address, + sua_assoc_id + ); +#ifdef DEBUG + cout << "routed to SCTP assoc " << sctp_assoc_id << "/SUA assoc id " << sua_assoc_id <<"\n"; +#endif + + /* does association exist? */ + if (sctp_assoc_id > 0) + { + /* YES, encode the SUA unitdata message and ... */ + error = msg.sua_encode(); + + /* figure out SCTP delivery type, stream to send msg on,...and.. */ + if (msg.sua_prim.prot_class_pres) + { + switch(msg.sua_prim.prot_class.pcl) + { + case(prot_class_0): /* connectionless transport, non sequenced */ + sctp_delivery_type = SCTP_UNORDERED_DELIVERY; + break; + case(prot_class_1): /* connectionless transport, sequenced */ + sctp_delivery_type = SCTP_ORDERED_DELIVERY; + break; + case(prot_class_2): /* connection-oriented transport, ... */ + sctp_delivery_type = SCTP_ORDERED_DELIVERY; + break; + case(prot_class_3): /* connection-oriented transport, ... */ + sctp_delivery_type = SCTP_ORDERED_DELIVERY; + break; + default: + sctp_delivery_type = SCTP_UNORDERED_DELIVERY; + break; + } + sctp_stream_id = sua.AssocDB.instance[sua_assoc_id].nr_of_outbound_streams; + sctp_stream_id = 0; + } + else + { + + sctp_stream_id = 0; + } + + /* copy data into buffer, then finally... */ + char* databuf = new char[msg.sua_msg.length()]; + msg.sua_msg.copy(databuf, msg.sua_msg.length()); + + datalen = msg.sua_msg.length(); + + // send data to SCTP + result = sua_send_Message( sctp_assoc_id, + sctp_stream_id, + sctp_delivery_type, + sctp_loadshare, + databuf, + datalen + ); + + delete databuf; + +#ifdef DEBUG + cout.setf(ios::internal); + cout << "sua_cl.c:result sua send = "<< result << "\n"; +#endif + + } + else if (sctp_assoc_id < 0) + { + /* NOPE, message is routable, but destination is blocked */ + /* due to administration or management descisions */ +#ifdef DEBUG + cout << "sua_cl.c:sending msg prohibited \n"; +#endif + result = -1; + } + else + { + /* NOPE message is NOT routable, destination not found. */ + /* return a unitdata service msg indicating routing failure */ + if ((msg.sua_prim.prot_class_pres) && (msg.sua_prim.prot_class.return_option)) + { + UDTS_reason = SUA_UDTS_NO_TRANSLATION_FOR_SPECIFIC_ADDRES; + result = sua_send_UDTService ( msg, + calling_pty_address, /* CLD */ + called_pty_address, /* CLG */ + UDTS_reason + ); + } + /* drop the message, no route present for that address */ + else + { + ; + } + + result = 0; + } + + return(result); + +} + + + +/***********************************************************************/ +/* sua_send_Unitdata */ +/***********************************************************************/ +int sua_send_Unitdata ( sccp_QOS_str &QOS, + sccp_addr_str &called_pty_address, + sccp_addr_str &calling_pty_address, + char *buffer, + unsigned int len + ) +{ + Sua_container msg; + Sua_syntax_error_struct error; + int error_value = 0; + int i, string_size, datalen; + signed int sctp_assoc_id; + int sua_assoc_id; + short sctp_stream_id = 0; + signed int sctp_loadshare = SCTP_USE_PRIMARY; + int sctp_delivery_type, result; + tcb_Sua_msg_elem sua_msg; + // init the message msg.sua_init(); @@ -310,18 +431,18 @@ int sua_send_Unitdata ( sccp_QOS_str &QOS, msg.sua_prim.prot_class.return_option = TRUE; else msg.sua_prim.prot_class.return_option = FALSE; - + // fill in the source address (=local sua address/CLG) - switch (calling_pty_address.routing_ind) + switch (calling_pty_address.routing_ind) { case (route_on_ssn): - + if (calling_pty_address.address_fields_present.pc == ipvx_pc_present) { msg.sua_prim.source_addr.ip_addr_pres = TRUE; msg.sua_prim.source_addr.pc_pres = FALSE; if (calling_pty_address.pc.ipvx.sa.sa_family == AF_INET) - { + { msg.sua_prim.source_addr.ip_addr_type = ip_v4; msg.sua_prim.source_addr.ip_addr.ipv4 = calling_pty_address.pc.ipvx.sin; } @@ -354,15 +475,35 @@ int sua_send_Unitdata ( sccp_QOS_str &QOS, cout << "SS7 PC in CLG address \n"; } else - cout << "unsupported CLG address option\n"; + cout << "unsupported CLG IP/PC address option\n"; break; case(route_on_name_gt): msg.sua_prim.source_addr.ip_addr_pres = FALSE; msg.sua_prim.source_addr.pc_pres = FALSE; - msg.sua_prim.source_addr.hostname_pres = TRUE; - msg.sua_prim.source_addr.hostname = calling_pty_address.name.HostName; - msg.sua_prim.source_addr_pres = TRUE; - msg.sua_prim.source_addr.rout_ind = ri_route_hostname; + if (calling_pty_address.address_fields_present.name_gt == hostname_present){ + msg.sua_prim.source_addr_pres = TRUE; + msg.sua_prim.source_addr.rout_ind = ri_route_hostname; + msg.sua_prim.source_addr.hostname_pres = TRUE; + msg.sua_prim.source_addr.gt_pres = FALSE; + msg.sua_prim.source_addr.hostname = calling_pty_address.name.HostName; + + } + else if (calling_pty_address.address_fields_present.name_gt == GT_present){ + msg.sua_prim.source_addr_pres = TRUE; + msg.sua_prim.source_addr.rout_ind = ri_route_GT; + msg.sua_prim.source_addr.hostname_pres = FALSE; + msg.sua_prim.source_addr.gt_pres = TRUE; + msg.sua_prim.source_addr.gt.translation_type = calling_pty_address.name.GT.Translation_Type; + msg.sua_prim.source_addr.gt.num_plan = calling_pty_address.name.GT.Numbering_Plan; + msg.sua_prim.source_addr.gt.nat_addr = calling_pty_address.name.GT.Nature_of_Address; + msg.sua_prim.source_addr.gt.nr_of_digits = calling_pty_address.name.GT.nr_of_digits; + for (i=0; i < calling_pty_address.name.GT.nr_of_digits; i++) + msg.sua_prim.source_addr.gt.digits[i] = calling_pty_address.name.GT.digits[i]; + + } + else + cout << "unsupported CLG name/GT address option\n"; + msg.sua_prim.source_addr.ssn_incl = TRUE; msg.sua_prim.source_addr.pc_incl = FALSE; msg.sua_prim.source_addr.gt_incl = TRUE; @@ -374,19 +515,19 @@ int sua_send_Unitdata ( sccp_QOS_str &QOS, return(INVALID_CLG_ADDRESS); break; } - + // fill in the destination address(=remote sua address/CLD) - switch (called_pty_address.routing_ind) + switch (called_pty_address.routing_ind) { case (route_on_ssn): - + if (called_pty_address.address_fields_present.pc == ipvx_pc_present) { msg.sua_prim.dest_addr.ip_addr_pres = TRUE; msg.sua_prim.dest_addr.pc_pres = FALSE; if (called_pty_address.pc.ipvx.sa.sa_family == AF_INET) - { + { msg.sua_prim.dest_addr.ip_addr_type = ip_v4; msg.sua_prim.dest_addr.ip_addr.ipv4 = called_pty_address.pc.ipvx.sin; } @@ -419,15 +560,34 @@ int sua_send_Unitdata ( sccp_QOS_str &QOS, } else cout << "unsupported CLD address option\n"; - + break; case(route_on_name_gt): msg.sua_prim.dest_addr.ip_addr_pres = FALSE; - msg.sua_prim.dest_addr.hostname_pres = TRUE; msg.sua_prim.dest_addr.pc_pres = FALSE; - msg.sua_prim.dest_addr.hostname = called_pty_address.name.HostName; - msg.sua_prim.dest_addr_pres = TRUE; - msg.sua_prim.dest_addr.rout_ind = ri_route_hostname; + if (called_pty_address.address_fields_present.name_gt == hostname_present){ + msg.sua_prim.dest_addr_pres = TRUE; + msg.sua_prim.dest_addr.rout_ind = ri_route_hostname; + msg.sua_prim.dest_addr.hostname_pres = TRUE; + msg.sua_prim.dest_addr.gt_pres = FALSE; + msg.sua_prim.dest_addr.hostname = called_pty_address.name.HostName; + + } + else if (called_pty_address.address_fields_present.name_gt == GT_present){ + msg.sua_prim.dest_addr_pres = TRUE; + msg.sua_prim.dest_addr.rout_ind = ri_route_GT; + msg.sua_prim.dest_addr.hostname_pres = FALSE; + msg.sua_prim.dest_addr.gt_pres = TRUE; + msg.sua_prim.dest_addr.gt.translation_type = called_pty_address.name.GT.Translation_Type; + msg.sua_prim.dest_addr.gt.num_plan = called_pty_address.name.GT.Numbering_Plan; + msg.sua_prim.dest_addr.gt.nat_addr = called_pty_address.name.GT.Nature_of_Address; + msg.sua_prim.dest_addr.gt.nr_of_digits = called_pty_address.name.GT.nr_of_digits; + for (i=0; i < called_pty_address.name.GT.nr_of_digits; i++) + msg.sua_prim.dest_addr.gt.digits[i] = called_pty_address.name.GT.digits[i]; + } + else + cout << "unsupported CLG name/GT address option\n"; + msg.sua_prim.dest_addr.ssn_incl = TRUE; msg.sua_prim.dest_addr.pc_incl = FALSE; msg.sua_prim.dest_addr.gt_incl = TRUE; @@ -442,7 +602,7 @@ int sua_send_Unitdata ( sccp_QOS_str &QOS, // fill in the user data msg.sua_prim.data_pres = TRUE; - string stemp(buffer,len); + string stemp(buffer,len); msg.sua_prim.data_string = stemp; // encode the SUA unitdata message @@ -454,10 +614,10 @@ int sua_send_Unitdata ( sccp_QOS_str &QOS, #ifdef DEBUG cout << "call routing function\n"; #endif - sctp_assoc_id = Assoc_sua.route_msg( called_pty_address, - calling_pty_address, - sua_assoc_id - ); + sctp_assoc_id = sua.route_msg( called_pty_address, + calling_pty_address, + sua_assoc_id + ); #ifdef DEBUG cout << "routed to SCTP assoc " << sctp_assoc_id << "\n"; #endif @@ -465,28 +625,29 @@ int sua_send_Unitdata ( sccp_QOS_str &QOS, if (sctp_assoc_id > 0) { /* copy data into buffer, then finally... */ - char* databuf = new char[msg.sua_msg.length()]; + char* databuf = new char[msg.sua_msg.length()]; msg.sua_msg.copy(databuf, msg.sua_msg.length()); - + datalen = msg.sua_msg.length(); - + // send data to SCTP - result = sua_send_Message( sctp_assoc_id, - sctp_stream_id, - sctp_delivery_type, - sctp_loadshare, - databuf, - datalen - ); + result = sua_send_Message( sctp_assoc_id, + sctp_stream_id, + sctp_delivery_type, + sctp_loadshare, + databuf, + datalen + ); - delete databuf; + delete databuf; #ifdef DEBUG cout << "sua_cl.c:result sctp send = "<< result << "\n"; #endif - error_value = 0; + error_value = 0; } else if (sctp_assoc_id < 0) { + #ifdef DEBUG cout << "sua_cl.c:sending msg prohibited \n"; #endif @@ -496,15 +657,13 @@ int sua_send_Unitdata ( sccp_QOS_str &QOS, { /* NO it does NOT exist. */ /* - Try to set up the association */ - sua_assoc_id = Assoc_sua.Dynamic_Associate ( local_sua, - remote_sua, - called_pty_address, - calling_pty_address, - 1, - 1, - 1 - ); - + sua_assoc_id = sua.Dynamic_Associate ( called_pty_address, + calling_pty_address, + 1, + 1, + 1 + ); + /* - save the msg till the association is setup or */ /* association setup fails -> drop saved msg */ sua_msg.byte = msg.sua_msg; @@ -512,9 +671,9 @@ int sua_send_Unitdata ( sccp_QOS_str &QOS, sua_msg.stream_id = sctp_stream_id; sua_msg.valid = true; msg_store.add_msg ( sua_assoc_id, - sua_msg - ); - + sua_msg + ); + error_value = -1; } return(error_value); @@ -538,7 +697,7 @@ short process_unitdata_msg ( int local_sua_id, temp.primitive = N_UNITDATA; temp.user_ref = 0; - + if (msg.sua_prim.prot_class_pres) { // QOS choice @@ -561,21 +720,21 @@ short process_unitdata_msg ( int local_sua_id, temp.QOS.sequence_number = 0; temp.QOS.importance = msg.sua_prim.importance; - + // retrieve the clg(=source) address (=remote sua address) // which types are present in the address(ip pc, SS7 pc, GT, hostname) if (msg.sua_prim.source_addr.ip_addr_pres == TRUE) { - temp.calling_pty_address.address_fields_present.pc = ipvx_pc_present; + temp.calling_pty_address.address_fields_present.pc = ipvx_pc_present; if (msg.sua_prim.source_addr.ip_addr_type == ip_v4) { temp.calling_pty_address.pc.ipvx.sin = msg.sua_prim.source_addr.ip_addr.ipv4; temp.calling_pty_address.pc.ipvx.sa.sa_family = AF_INET; - temp.calling_pty_address.pc.ipvx.sin.sin_port = Assoc_sua.instance[sua_assoc_id].Dest.addrs[0].sin.sin_port; + temp.calling_pty_address.pc.ipvx.sin.sin_port = sua.AssocDB.instance[sua_assoc_id].Dest.addrs[0].sin.sin_port; } else if (msg.sua_prim.source_addr.ip_addr_type == ip_v6) { temp.calling_pty_address.pc.ipvx.sin6 = msg.sua_prim.source_addr.ip_addr.ipv6; temp.calling_pty_address.pc.ipvx.sa.sa_family = AF_INET6; - temp.calling_pty_address.pc.ipvx.sin6.sin6_port = Assoc_sua.instance[sua_assoc_id].Dest.addrs[0].sin.sin_port; + temp.calling_pty_address.pc.ipvx.sin6.sin6_port = sua.AssocDB.instance[sua_assoc_id].Dest.addrs[0].sin.sin_port; } else cout << "Unknown IP address format\n"; @@ -583,7 +742,7 @@ short process_unitdata_msg ( int local_sua_id, if (msg.sua_prim.source_addr.pc_pres == TRUE) { temp.calling_pty_address.address_fields_present.pc = ss7_pc_present; - temp.calling_pty_address.pc.ss7.ITU24.family = Assoc_sua.instance[sua_assoc_id].Dest.pc.ITU14.family; + temp.calling_pty_address.pc.ss7.ITU24.family = sua.AssocDB.instance[sua_assoc_id].Dest.pc.ITU14.family; temp.calling_pty_address.pc.ss7.ITU24.pc = msg.sua_prim.source_addr.pc; } if (msg.sua_prim.source_addr.gt_pres == TRUE) @@ -592,7 +751,7 @@ short process_unitdata_msg ( int local_sua_id, } if (msg.sua_prim.source_addr.hostname_pres == TRUE) { - temp.calling_pty_address.address_fields_present.name_gt = hostname_present; + temp.calling_pty_address.address_fields_present.name_gt = hostname_present; msg.sua_prim.source_addr.hostname.copy( temp.calling_pty_address.name.HostName, (msg.sua_prim.source_addr.hostname.length()+1 ) ); @@ -624,37 +783,251 @@ short process_unitdata_msg ( int local_sua_id, default: break; } - + temp.calling_pty_address.address_fields_present.ssn_port = ssn_present; - temp.calling_pty_address.ssn = msg.sua_prim.source_addr.ssn; - + temp.calling_pty_address.ssn = msg.sua_prim.source_addr.ssn; + // retrieve the called(=destination) address(=should be our own local addr) // not completely done yet if (msg.sua_prim.dest_addr.ip_addr_pres == TRUE) { - temp.called_pty_address.address_fields_present.pc = ipvx_pc_present; + temp.called_pty_address.address_fields_present.pc = ipvx_pc_present; if (msg.sua_prim.dest_addr.ip_addr_type == ip_v4) { - temp.called_pty_address.pc.ipvx.sin = msg.sua_prim.dest_addr.ip_addr.ipv4; - temp.called_pty_address.pc.ipvx.sa.sa_family = AF_INET; - temp.called_pty_address.pc.ipvx.sin.sin_port = Assoc_sua.instance[sua_assoc_id].Dest.addrs[0].sin.sin_port; - } + temp.called_pty_address.pc.ipvx.sin = msg.sua_prim.dest_addr.ip_addr.ipv4; + temp.called_pty_address.pc.ipvx.sa.sa_family = AF_INET; + temp.called_pty_address.pc.ipvx.sin.sin_port = sua.AssocDB.instance[sua_assoc_id].Dest.addrs[0].sin.sin_port; + } else if (msg.sua_prim.dest_addr.ip_addr_type == ip_v6) { - temp.called_pty_address.pc.ipvx.sin6 = msg.sua_prim.dest_addr.ip_addr.ipv6; - temp.called_pty_address.pc.ipvx.sa.sa_family = AF_INET6; - temp.called_pty_address.pc.ipvx.sin6.sin6_port = Assoc_sua.instance[sua_assoc_id].Dest.addrs[0].sin.sin_port; - } + temp.called_pty_address.pc.ipvx.sin6 = msg.sua_prim.dest_addr.ip_addr.ipv6; + temp.called_pty_address.pc.ipvx.sa.sa_family = AF_INET6; + temp.called_pty_address.pc.ipvx.sin6.sin6_port = sua.AssocDB.instance[sua_assoc_id].Dest.addrs[0].sin.sin_port; + } } if (msg.sua_prim.dest_addr.pc_pres == TRUE) { temp.called_pty_address.address_fields_present.pc = ss7_pc_present; - temp.called_pty_address.pc.ss7.ITU24.family = Assoc_sua.instance[sua_assoc_id].Dest.pc.ITU14.family; + temp.called_pty_address.pc.ss7.ITU24.family = sua.AssocDB.instance[sua_assoc_id].Dest.pc.ITU14.family; temp.called_pty_address.pc.ss7.ITU24.pc = msg.sua_prim.dest_addr.pc; } if (msg.sua_prim.dest_addr.hostname_pres == TRUE) { - temp.called_pty_address.address_fields_present.name_gt = hostname_present; + temp.called_pty_address.address_fields_present.name_gt = hostname_present; + msg.sua_prim.dest_addr.hostname.copy( temp.called_pty_address.name.HostName, + (msg.sua_prim.dest_addr.hostname.length()+1 ) + ); + temp.called_pty_address.name.HostName[msg.sua_prim.dest_addr.hostname.length()] = '\0'; + } + // routing indicator + switch (msg.sua_prim.dest_addr.rout_ind) + { + case(ri_route_PC_SSN): + temp.called_pty_address.routing_ind = route_on_ssn; + break; + case(ri_route_IP_SSN): + temp.called_pty_address.routing_ind = route_on_ssn; + break; + case (ri_route_GT): + temp.called_pty_address.routing_ind = route_on_name_gt; + break; + case (ri_route_hostname): + temp.called_pty_address.routing_ind = route_on_name_gt; + break; + default: + break; + } + + temp.called_pty_address.address_fields_present.ssn_port = ssn_present; + temp.called_pty_address.ssn = msg.sua_prim.dest_addr.ssn; + + + if (msg.sua_prim.data_pres == TRUE) + temp.userdata = msg.sua_prim.data_string; + else + cout << "sua_cl.c: no sua user data in unitdata msg \n"; + + /* Is this the final destination ? */ + if ( sua.Find_local_sua ( temp.called_pty_address) > 0 ) + { + /* Yes, message has arrived at its final destination -> send to upper layer */ + /* store primitive in a list(is retrieve via sua_receive_msg) */ + rec_msg_pool.push_back(temp); + + /* call the application/user callBack function */ + sua.local_sua.instance[local_sua_id].SUA_APLCallBack.ulp_ClDataIndNotif + ( local_sua_id, + N_UNITDATA, + temp.userdata.length() + ); + } + else + { + /* No, Message has not arrived at its final destination -> */ + /* route it to the next SUA node via an SCTP association nr x */ + result = sua_route_Message( sctp_assoc_id, + local_sua_id, + msg, + temp.called_pty_address, + temp.calling_pty_address + ); + } + + return(0); +} + +/***********************************************************************/ +/* sua_process_UDTService */ +/***********************************************************************/ +short process_UDTService_msg ( int local_sua_id, + unsigned int sua_assoc_id, + Sua_container &msg + ) +{ + sua_save_str temp; + int i, result = 0; + int sctp_assoc_id = 0; + + temp.primitive = N_NOTICE; + temp.user_ref = 0; + + if (msg.sua_prim.prot_class_pres) + { + // QOS choice + switch ( msg.sua_prim.prot_class.pcl) + { + case(prot_class_0): // connectionless transport, non-sequenced + temp.QOS.prot_class = class0; + temp.QOS.in_sequence = false; + break; + case(prot_class_1): + temp.QOS.prot_class = class1; + temp.QOS.in_sequence = true; + break; + default: + return(PROTOCOL_CLASS_NOT_SPECIFIED); + break; + } + temp.QOS.return_msg_on_error = (msg.sua_prim.prot_class.return_option == TRUE); + } + + temp.QOS.sequence_number = 0; + temp.QOS.importance = msg.sua_prim.importance; + + // retrieve the clg(=source) address (=remote sua address) + // which types are present in the address(ip pc, SS7 pc, GT, hostname) + if (msg.sua_prim.source_addr.ip_addr_pres == TRUE) + { + temp.calling_pty_address.address_fields_present.pc = ipvx_pc_present; + if (msg.sua_prim.source_addr.ip_addr_type == ip_v4) { + temp.calling_pty_address.pc.ipvx.sin = msg.sua_prim.source_addr.ip_addr.ipv4; + temp.calling_pty_address.pc.ipvx.sa.sa_family = AF_INET; + temp.calling_pty_address.pc.ipvx.sin.sin_port = sua.AssocDB.instance[sua_assoc_id].Dest.addrs[0].sin.sin_port; + } + else if (msg.sua_prim.source_addr.ip_addr_type == ip_v6) { + temp.calling_pty_address.pc.ipvx.sin6 = msg.sua_prim.source_addr.ip_addr.ipv6; + temp.calling_pty_address.pc.ipvx.sa.sa_family = AF_INET6; + temp.calling_pty_address.pc.ipvx.sin6.sin6_port = sua.AssocDB.instance[sua_assoc_id].Dest.addrs[0].sin.sin_port; + } + else + cout << "Unknown IP address format\n"; + } + if (msg.sua_prim.source_addr.pc_pres == TRUE) + { + temp.calling_pty_address.address_fields_present.pc = ss7_pc_present; + temp.calling_pty_address.pc.ss7.ITU24.family = sua.AssocDB.instance[sua_assoc_id].Dest.pc.ITU14.family; + temp.calling_pty_address.pc.ss7.ITU24.pc = msg.sua_prim.source_addr.pc; + } + + if (msg.sua_prim.source_addr.gt_pres == TRUE) + { + temp.calling_pty_address.address_fields_present.name_gt = GT_present; + temp.calling_pty_address.name.GT.Translation_Type = msg.sua_prim.source_addr.gt.translation_type; + temp.calling_pty_address.name.GT.Numbering_Plan = msg.sua_prim.source_addr.gt.num_plan; + temp.calling_pty_address.name.GT.Nature_of_Address = msg.sua_prim.source_addr.gt.nat_addr; + temp.calling_pty_address.name.GT.nr_of_digits = msg.sua_prim.source_addr.gt.nr_of_digits; + for (i=0; i < temp.calling_pty_address.name.GT.nr_of_digits; i++) + temp.calling_pty_address.name.GT.digits[i] = msg.sua_prim.source_addr.gt.digits[i]; + temp.calling_pty_address.name.GT.digits[temp.calling_pty_address.name.GT.nr_of_digits] = '\0'; + } + + if (msg.sua_prim.source_addr.hostname_pres == TRUE) + { + temp.calling_pty_address.address_fields_present.name_gt = hostname_present; + msg.sua_prim.source_addr.hostname.copy( temp.calling_pty_address.name.HostName, + (msg.sua_prim.source_addr.hostname.length()+1 ) + ); + temp.calling_pty_address.name.HostName[msg.sua_prim.source_addr.hostname.length()] = '\0'; + } + if ((msg.sua_prim.source_addr.ip_addr_pres /= TRUE) && + (msg.sua_prim.source_addr.pc_pres /= TRUE) && + (msg.sua_prim.source_addr.gt_pres /= TRUE) && + (msg.sua_prim.source_addr.hostname_pres /= TRUE)) + { + cout << "No valid address format found in msg\n"; + } + + // routing indicator + switch (msg.sua_prim.source_addr.rout_ind) + { + case(ri_route_PC_SSN): + temp.calling_pty_address.routing_ind = route_on_ssn; + break; + case(ri_route_IP_SSN): + temp.calling_pty_address.routing_ind = route_on_ssn; + break; + case (ri_route_GT): + temp.calling_pty_address.routing_ind = route_on_name_gt; + break; + case (ri_route_hostname): + temp.calling_pty_address.routing_ind = route_on_name_gt; + break; + default: + break; + } + + temp.calling_pty_address.address_fields_present.ssn_port = ssn_present; + temp.calling_pty_address.ssn = msg.sua_prim.source_addr.ssn; + + + // retrieve the called(=destination) address(=should be our own local addr) + // not completely done yet + if (msg.sua_prim.dest_addr.ip_addr_pres == TRUE) + { + temp.called_pty_address.address_fields_present.pc = ipvx_pc_present; + if (msg.sua_prim.dest_addr.ip_addr_type == ip_v4) { + temp.called_pty_address.pc.ipvx.sin = msg.sua_prim.dest_addr.ip_addr.ipv4; + temp.called_pty_address.pc.ipvx.sa.sa_family = AF_INET; + temp.called_pty_address.pc.ipvx.sin.sin_port = sua.AssocDB.instance[sua_assoc_id].Dest.addrs[0].sin.sin_port; + } + else if (msg.sua_prim.dest_addr.ip_addr_type == ip_v6) { + temp.called_pty_address.pc.ipvx.sin6 = msg.sua_prim.dest_addr.ip_addr.ipv6; + temp.called_pty_address.pc.ipvx.sa.sa_family = AF_INET6; + temp.called_pty_address.pc.ipvx.sin6.sin6_port = sua.AssocDB.instance[sua_assoc_id].Dest.addrs[0].sin.sin_port; + } + } + if (msg.sua_prim.dest_addr.pc_pres == TRUE) + { + temp.called_pty_address.address_fields_present.pc = ss7_pc_present; + temp.called_pty_address.pc.ss7.ITU24.family = sua.AssocDB.instance[sua_assoc_id].Dest.pc.ITU14.family; + temp.called_pty_address.pc.ss7.ITU24.pc = msg.sua_prim.dest_addr.pc; + } + + if (msg.sua_prim.dest_addr.gt_pres == TRUE) + { + temp.called_pty_address.address_fields_present.name_gt = GT_present; + temp.called_pty_address.name.GT.Translation_Type = msg.sua_prim.dest_addr.gt.translation_type; + temp.called_pty_address.name.GT.Numbering_Plan = msg.sua_prim.dest_addr.gt.num_plan; + temp.called_pty_address.name.GT.Nature_of_Address = msg.sua_prim.dest_addr.gt.nat_addr; + temp.called_pty_address.name.GT.nr_of_digits = msg.sua_prim.dest_addr.gt.nr_of_digits; + for (i=0; i < temp.called_pty_address.name.GT.nr_of_digits; i++) + temp.called_pty_address.name.GT.digits[i] = msg.sua_prim.dest_addr.gt.digits[i]; + temp.called_pty_address.name.GT.digits[temp.called_pty_address.name.GT.nr_of_digits] = '\0'; + } + + if (msg.sua_prim.dest_addr.hostname_pres == TRUE) + { + temp.called_pty_address.address_fields_present.name_gt = hostname_present; msg.sua_prim.dest_addr.hostname.copy( temp.called_pty_address.name.HostName, (msg.sua_prim.dest_addr.hostname.length()+1 ) ); @@ -678,46 +1051,45 @@ short process_unitdata_msg ( int local_sua_id, default: break; } - + temp.called_pty_address.address_fields_present.ssn_port = ssn_present; - temp.called_pty_address.ssn = msg.sua_prim.dest_addr.ssn; - - + temp.called_pty_address.ssn = msg.sua_prim.dest_addr.ssn; + + if (msg.sua_prim.data_pres == TRUE) temp.userdata = msg.sua_prim.data_string; else - cout << "sua_cl.c: no sua user data in unitdata msg \n"; + cout << "sua_cl.c: no sua user data in unitdata service msg \n"; /* Is this the final destination ? */ - if ( Assoc_sua.Find_local_sua ( temp.called_pty_address) > 0 ) - { - /* Yes, message has arrived at its final destination -> send to upper layer */ - /* store primitive in a list(is retrieve via sua_receive_msg) */ - rec_msg_pool.push_back(temp); - - /* call the application/user callBack function */ - local_sua.instance[local_sua_id].SUA_APLCallBack.ulp_ClDataIndNotif - ( local_sua_id, - N_UNITDATA, - temp.userdata.length() - ); + if ( sua.Find_local_sua ( temp.called_pty_address) > 0 ) + { + /* Yes, message has arrived at its final destination -> send to upper layer */ + /* store primitive in a list(is retrieve via sua_receive_msg) */ + rec_msg_pool.push_back(temp); + + /* call the application/user callBack function */ + sua.local_sua.instance[local_sua_id].SUA_APLCallBack.ulp_ClDataIndNotif + ( local_sua_id, + N_NOTICE, + temp.userdata.length() + ); } else - { + { /* No, Message has not arrived at its final destination -> */ /* route it to the next SUA node via an SCTP association nr x */ result = sua_route_Message( sctp_assoc_id, - local_sua_id, - msg, - temp.called_pty_address, - temp.calling_pty_address - ); - } - + local_sua_id, + msg, + temp.called_pty_address, + temp.calling_pty_address + ); + } + return(0); } - // end of module sua_cl.c diff --git a/sualibrary/sua/sua_cl.h b/sualibrary/sua/sua_cl.h index ed9bdc7..bd001ea 100644 --- a/sualibrary/sua/sua_cl.h +++ b/sualibrary/sua/sua_cl.h @@ -15,7 +15,7 @@ * * ***************************************************************************/ /* - * $Id: sua_cl.h,v 1.2 2002/03/01 12:57:38 p82609 Exp $ + * $Id: sua_cl.h,v 1.4 2002/04/08 15:28:06 p82609 Exp $ * * SUA implementation according to SUA draft issue 6. * @@ -48,9 +48,9 @@ * - send a SUA message to SCTP * - route/relay a received SUA msg towards to the correct SCTP association * - send a Unitdata msg to remote node - * (- send a Unitdata Service msg to remote node) + * - send a Unitdata Service msg to remote node * - Process a Unitdata msg - * (- Process a Unitdata Service msg) + * - Process a Unitdata Service msg */ #ifndef SUA_CL_H @@ -92,12 +92,24 @@ int sua_send_Unitdata( sccp_QOS_str &QOS, char *buffer, unsigned int len ); + +int sua_send_UDTService( Sua_container &org_msg, + sccp_addr_str &called_pty_address, + sccp_addr_str &calling_pty_address, + unsigned int UDTS_reason + ); short process_unitdata_msg ( int local_sua_id, unsigned int sua_assoc_id, Sua_container &sua_msg ); +short process_UDTService_msg ( int local_sua_id, + unsigned int sua_assoc_id, + Sua_container &sua_msg + ); + + #endif // SUA_CL_H // end of module sua_cl.h diff --git a/sualibrary/sua/sua_co.cpp b/sualibrary/sua/sua_co.cpp index cdfbbaa..607423e 100644 --- a/sualibrary/sua/sua_co.cpp +++ b/sualibrary/sua/sua_co.cpp @@ -15,7 +15,7 @@ * * ***************************************************************************/ /* - * $Id: sua_co.cpp,v 1.2 2002/03/01 12:57:38 p82609 Exp $ + * $Id: sua_co.cpp,v 1.7 2002/11/12 11:02:49 p82609 Exp $ * * SUA implementation according to SUA draft issue 6. * @@ -91,9 +91,7 @@ using namespace std; // import the dataobjects of SUA -extern db_Sua_LocalList local_sua; -extern db_Sua_RemoteList remote_sua; -extern db_Sua_AssociationList Assoc_sua; +extern db_Sua_DatabaseList sua; // import the TCB pool of SUA extern tcb_Sua_TCB_arr tcb_pool; @@ -117,16 +115,16 @@ int sua_send_CORE( sccp_QOS_str &QOS, tcb_Sua_TCB_str *tcb_ptr ) { - Sua_container msg; - Sua_syntax_error_struct error; - int error_value; - int string_size, datalen; - signed int SCTP_assoc_id; - int sua_assoc_id; - signed int sctp_loadshare = SCTP_USE_PRIMARY; - short sctp_stream_id = 0; - int sctp_delivery_type, result; - tcb_Sua_msg_elem sua_msg; + Sua_container msg; + Sua_syntax_error_struct error; + int error_value; + int i, string_size, datalen; + signed int SCTP_assoc_id; + int sua_assoc_id; + signed int sctp_loadshare = SCTP_USE_PRIMARY; + short sctp_stream_id = 0; + int sctp_delivery_type, result; + tcb_Sua_msg_elem sua_msg; // init the message @@ -214,10 +212,30 @@ int sua_send_CORE( sccp_QOS_str &QOS, case(route_on_name_gt): msg.sua_prim.source_addr.ip_addr_pres = FALSE; msg.sua_prim.source_addr.pc_pres = FALSE; - msg.sua_prim.source_addr.hostname_pres = TRUE; - msg.sua_prim.source_addr.hostname = calling_pty_address.name.HostName; - msg.sua_prim.source_addr_pres = TRUE; - msg.sua_prim.source_addr.rout_ind = ri_route_hostname; + if (calling_pty_address.address_fields_present.name_gt == hostname_present){ + msg.sua_prim.source_addr_pres = TRUE; + msg.sua_prim.source_addr.rout_ind = ri_route_hostname; + msg.sua_prim.source_addr.hostname_pres = TRUE; + msg.sua_prim.source_addr.gt_pres = FALSE; + msg.sua_prim.source_addr.hostname = calling_pty_address.name.HostName; + + } + else if (calling_pty_address.address_fields_present.name_gt == GT_present){ + msg.sua_prim.source_addr_pres = TRUE; + msg.sua_prim.source_addr.rout_ind = ri_route_GT; + msg.sua_prim.source_addr.hostname_pres = FALSE; + msg.sua_prim.source_addr.gt_pres = TRUE; + msg.sua_prim.source_addr.gt.translation_type = calling_pty_address.name.GT.Translation_Type; + msg.sua_prim.source_addr.gt.num_plan = calling_pty_address.name.GT.Numbering_Plan; + msg.sua_prim.source_addr.gt.nat_addr = calling_pty_address.name.GT.Nature_of_Address; + msg.sua_prim.source_addr.gt.nr_of_digits = calling_pty_address.name.GT.nr_of_digits; + for (i=0; i < calling_pty_address.name.GT.nr_of_digits; i++) + msg.sua_prim.source_addr.gt.digits[i] = calling_pty_address.name.GT.digits[i]; + + } + else + cout << "unsupported CLG name/GT address option\n"; + msg.sua_prim.source_addr.ssn_incl = TRUE; msg.sua_prim.source_addr.pc_incl = FALSE; msg.sua_prim.source_addr.gt_incl = TRUE; @@ -279,11 +297,30 @@ int sua_send_CORE( sccp_QOS_str &QOS, break; case(route_on_name_gt): msg.sua_prim.dest_addr.ip_addr_pres = FALSE; - msg.sua_prim.dest_addr.hostname_pres = TRUE; msg.sua_prim.dest_addr.pc_pres = FALSE; - msg.sua_prim.dest_addr.hostname = called_pty_address.name.HostName; - msg.sua_prim.dest_addr_pres = TRUE; - msg.sua_prim.dest_addr.rout_ind = ri_route_hostname; + if (called_pty_address.address_fields_present.name_gt == hostname_present){ + msg.sua_prim.dest_addr_pres = TRUE; + msg.sua_prim.dest_addr.rout_ind = ri_route_hostname; + msg.sua_prim.dest_addr.hostname_pres = TRUE; + msg.sua_prim.dest_addr.gt_pres = FALSE; + msg.sua_prim.dest_addr.hostname = called_pty_address.name.HostName; + + } + else if (called_pty_address.address_fields_present.name_gt == GT_present){ + msg.sua_prim.dest_addr_pres = TRUE; + msg.sua_prim.dest_addr.rout_ind = ri_route_GT; + msg.sua_prim.dest_addr.hostname_pres = FALSE; + msg.sua_prim.dest_addr.gt_pres = TRUE; + msg.sua_prim.dest_addr.gt.translation_type = called_pty_address.name.GT.Translation_Type; + msg.sua_prim.dest_addr.gt.num_plan = called_pty_address.name.GT.Numbering_Plan; + msg.sua_prim.dest_addr.gt.nat_addr = called_pty_address.name.GT.Nature_of_Address; + msg.sua_prim.dest_addr.gt.nr_of_digits = called_pty_address.name.GT.nr_of_digits; + for (i=0; i < called_pty_address.name.GT.nr_of_digits; i++) + msg.sua_prim.dest_addr.gt.digits[i] = called_pty_address.name.GT.digits[i]; + } + else + cout << "unsupported CLG name/GT address option\n"; + msg.sua_prim.dest_addr.ssn_incl = TRUE; msg.sua_prim.dest_addr.pc_incl = FALSE; msg.sua_prim.dest_addr.gt_incl = TRUE; @@ -320,10 +357,10 @@ int sua_send_CORE( sccp_QOS_str &QOS, #ifdef DEBUG cout << "call routing function\n"; #endif - SCTP_assoc_id = Assoc_sua.route_msg( called_pty_address, - calling_pty_address, - sua_assoc_id - ); + SCTP_assoc_id = sua.route_msg( called_pty_address, + calling_pty_address, + sua_assoc_id + ); #ifdef DEBUG cout << "routed to SCTP assoc " << SCTP_assoc_id << "/SUA association " << sua_assoc_id << "\n"; #endif @@ -346,15 +383,15 @@ int sua_send_CORE( sccp_QOS_str &QOS, datalen = msg.sua_msg.length(); // send data to SCTP - result = sua_send_Message( SCTP_assoc_id, - sctp_stream_id, - sctp_delivery_type, - sctp_loadshare, - databuf, - datalen - ); + result = sua_send_Message( SCTP_assoc_id, + sctp_stream_id, + sctp_delivery_type, + sctp_loadshare, + databuf, + datalen + ); - delete databuf; + delete databuf; error_value = 0; #ifdef DEBUG @@ -372,16 +409,14 @@ int sua_send_CORE( sccp_QOS_str &QOS, { /* NO it does NOT exist. */ /* - Try to set up the association */ - sua_assoc_id = Assoc_sua.Dynamic_Associate ( local_sua, - remote_sua, - called_pty_address, - calling_pty_address, - 1, - 1, - 1 - ); + sua_assoc_id = sua.Dynamic_Associate ( called_pty_address, + calling_pty_address, + 1, + 1, + 1 + ); /* save newly assigned SCTP association id in SCOC TCB */ - tcb_ptr->sctp_Association_id = Assoc_sua.instance[sua_assoc_id].SCTP_assoc_id; + tcb_ptr->sctp_Association_id = sua.AssocDB.instance[sua_assoc_id].SCTP_assoc_id; /* - save the msg till the association is setup or */ /* association setup fails -> drop saved msg */ @@ -391,11 +426,11 @@ int sua_send_CORE( sccp_QOS_str &QOS, sua_msg.valid = true; msg_store.add_msg ( sua_assoc_id, sua_msg - ); + ); error_value = -1; } - + return(error_value); } @@ -433,11 +468,11 @@ int sua_send_CORESP( sccp_QOS_str &QOS, msg.sua_prim.importance = 5; msg.sua_prim.hop_count_pres = TRUE; msg.sua_prim.hop_count = 15; - + // QOS choice switch (QOS.prot_class) { - case(class2): // connectionless transport, non-sequenced + case(class2): // connection-oriented transport, non-sequenced msg.sua_prim.prot_class_pres = TRUE; msg.sua_prim.prot_class.pcl = prot_class_2; msg.sua_prim.seq_control_pres = TRUE; @@ -455,7 +490,7 @@ int sua_send_CORESP( sccp_QOS_str &QOS, msg.sua_prim.prot_class.return_option = TRUE; else msg.sua_prim.prot_class.return_option = FALSE; - + // fill in the connection-oriented specific data of the msg msg.sua_prim.source_ref_pres = TRUE; msg.sua_prim.source_ref = tcb_ptr->Source_LR ; @@ -475,7 +510,7 @@ int sua_send_CORESP( sccp_QOS_str &QOS, if (len > 0) { msg.sua_prim.data_pres = TRUE; - string stemp(buffer,len); + string stemp(buffer,len); msg.sua_prim.data_string = stemp; } else @@ -492,32 +527,32 @@ int sua_send_CORESP( sccp_QOS_str &QOS, #endif #ifdef SUA_MANAGEMENT - sua_assoc_id = Assoc_sua.Find_association( SCTP_assoc_id, + sua_assoc_id = sua.AssocDB.Find_association( SCTP_assoc_id, local_sua_id, remote_sua_id ); - if (Assoc_sua.instance[sua_assoc_id].asp.status == asp_active) + if (sua.AssocDB.instance[sua_assoc_id].asp.status == asp_active) { #endif /* copy data into buffer, then finally... */ - char* databuf = new char[msg.sua_msg.length()]; + char* databuf = new char[msg.sua_msg.length()]; msg.sua_msg.copy(databuf, msg.sua_msg.length()); - + datalen = msg.sua_msg.length(); - + // send data to SCTP - result = sua_send_Message( SCTP_assoc_id, - sctp_stream_id, - sctp_delivery_type, - sctp_loadshare, - databuf, - datalen - ); - - delete databuf; + result = sua_send_Message( SCTP_assoc_id, + sctp_stream_id, + sctp_delivery_type, + sctp_loadshare, + databuf, + datalen + ); + + delete databuf; error_value = 0; - + #ifdef SUA_MANAGEMENT } else @@ -528,11 +563,11 @@ int sua_send_CORESP( sccp_QOS_str &QOS, error_value = -1; } #endif - + #ifdef DEBUG cout << "sua_co.c:result sctp send = "<< result << "\n"; #endif - + return(error_value); } @@ -556,7 +591,7 @@ int sua_send_CODATA( sccp_QOS_str &QOS, signed int sctp_loadshare = SCTP_USE_PRIMARY; short sctp_stream_id = 0; int sctp_delivery_type, result = 0; - + // init the message msg.sua_init(); @@ -593,8 +628,8 @@ int sua_send_CODATA( sccp_QOS_str &QOS, msg.sua_prim.prot_class.return_option = TRUE; else msg.sua_prim.prot_class.return_option = FALSE; - - + + // fill in the connection-oriented specific data of the msg msg.sua_prim.source_ref_pres = FALSE; msg.sua_prim.dest_ref_pres = TRUE; @@ -611,7 +646,7 @@ int sua_send_CODATA( sccp_QOS_str &QOS, // fill in the user data msg.sua_prim.data_pres = TRUE; - string stemp(buffer,len); + string stemp(buffer,len); msg.sua_prim.data_string = stemp; // encode the SUA unitdata message @@ -624,33 +659,33 @@ int sua_send_CODATA( sccp_QOS_str &QOS, cout << "routed to SCTP assoc " << SCTP_assoc_id << "\n"; #endif #ifdef SUA_MANAGEMENT - sua_assoc_id = Assoc_sua.Find_association( SCTP_assoc_id, + sua_assoc_id = sua.AssocDB.Find_association( SCTP_assoc_id, local_sua_id, remote_sua_id ); - if (Assoc_sua.instance[sua_assoc_id].asp.status == asp_active) + if (sua.AssocDB.instance[sua_assoc_id].asp.status == asp_active) { #endif - /* copy data into buffer, then finally... */ - char* databuf = new char[msg.sua_msg.length()]; + /* copy data into buffer, then finally... */ + char* databuf = new char[msg.sua_msg.length()]; msg.sua_msg.copy(databuf, msg.sua_msg.length()); - + datalen = msg.sua_msg.length(); - + // send data to SCTP - result = sua_send_Message( SCTP_assoc_id, - sctp_stream_id, - sctp_delivery_type, - sctp_loadshare, - databuf, - datalen - ); - - delete databuf; + result = sua_send_Message( SCTP_assoc_id, + sctp_stream_id, + sctp_delivery_type, + sctp_loadshare, + databuf, + datalen + ); + + delete databuf; error_value = 0; - + #ifdef SUA_MANAGEMENT } else @@ -661,11 +696,11 @@ int sua_send_CODATA( sccp_QOS_str &QOS, error_value = -1; } #endif - + #ifdef DEBUG cout << "sua_co.c:result sctp send = "<< result << "\n"; #endif - + return(error_value); } @@ -689,7 +724,7 @@ int sua_send_CORELRQ( sccp_QOS_str &QOS, signed int sctp_loadshare = SCTP_USE_PRIMARY; short sctp_stream_id = 0; int sctp_delivery_type, result = 0; - + // init the message msg.sua_init(); @@ -726,8 +761,8 @@ int sua_send_CORELRQ( sccp_QOS_str &QOS, msg.sua_prim.prot_class.return_option = TRUE; else msg.sua_prim.prot_class.return_option = FALSE; - - + + // fill in the connection-oriented specific data of the msg msg.sua_prim.source_ref_pres = TRUE; msg.sua_prim.source_ref = tcb_ptr->Source_LR ; @@ -748,7 +783,7 @@ int sua_send_CORELRQ( sccp_QOS_str &QOS, // fill in the user data msg.sua_prim.data_pres = TRUE; - string stemp(buffer,len); + string stemp(buffer,len); msg.sua_prim.data_string = stemp; // encode the SUA unitdata message @@ -762,32 +797,32 @@ int sua_send_CORELRQ( sccp_QOS_str &QOS, #endif #ifdef SUA_MANAGEMENT - sua_assoc_id = Assoc_sua.Find_association( SCTP_assoc_id, - local_sua_id, - remote_sua_id - ); - - if (Assoc_sua.instance[sua_assoc_id].asp.status == asp_active) + sua_assoc_id = sua.AssocDB.Find_association( SCTP_assoc_id, + local_sua_id, + remote_sua_id + ); + + if (sua.AssocDB.instance[sua_assoc_id].asp.status == asp_active) { #endif - /* copy data into buffer, then finally... */ - char* databuf = new char[msg.sua_msg.length()]; + /* copy data into buffer, then finally... */ + char* databuf = new char[msg.sua_msg.length()]; msg.sua_msg.copy(databuf, msg.sua_msg.length()); - + datalen = msg.sua_msg.length(); - + // send data to SCTP - result = sua_send_Message( SCTP_assoc_id, - sctp_stream_id, - sctp_delivery_type, - sctp_loadshare, - databuf, - datalen - ); - - delete databuf; + result = sua_send_Message( SCTP_assoc_id, + sctp_stream_id, + sctp_delivery_type, + sctp_loadshare, + databuf, + datalen + ); + + delete databuf; error_value = 0; - + #ifdef SUA_MANAGEMENT } else @@ -798,11 +833,11 @@ int sua_send_CORELRQ( sccp_QOS_str &QOS, error_value = -1; } #endif - + #ifdef DEBUG cout << "sua_co.c:result sctp send = "<< result << "\n"; #endif - + return(error_value); } @@ -826,7 +861,7 @@ int sua_send_CORELCO( sccp_QOS_str &QOS, signed int sctp_loadshare = SCTP_USE_PRIMARY; short sctp_stream_id = 0; int sctp_delivery_type, result = 0; - + // init the message msg.sua_init(); @@ -863,8 +898,8 @@ int sua_send_CORELCO( sccp_QOS_str &QOS, msg.sua_prim.prot_class.return_option = TRUE; else msg.sua_prim.prot_class.return_option = FALSE; - - + + // fill in the connection-oriented specific data of the msg msg.sua_prim.source_ref_pres = TRUE; msg.sua_prim.source_ref = tcb_ptr->Source_LR ; @@ -876,7 +911,7 @@ int sua_send_CORELCO( sccp_QOS_str &QOS, // fill in the user data msg.sua_prim.data_pres = TRUE; - string stemp(buffer,len); + string stemp(buffer,len); msg.sua_prim.data_string = stemp; // encode the SUA unitdata message @@ -895,32 +930,32 @@ int sua_send_CORELCO( sccp_QOS_str &QOS, #endif #ifdef SUA_MANAGEMENT - sua_assoc_id = Assoc_sua.Find_association( SCTP_assoc_id, + sua_assoc_id = sua.AssocDB.Find_association( SCTP_assoc_id, local_sua_id, remote_sua_id ); - if (Assoc_sua.instance[sua_assoc_id].asp.status == asp_active) + if (sua.AssocDB.instance[sua_assoc_id].asp.status == asp_active) { #endif - /* copy data into buffer, then finally... */ - char* databuf = new char[msg.sua_msg.length()]; + /* copy data into buffer, then finally... */ + char* databuf = new char[msg.sua_msg.length()]; msg.sua_msg.copy(databuf, msg.sua_msg.length()); - + datalen = msg.sua_msg.length(); - + // send data to SCTP - result = sua_send_Message( SCTP_assoc_id, - sctp_stream_id, - sctp_delivery_type, - sctp_loadshare, - databuf, - datalen - ); - - delete databuf; + result = sua_send_Message( SCTP_assoc_id, + sctp_stream_id, + sctp_delivery_type, + sctp_loadshare, + databuf, + datalen + ); + + delete databuf; error_value = 0; - + #ifdef SUA_MANAGEMENT } else @@ -931,14 +966,14 @@ int sua_send_CORELCO( sccp_QOS_str &QOS, error_value = -1; } #endif - + #ifdef DEBUG cout << "sua_co.c:result sctp send = "<< result << "\n"; #endif - + // release the TCB of this connection tcb_pool.release_TCB(Sua_ConnId); - + return(error_value); } @@ -962,7 +997,7 @@ int sua_send_COREF( sccp_QOS_str &QOS, signed int sctp_loadshare = SCTP_USE_PRIMARY; short sctp_stream_id = 0; int sctp_delivery_type, result = 0; - sccp_addr_str called_pty_address; + sccp_addr_str called_pty_address; // init the message msg.sua_init(); @@ -1001,17 +1036,17 @@ int sua_send_COREF( sccp_QOS_str &QOS, msg.sua_prim.prot_class.return_option = FALSE; called_pty_address = tcb_ptr->remote_address; - + // fill in the destination address(=remote sua address/CLD) - switch (called_pty_address.routing_ind) + switch (called_pty_address.routing_ind) { case (route_on_ssn): - + if (called_pty_address.address_fields_present.pc == ipvx_pc_present) { msg.sua_prim.dest_addr.ip_addr_pres = TRUE; if (called_pty_address.pc.ipvx.sa.sa_family == AF_INET) - { + { msg.sua_prim.dest_addr.ip_addr_type = ip_v4; msg.sua_prim.dest_addr.ip_addr.ipv4 = called_pty_address.pc.ipvx.sin; } @@ -1040,7 +1075,7 @@ int sua_send_COREF( sccp_QOS_str &QOS, return(INVALID_CLD_ADDRESS); break; } - + // fill in the connection-oriented specific data of the msg msg.sua_prim.source_ref_pres = FALSE; msg.sua_prim.dest_ref_pres = TRUE; @@ -1051,7 +1086,7 @@ int sua_send_COREF( sccp_QOS_str &QOS, // fill in the user data msg.sua_prim.data_pres = TRUE; - string stemp(buffer,len); + string stemp(buffer,len); msg.sua_prim.data_string = stemp; // encode the SUA unitdata message @@ -1070,32 +1105,32 @@ int sua_send_COREF( sccp_QOS_str &QOS, #endif #ifdef SUA_MANAGEMENT - sua_assoc_id = Assoc_sua.Find_association( SCTP_assoc_id, - local_sua_id, - remote_sua_id - ); - - if (Assoc_sua.instance[sua_assoc_id].asp.status == asp_active) + sua_assoc_id = sua.AssocDB.Find_association( SCTP_assoc_id, + local_sua_id, + remote_sua_id + ); + + if (sua.AssocDB.instance[sua_assoc_id].asp.status == asp_active) { #endif - /* copy data into buffer, then finally... */ - char* databuf = new char[msg.sua_msg.length()]; + /* copy data into buffer, then finally... */ + char* databuf = new char[msg.sua_msg.length()]; msg.sua_msg.copy(databuf, msg.sua_msg.length()); - + datalen = msg.sua_msg.length(); - + // send data to SCTP - result = sua_send_Message( SCTP_assoc_id, - sctp_stream_id, - sctp_delivery_type, - sctp_loadshare, - databuf, - datalen - ); + result = sua_send_Message( SCTP_assoc_id, + sctp_stream_id, + sctp_delivery_type, + sctp_loadshare, + databuf, + datalen + ); - delete databuf; + delete databuf; error_value = 0; - + #ifdef SUA_MANAGEMENT } else @@ -1129,12 +1164,16 @@ short process_CORE_msg ( unsigned int sua_assoc_id, Sua_container &msg ) { - unsigned int local_sua_id = 0; - sua_save_str temp; + int i, result = 0; + int sctp_assoc_id = 0; + unsigned int local_sua_id = 0; + sua_save_str temp; + unsigned int Sua_Out_ConnId; + tcb_Sua_TCB_str *tcb_out_ptr; temp.primitive = N_CONNECT_IND; temp.user_ref = Sua_ConnId; - + if ( msg.sua_prim.prot_class_pres ) { // QOS choice @@ -1152,7 +1191,7 @@ short process_CORE_msg ( unsigned int sua_assoc_id, return(PROTOCOL_CLASS_NOT_SPECIFIED); break; } - + temp.QOS.return_msg_on_error = (msg.sua_prim.prot_class.return_option == TRUE); } @@ -1163,16 +1202,16 @@ short process_CORE_msg ( unsigned int sua_assoc_id, // which types are present in the address(ip pc, SS7 pc, GT, hostname) if (msg.sua_prim.source_addr.ip_addr_pres == TRUE) { - temp.calling_pty_address.address_fields_present.pc = ipvx_pc_present; + temp.calling_pty_address.address_fields_present.pc = ipvx_pc_present; if (msg.sua_prim.source_addr.ip_addr_type == ip_v4) { temp.calling_pty_address.pc.ipvx.sin = msg.sua_prim.source_addr.ip_addr.ipv4; temp.calling_pty_address.pc.ipvx.sa.sa_family = AF_INET; - temp.calling_pty_address.pc.ipvx.sin.sin_port = Assoc_sua.instance[sua_assoc_id].Dest.addrs[0].sin.sin_port; + temp.calling_pty_address.pc.ipvx.sin.sin_port = sua.AssocDB.instance[sua_assoc_id].Dest.addrs[0].sin.sin_port; } else if (msg.sua_prim.source_addr.ip_addr_type == ip_v6) { temp.calling_pty_address.pc.ipvx.sin6 = msg.sua_prim.source_addr.ip_addr.ipv6; temp.calling_pty_address.pc.ipvx.sa.sa_family = AF_INET6; - temp.calling_pty_address.pc.ipvx.sin6.sin6_port = Assoc_sua.instance[sua_assoc_id].Dest.addrs[0].sin6.sin6_port; + temp.calling_pty_address.pc.ipvx.sin6.sin6_port = sua.AssocDB.instance[sua_assoc_id].Dest.addrs[0].sin6.sin6_port; } else cout << "Unknown IP address format\n"; @@ -1180,16 +1219,29 @@ short process_CORE_msg ( unsigned int sua_assoc_id, if (msg.sua_prim.source_addr.pc_pres == TRUE) { temp.calling_pty_address.address_fields_present.pc = ss7_pc_present; - temp.calling_pty_address.pc.ss7.ITU24.family = ITU24bit; + temp.calling_pty_address.pc.ss7.ITU24.family = ITU24bit; temp.calling_pty_address.pc.ss7.ITU24.pc = msg.sua_prim.source_addr.pc; } if (msg.sua_prim.source_addr.gt_pres == TRUE) { cout << "Global Title : unsupported address format\n"; } + + if (msg.sua_prim.source_addr.gt_pres == TRUE) + { + temp.calling_pty_address.address_fields_present.name_gt = GT_present; + temp.calling_pty_address.name.GT.Translation_Type = msg.sua_prim.source_addr.gt.translation_type; + temp.calling_pty_address.name.GT.Numbering_Plan = msg.sua_prim.source_addr.gt.num_plan; + temp.calling_pty_address.name.GT.Nature_of_Address = msg.sua_prim.source_addr.gt.nat_addr; + temp.calling_pty_address.name.GT.nr_of_digits = msg.sua_prim.source_addr.gt.nr_of_digits; + for (i=0; i < temp.calling_pty_address.name.GT.nr_of_digits; i++) + temp.calling_pty_address.name.GT.digits[i] = msg.sua_prim.source_addr.gt.digits[i]; + temp.calling_pty_address.name.GT.digits[temp.calling_pty_address.name.GT.nr_of_digits] = '\0'; + } + if (msg.sua_prim.source_addr.hostname_pres == TRUE) { - temp.calling_pty_address.address_fields_present.name_gt = hostname_present; + temp.calling_pty_address.address_fields_present.name_gt = hostname_present; msg.sua_prim.source_addr.hostname.copy( temp.calling_pty_address.name.HostName, (msg.sua_prim.source_addr.hostname.length()+1 ) ); @@ -1222,31 +1274,60 @@ short process_CORE_msg ( unsigned int sua_assoc_id, break; } - if (msg.sua_prim.source_addr.ssn_incl == TRUE) { + if (msg.sua_prim.source_addr.ssn_incl == TRUE) { temp.calling_pty_address.address_fields_present.ssn_port = ssn_present; temp.calling_pty_address.ssn = msg.sua_prim.source_addr.ssn; } else temp.calling_pty_address.address_fields_present.ssn_port = no_sap_present; - + // retrieve the called(=destination) address(=should be our own local addr) // not completely done yet + if (msg.sua_prim.dest_addr.ip_addr_pres == TRUE) + { + temp.called_pty_address.address_fields_present.pc = ipvx_pc_present; + if (msg.sua_prim.dest_addr.ip_addr_type == ip_v4) { + temp.called_pty_address.pc.ipvx.sin = msg.sua_prim.dest_addr.ip_addr.ipv4; + temp.called_pty_address.pc.ipvx.sa.sa_family = AF_INET; + temp.called_pty_address.pc.ipvx.sin.sin_port = sua.AssocDB.instance[sua_assoc_id].Dest.addrs[0].sin.sin_port; + } + else if (msg.sua_prim.dest_addr.ip_addr_type == ip_v6) { + temp.called_pty_address.pc.ipvx.sin6 = msg.sua_prim.dest_addr.ip_addr.ipv6; + temp.called_pty_address.pc.ipvx.sa.sa_family = AF_INET6; + temp.called_pty_address.pc.ipvx.sin6.sin6_port = sua.AssocDB.instance[sua_assoc_id].Dest.addrs[0].sin6.sin6_port; + } + else + cout << "Unknown IP address format\n"; + } if (msg.sua_prim.dest_addr.pc_pres == TRUE) { temp.called_pty_address.address_fields_present.pc = ss7_pc_present; - temp.called_pty_address.pc.ss7.ITU24.family = ITU24bit; - temp.called_pty_address.pc.ss7.ITU24.pc = msg.sua_prim.source_addr.pc; + temp.called_pty_address.pc.ss7.ITU24.family = ITU24bit; + temp.called_pty_address.pc.ss7.ITU24.pc = msg.sua_prim.dest_addr.pc; + } + + if (msg.sua_prim.dest_addr.gt_pres == TRUE) + { + temp.called_pty_address.address_fields_present.name_gt = GT_present; + temp.called_pty_address.name.GT.Translation_Type = msg.sua_prim.dest_addr.gt.translation_type; + temp.called_pty_address.name.GT.Numbering_Plan = msg.sua_prim.dest_addr.gt.num_plan; + temp.called_pty_address.name.GT.Nature_of_Address = msg.sua_prim.dest_addr.gt.nat_addr; + temp.called_pty_address.name.GT.nr_of_digits = msg.sua_prim.dest_addr.gt.nr_of_digits; + for (i=0; i < temp.called_pty_address.name.GT.nr_of_digits; i++) + temp.called_pty_address.name.GT.digits[i] = msg.sua_prim.dest_addr.gt.digits[i]; + temp.called_pty_address.name.GT.digits[temp.called_pty_address.name.GT.nr_of_digits] = '\0'; } if (msg.sua_prim.dest_addr.hostname_pres == TRUE) { - temp.called_pty_address.address_fields_present.name_gt = hostname_present; + temp.called_pty_address.address_fields_present.name_gt = hostname_present; msg.sua_prim.dest_addr.hostname.copy( temp.called_pty_address.name.HostName, (msg.sua_prim.dest_addr.hostname.length()+1 ) ); temp.called_pty_address.name.HostName[msg.sua_prim.dest_addr.hostname.length()] = '\0'; } + // routing indicator switch (msg.sua_prim.dest_addr.rout_ind) { @@ -1262,20 +1343,20 @@ short process_CORE_msg ( unsigned int sua_assoc_id, default: break; } - + temp.called_pty_address.address_fields_present.ssn_port = ssn_present; - temp.called_pty_address.ssn = msg.sua_prim.dest_addr.ssn; + temp.called_pty_address.ssn = msg.sua_prim.dest_addr.ssn; // fill in the allocated TCB tcb_ptr->Source_LR = Sua_ConnId; tcb_ptr->Dest_LR = msg.sua_prim.source_ref; tcb_ptr->User_ref_id = 1; - tcb_ptr->sctp_Association_id = Assoc_sua.instance[sua_assoc_id].SCTP_assoc_id; + tcb_ptr->sctp_Association_id = sua.AssocDB.instance[sua_assoc_id].SCTP_assoc_id; tcb_ptr->state = scoc_incoming; tcb_ptr->remote_address = temp.calling_pty_address; tcb_ptr->seq_number = Sua_ConnId % 255; - local_sua_id = Assoc_sua.instance[sua_assoc_id].local_sua_id; + local_sua_id = sua.AssocDB.instance[sua_assoc_id].local_sua_id; #ifdef DEBUG cout << "TCB source_LR = " << tcb_ptr->Source_LR << "\n"; @@ -1288,22 +1369,55 @@ short process_CORE_msg ( unsigned int sua_assoc_id, temp.userdata = msg.sua_prim.data_string; else cout << "sua_co.c: no sua user data in CORE msg \n"; - - // store primitive in a list(is retrieve via sua_receive_msg) - rec_msg_pool.push_back(temp); -#ifdef DEBUG - cout << "primitive stored , local_sua_id = " << local_sua_id << "\n"; -#endif + /* Is this the final destination ? */ + if ( sua.Find_local_sua ( temp.called_pty_address) > 0 ) + { + /* Yes, message has arrived at its final destination -> send */ + /* to upper layer */ + /* store primitive in a list(is retrieve via sua_receive_msg) */ + rec_msg_pool.push_back(temp); + + /* call the application/user callBack function */ + sua.local_sua.instance[local_sua_id].SUA_APLCallBack.ulp_ConnIndNotif + ( local_sua_id, + Sua_ConnId, + temp.userdata.length() + ); + } + else + { + /* No, Message has not arrived at its final destination -> */ + /* route it to the next SUA node via an SCTP association nr x */ + /* setup TCB linkage for CO */ - /* call the application/user callBack function */ - local_sua.instance[local_sua_id].SUA_APLCallBack.ulp_ConnIndNotif - ( local_sua_id, - Sua_ConnId, - temp.userdata.length() - ); + tcb_out_ptr = tcb_pool.allocate_TCB(Sua_Out_ConnId); - return(0); + msg.sua_prim.source_ref = Sua_Out_ConnId; + + result = sua_route_Message( sctp_assoc_id, + local_sua_id, + msg, + temp.called_pty_address, + temp.calling_pty_address + ); + + + // fill in the allocated TCB + tcb_out_ptr->Source_LR = Sua_Out_ConnId; + tcb_out_ptr->User_ref_id = 1; + tcb_out_ptr->sctp_Association_id = sctp_assoc_id; + /* fill in link from TCB_out to first TCB */ + tcb_out_ptr->scoc_tcb_id = Sua_ConnId; + tcb_out_ptr->state = scoc_outgoing; + tcb_out_ptr->remote_address = temp.called_pty_address; + tcb_out_ptr->seq_number = Sua_Out_ConnId % 255; + + /* fill in the link from the first TCB to the TCB_out */ + tcb_ptr->scoc_tcb_id = Sua_Out_ConnId; + } + + return(0); } /***********************************************************************/ @@ -1317,12 +1431,15 @@ short process_COAK_msg ( unsigned int sua_assoc_id, { unsigned int local_sua_id = 0; sua_save_str temp; + unsigned int Sua_Out_ConnId; + tcb_Sua_TCB_str *tcb_out_ptr; + Sua_syntax_error_struct error; temp.primitive = N_CONNECT_CONF; temp.user_ref = sua_ConnId; - + if (msg.sua_prim.prot_class_pres) - { + { // QOS choice switch ( msg.sua_prim.prot_class.pcl) { @@ -1338,15 +1455,15 @@ short process_COAK_msg ( unsigned int sua_assoc_id, return(PROTOCOL_CLASS_NOT_SPECIFIED); break; } - + temp.QOS.return_msg_on_error = (msg.sua_prim.prot_class.return_option == TRUE); } temp.QOS.sequence_number = 0; temp.QOS.importance = msg.sua_prim.importance; - + // retrieve the clg(=source) address (=remote sua address) - + // retrieve the called(=destination) address(=should be our own local addr) // fill in the allocated TCB @@ -1354,7 +1471,7 @@ short process_COAK_msg ( unsigned int sua_assoc_id, tcb_ptr->User_ref_id = 1; tcb_ptr->state = scoc_active; - local_sua_id = Assoc_sua.instance[sua_assoc_id].local_sua_id; + local_sua_id = sua.AssocDB.instance[sua_assoc_id].local_sua_id; #ifdef DEBUG cout << "TCB source_LR = " << tcb_ptr->Source_LR << "\n"; @@ -1367,20 +1484,68 @@ short process_COAK_msg ( unsigned int sua_assoc_id, temp.userdata = msg.sua_prim.data_string; else cout << "sua_co.c: no sua user data in CODATA msg \n"; - - // store primitive in a list(is retrieve via sua_receive_msg) - rec_msg_pool.push_back(temp); - - - /* call the application/user callBack function */ - local_sua.instance[local_sua_id].SUA_APLCallBack.ulp_ConnConfIndNotif - ( local_sua_id, - sua_ConnId, - temp.userdata.length() - ); + /* Look if this is the end or intermediate node */ + Sua_Out_ConnId = tcb_ptr->scoc_tcb_id; - return(0); + /* Is this the final destination ? */ + if ( Sua_Out_ConnId == 0 ) + { + /* Yes, message has arrived at its final destination -> send */ + /* to upper layer */ + + // store primitive in a list(is retrieve via sua_receive_msg) + rec_msg_pool.push_back(temp); + + /* call the application/user callBack function */ + sua.local_sua.instance[local_sua_id].SUA_APLCallBack.ulp_ConnConfIndNotif + ( local_sua_id, + sua_ConnId, + temp.userdata.length() + ); + + } + else + { + /* No, Message has not arrived at its final destination -> */ + /* route it to the next SUA node via an SCTP association nr x */ + /* get association id from SCOC TCB */ + + tcb_out_ptr = tcb_pool.get_tcb(Sua_Out_ConnId); + + msg.sua_prim.source_ref = tcb_out_ptr->Source_LR; + msg.sua_prim.dest_ref = tcb_out_ptr->Dest_LR; + + error = msg.sua_encode(); + + /* copy data into buffer, then finally... */ + signed int sctp_loadshare = SCTP_USE_PRIMARY; + short sctp_stream_id = 0; + int sctp_delivery_type = 0 ,datalen , result = 0; + char* databuf = new char[msg.sua_msg.length()]; + + msg.sua_msg.copy(databuf, msg.sua_msg.length()); + + datalen = msg.sua_msg.length(); + + // send data to SCTP + result = sua_send_Message( tcb_out_ptr->sctp_Association_id, + sctp_stream_id, + sctp_delivery_type, + sctp_loadshare, + databuf, + datalen + ); + + delete databuf; + + // set the outgoing TCB on active + tcb_out_ptr->state = scoc_active; + + } + + + return(0); } /***********************************************************************/ @@ -1394,20 +1559,23 @@ short process_CODATA_msg ( unsigned int sua_assoc_id, { unsigned int local_sua_id = 0; sua_save_str temp; + unsigned int Sua_Out_ConnId; + tcb_Sua_TCB_str *tcb_out_ptr; + Sua_syntax_error_struct error; //temp.primitive = N_CODATA; temp.user_ref = sua_ConnId; - + temp.QOS.return_msg_on_error = (msg.sua_prim.prot_class.return_option == TRUE); temp.QOS.sequence_number = 0; temp.QOS.importance = msg.sua_prim.importance; - + // retrieve the clg(=source) address (=remote sua address) // not needed -> to be found in TCB // retrieve the called(=destination) address(=should be our own local addr) // not needed -> to be found in TCB - local_sua_id = Assoc_sua.instance[sua_assoc_id].local_sua_id; + local_sua_id = sua.AssocDB.instance[sua_assoc_id].local_sua_id; #ifdef DEBUG cout << "TCB source_LR = " << tcb_ptr->Source_LR << "\n"; @@ -1420,21 +1588,62 @@ short process_CODATA_msg ( unsigned int sua_assoc_id, temp.userdata = msg.sua_prim.data_string; else cout << "sua_co.c: no sua user data in CODATA msg \n"; - - // store primitive in a list(is retrieve via sua_receive_msg) - rec_msg_pool.push_back(temp); - - - /* call the application/user callBack function */ - local_sua.instance[local_sua_id].SUA_APLCallBack.ulp_ConnDataIndNotif - ( local_sua_id, - sua_ConnId, - temp.userdata.length() - ); - return(0); + /* Look if this is the end or intermediate node */ + Sua_Out_ConnId = tcb_ptr->scoc_tcb_id; + + /* Is this the final destination ? */ + if ( Sua_Out_ConnId == 0 ) + { + // store primitive in a list(is retrieve via sua_receive_msg) + rec_msg_pool.push_back(temp); + + /* call the application/user callBack function */ + sua.local_sua.instance[local_sua_id].SUA_APLCallBack.ulp_ConnDataIndNotif + ( local_sua_id, + sua_ConnId, + temp.userdata.length() + ); + } + else + { + /* No, Message has not arrived at its final destination -> */ + /* route it to the next SUA node via an SCTP association nr x */ + /* get association id from SCOC TCB */ + + tcb_out_ptr = tcb_pool.get_tcb(Sua_Out_ConnId); + + msg.sua_prim.source_ref = tcb_out_ptr->Source_LR; + msg.sua_prim.dest_ref = tcb_out_ptr->Dest_LR; + + error = msg.sua_encode(); + + /* copy data into buffer, then finally... */ + signed int sctp_loadshare = SCTP_USE_PRIMARY; + short sctp_stream_id = 0; + int sctp_delivery_type = 0 ,datalen , result = 0; + char* databuf = new char[msg.sua_msg.length()]; + + msg.sua_msg.copy(databuf, msg.sua_msg.length()); + + datalen = msg.sua_msg.length(); + + // send data to SCTP + result = sua_send_Message( tcb_out_ptr->sctp_Association_id, + sctp_stream_id, + sctp_delivery_type, + sctp_loadshare, + databuf, + datalen + ); + + delete databuf; + } + + return(0); + } /***********************************************************************/ @@ -1450,16 +1659,19 @@ short process_CORELRQ_msg ( unsigned int sua_assoc_id, unsigned int release_cause = 0; unsigned int routing_Contex = 0; sua_save_str temp; + unsigned int Sua_Out_ConnId; + tcb_Sua_TCB_str *tcb_out_ptr; + Sua_syntax_error_struct error; temp.primitive = N_RELEASE_REQ; temp.user_ref = sua_ConnId; - routing_Contex = msg.sua_prim.rout_con; + routing_Contex = msg.sua_prim.rout_con; temp.QOS.return_msg_on_error = (msg.sua_prim.prot_class.return_option == TRUE); temp.QOS.sequence_number = 0; temp.QOS.importance = msg.sua_prim.importance; - + // retrieve the clg(=source) address (=remote sua address) - + // retrieve the called(=destination) address(=should be our own local addr) tcb_ptr->state = scoc_disconnect; @@ -1474,99 +1686,141 @@ short process_CORELRQ_msg ( unsigned int sua_assoc_id, temp.userdata = msg.sua_prim.data_string; else cout << "sua_co.c: no sua user data in CODATA msg \n"; + + + /* Look if this is the end or intermediate node */ + Sua_Out_ConnId = tcb_ptr->scoc_tcb_id; - // store primitive in a list(is retrieve via sua_receive_msg) - rec_msg_pool.push_back(temp); - - // send a CORELCONF back to the remote node - Sua_syntax_error_struct error; - int datalen; - unsigned int assoc_id; - short stream_id = 0; - int delivery_type, result; - - // init the message - msg.sua_init(); - - // fill in the main sua header - msg.sua_prim.hdr_msg_class = sua_co; - msg.sua_prim.hdr_msg_type.co = co_relco; - - msg.sua_prim.rout_con_pres = TRUE; - msg.sua_prim.rout_con = routing_Contex; - msg.sua_prim.importance_pres = TRUE; - msg.sua_prim.importance = 7; - - // QOS choice - delivery_type = SCTP_UNORDERED_DELIVERY; - - // fill in the connection-oriented specific data of the msg - msg.sua_prim.source_ref_pres = TRUE; - msg.sua_prim.source_ref = tcb_ptr->Source_LR ; - msg.sua_prim.dest_ref_pres = TRUE; - msg.sua_prim.dest_ref = tcb_ptr->Dest_LR ; - msg.sua_prim.SCCP_cause_pres = FALSE; - - // fill in the user data - msg.sua_prim.data_pres = FALSE; - - // encode the SUA Release complete message - error = msg.sua_encode(); - //string_size = msg.sua_msg.size(); - - assoc_id = tcb_ptr->sctp_Association_id; - local_sua_id = Assoc_sua.instance[sua_assoc_id].local_sua_id; - + /* Is this the final destination ? */ + if ( Sua_Out_ConnId == 0 ) + { + // store primitive in a list(is retrieve via sua_receive_msg) + rec_msg_pool.push_back(temp); + + // send a CORELCONF back to the remote node + Sua_syntax_error_struct error; + int datalen; + unsigned int assoc_id; + short stream_id = 0; + int delivery_type, result; + + // init the message + msg.sua_init(); + + // fill in the main sua header + msg.sua_prim.hdr_msg_class = sua_co; + msg.sua_prim.hdr_msg_type.co = co_relco; + + msg.sua_prim.rout_con_pres = TRUE; + msg.sua_prim.rout_con = routing_Contex; + msg.sua_prim.importance_pres = TRUE; + msg.sua_prim.importance = 7; + + // QOS choice + delivery_type = SCTP_UNORDERED_DELIVERY; + + // fill in the connection-oriented specific data of the msg + msg.sua_prim.source_ref_pres = TRUE; + msg.sua_prim.source_ref = tcb_ptr->Source_LR ; + msg.sua_prim.dest_ref_pres = TRUE; + msg.sua_prim.dest_ref = tcb_ptr->Dest_LR ; + msg.sua_prim.SCCP_cause_pres = FALSE; + + // fill in the user data + msg.sua_prim.data_pres = FALSE; + + // encode the SUA Release complete message + error = msg.sua_encode(); + //string_size = msg.sua_msg.size(); + + assoc_id = tcb_ptr->sctp_Association_id; + local_sua_id = sua.AssocDB.instance[sua_assoc_id].local_sua_id; + #ifdef DEBUG - cout << "routed to SCTP assoc " << assoc_id << "\n"; + cout << "routed to SCTP assoc " << assoc_id << "\n"; #endif - - tcb_ptr->state = scoc_idle; - - // send data to SCTP - char* databuf = new char[msg.sua_msg.length()]; - msg.sua_msg.copy(databuf, msg.sua_msg.length()); - datalen = msg.sua_msg.length(); - + + tcb_ptr->state = scoc_idle; + + // send data to SCTP + char* databuf = new char[msg.sua_msg.length()]; + msg.sua_msg.copy(databuf, msg.sua_msg.length()); + datalen = msg.sua_msg.length(); + #ifdef DEBUG - // display byte array - display_byte_array(databuf , msg.sua_msg.length()); + // display byte array + display_byte_array(databuf , msg.sua_msg.length()); #endif - - char logstring[100]; - sprintf(logstring, "SUA encoded message, ready for being send to SCTP assoc %d", assoc_id); - event_log("sua_co.c",logstring); - log_byte_array("sua_co.c", databuf,msg.sua_msg.length()); - - result = sctp_send ( assoc_id, - stream_id, - (unsigned char *) databuf, - datalen, - SUA_PPI, - SCTP_USE_PRIMARY, - SCTP_NO_CONTEXT, - SCTP_INFINITE_LIFETIME, - delivery_type, - SCTP_BUNDLING_DISABLED - ); - - delete databuf; - - // release the TCB of this connection - tcb_pool.release_TCB(sua_ConnId); - + + char logstring[100]; + sprintf(logstring, "SUA encoded message, ready for being send to SCTP assoc %d", assoc_id); + event_log("sua_co.c",logstring); + log_byte_array("sua_co.c", databuf,msg.sua_msg.length()); + + result = sctp_send ( assoc_id, + stream_id, + (unsigned char *) databuf, + datalen, + SUA_PPI, + SCTP_USE_PRIMARY, + SCTP_NO_CONTEXT, + SCTP_INFINITE_LIFETIME, + delivery_type, + SCTP_BUNDLING_DISABLED + ); + + delete databuf; + + // release the TCB of this connection + tcb_pool.release_TCB(sua_ConnId); + #ifdef DEBUG - cout << "local_sua_id = " << local_sua_id << "\n"; + cout << "local_sua_id = " << local_sua_id << "\n"; #endif - - /* call the application/user callBack function */ - local_sua.instance[local_sua_id].SUA_APLCallBack.ulp_DisConnIndNotif - ( local_sua_id, - sua_ConnId, - release_cause, - temp.userdata.length() - ); - + + /* call the application/user callBack function */ + sua.local_sua.instance[local_sua_id].SUA_APLCallBack.ulp_DisConnIndNotif + ( local_sua_id, + sua_ConnId, + release_cause, + temp.userdata.length() + ); + } + else + { + /* No, Message has not arrived at its final destination -> */ + /* route it to the next SUA node via an SCTP association nr x */ + /* get association id from SCOC TCB */ + + tcb_out_ptr = tcb_pool.get_tcb(Sua_Out_ConnId); + + msg.sua_prim.source_ref = tcb_out_ptr->Source_LR; + msg.sua_prim.dest_ref = tcb_out_ptr->Dest_LR; + + error = msg.sua_encode(); + + /* copy data into buffer, then finally... */ + signed int sctp_loadshare = SCTP_USE_PRIMARY; + short sctp_stream_id = 0; + int sctp_delivery_type = 0 ,datalen , result = 0; + char* databuf = new char[msg.sua_msg.length()]; + + msg.sua_msg.copy(databuf, msg.sua_msg.length()); + + datalen = msg.sua_msg.length(); + + // send data to SCTP + result = sua_send_Message( tcb_out_ptr->sctp_Association_id, + sctp_stream_id, + sctp_delivery_type, + sctp_loadshare, + databuf, + datalen + ); + + delete databuf; + } + return(0); } @@ -1583,18 +1837,21 @@ short process_CORELCO_msg ( unsigned int sua_assoc_id, unsigned int local_sua_id = 0; unsigned int release_cause = 0; sua_save_str temp; + unsigned int Sua_Out_ConnId; + tcb_Sua_TCB_str *tcb_out_ptr; + Sua_syntax_error_struct error; temp.primitive = N_RELEASE_CONF; temp.user_ref = sua_ConnId; - + temp.QOS.return_msg_on_error = (msg.sua_prim.prot_class.return_option == TRUE); temp.QOS.sequence_number = 0; temp.QOS.importance = msg.sua_prim.importance; - + // retrieve the clg(=source) address (=remote sua address) - + // retrieve the called(=destination) address(=should be our own local addr) - + tcb_ptr->state = scoc_idle; #ifdef DEBUG @@ -1604,21 +1861,62 @@ short process_CORELCO_msg ( unsigned int sua_assoc_id, cout << "TCB state = " << tcb_ptr->state << "\n"; #endif - local_sua_id = Assoc_sua.instance[sua_assoc_id].local_sua_id; + local_sua_id = sua.AssocDB.instance[sua_assoc_id].local_sua_id; - // store primitive in a list(is retrieve via sua_receive_msg) - rec_msg_pool.push_back(temp); + /* Look if this is the end or intermediate node */ + Sua_Out_ConnId = tcb_ptr->scoc_tcb_id; - // release the TCB of this connection - tcb_pool.release_TCB(sua_ConnId); - - /* call the application/user callBack function */ - local_sua.instance[local_sua_id].SUA_APLCallBack.ulp_DisConnIndNotif - ( local_sua_id, - sua_ConnId, - release_cause, - temp.userdata.length() - ); + /* Is this the final destination ? */ + if ( Sua_Out_ConnId == 0 ) + { + // store primitive in a list(is retrieve via sua_receive_msg) + rec_msg_pool.push_back(temp); + + // release the TCB of this connection + tcb_pool.release_TCB(sua_ConnId); + + /* call the application/user callBack function */ + sua.local_sua.instance[local_sua_id].SUA_APLCallBack.ulp_DisConnIndNotif + ( local_sua_id, + sua_ConnId, + release_cause, + temp.userdata.length() + ); + } + else + { + /* No, Message has not arrived at its final destination -> */ + /* route it to the next SUA node via an SCTP association nr x */ + /* get association id from SCOC TCB */ + + tcb_out_ptr = tcb_pool.get_tcb(Sua_Out_ConnId); + + msg.sua_prim.source_ref = tcb_out_ptr->Source_LR; + msg.sua_prim.dest_ref = tcb_out_ptr->Dest_LR; + + error = msg.sua_encode(); + + /* copy data into buffer, then finally... */ + signed int sctp_loadshare = SCTP_USE_PRIMARY; + short sctp_stream_id = 0; + int sctp_delivery_type = 0 ,datalen , result = 0; + char* databuf = new char[msg.sua_msg.length()]; + + msg.sua_msg.copy(databuf, msg.sua_msg.length()); + + datalen = msg.sua_msg.length(); + + // send data to SCTP + result = sua_send_Message( tcb_out_ptr->sctp_Association_id, + sctp_stream_id, + sctp_delivery_type, + sctp_loadshare, + databuf, + datalen + ); + + delete databuf; + } return(0); } @@ -1636,7 +1934,10 @@ short process_COREF_msg ( unsigned int sua_assoc_id, unsigned int local_sua_id = 0; unsigned int release_cause = 0; sua_save_str temp; - + unsigned int Sua_Out_ConnId; + tcb_Sua_TCB_str *tcb_out_ptr; + Sua_syntax_error_struct error; + temp.primitive = N_CONNECT_REFUSED; temp.user_ref = sua_ConnId; @@ -1677,28 +1978,69 @@ short process_COREF_msg ( unsigned int sua_assoc_id, if (msg.sua_prim.data_pres == TRUE) temp.userdata = msg.sua_prim.data_string; - else - cout << "sua_co.c: no sua user data in CODATA msg \n"; - // store primitive in a list(is retrieve via sua_receive_msg) - rec_msg_pool.push_back(temp); - - // release the TCB of this connection - tcb_pool.release_TCB(sua_ConnId); + /* Look if this is the end or intermediate node */ + Sua_Out_ConnId = tcb_ptr->scoc_tcb_id; + + /* Is this the final destination ? */ + if ( Sua_Out_ConnId == 0 ) + { + // store primitive in a list(is retrieve via sua_receive_msg) + rec_msg_pool.push_back(temp); + + // release the TCB of this connection + tcb_pool.release_TCB(sua_ConnId); + #ifdef DEBUG - cout << "local_sua_id = " << local_sua_id << "\n"; + cout << "local_sua_id = " << local_sua_id << "\n"; #endif + + /* call the application/user callBack function */ + sua.local_sua.instance[local_sua_id].SUA_APLCallBack.ulp_DisConnIndNotif + ( local_sua_id, + sua_ConnId, + release_cause, + temp.userdata.length() + ); - /* call the application/user callBack function */ - local_sua.instance[local_sua_id].SUA_APLCallBack.ulp_DisConnIndNotif - ( local_sua_id, - sua_ConnId, - release_cause, - temp.userdata.length() - ); + } + else + { + /* No, Message has not arrived at its final destination -> */ + /* route it to the next SUA node via an SCTP association nr x */ + /* get association id from SCOC TCB */ + + tcb_out_ptr = tcb_pool.get_tcb(Sua_Out_ConnId); + + msg.sua_prim.source_ref = tcb_out_ptr->Source_LR; + msg.sua_prim.dest_ref = tcb_out_ptr->Dest_LR; + + error = msg.sua_encode(); + + /* copy data into buffer, then finally... */ + signed int sctp_loadshare = SCTP_USE_PRIMARY; + short sctp_stream_id = 0; + int sctp_delivery_type = 0 ,datalen , result = 0; + char* databuf = new char[msg.sua_msg.length()]; + + msg.sua_msg.copy(databuf, msg.sua_msg.length()); + + datalen = msg.sua_msg.length(); + + // send data to SCTP + result = sua_send_Message( tcb_out_ptr->sctp_Association_id, + sctp_stream_id, + sctp_delivery_type, + sctp_loadshare, + databuf, + datalen + ); + + delete databuf; + } - return(0); + return(0); } // end of module sua_co.c diff --git a/sualibrary/sua/sua_database.cpp b/sualibrary/sua/sua_database.cpp index ce953e1..8604ee5 100644 --- a/sualibrary/sua/sua_database.cpp +++ b/sualibrary/sua/sua_database.cpp @@ -15,7 +15,7 @@ * * ***************************************************************************/ /* - * $Id: sua_database.cpp,v 1.1.1.1 2002/02/04 14:30:41 p82609 Exp $ + * $Id: sua_database.cpp,v 1.2 2002/10/30 16:04:09 p82609 Exp $ * * SUA implementation according to SUA draft issue 6. * @@ -155,58 +155,58 @@ void db_Sua_AddressObject::read_addr_param(string address_str){ #ifdef DEBUG cout << "address = " << address_str << " len = " <= 2) - { // IPv6 address parameters - addrs[nr_of_addrs].sa.sa_family = AF_INET6; - addrs[nr_of_addrs].sin6.sin6_port = SUA_PORT; - result = inet_pton(AF_INET6, tokstr,&addrs[nr_of_addrs].sin6.sin6_addr); - if (result != 1) - cout << "IPvx address conversion returned "<< result << " \n"; + } + if (count_colon >= 2) + { // IPv6 address parameters + addrs[nr_of_addrs].sa.sa_family = AF_INET6; + addrs[nr_of_addrs].sin6.sin6_port = SUA_PORT; + result = inet_pton(AF_INET6, tokstr,&addrs[nr_of_addrs].sin6.sin6_addr); + if (result != 1) + cout << "IPvx address conversion returned "<< result << " \n"; #ifdef DEBUG - cout << "IPv6 = " << &addrs[nr_of_addrs].sin6.sin6_addr << " \n"; + cout << "IPv6 = " << &addrs[nr_of_addrs].sin6.sin6_addr << " \n"; #endif - } - - nr_of_addrs++; - b = i + 1; - count_punct = 0; - count_colon = 0; - - } + } + + nr_of_addrs++; + b = i + 1; + count_punct = 0; + count_colon = 0; + + } - i++; - - } + i++; + + } #ifdef DEBUG cout << "number of address = " << nr_of_addrs << " \n"; #endif diff --git a/sualibrary/sua/sua_database.h b/sualibrary/sua/sua_database.h index 7fce372..31d1119 100644 --- a/sualibrary/sua/sua_database.h +++ b/sualibrary/sua/sua_database.h @@ -15,7 +15,7 @@ * * ***************************************************************************/ /* - * $Id: sua_database.h,v 1.4 2002/03/01 12:57:38 p82609 Exp $ + * $Id: sua_database.h,v 1.8 2002/11/12 11:02:49 p82609 Exp $ * * SUA implementation according to SUA draft issue 8. * @@ -172,6 +172,60 @@ class db_Sua_AddressObject { void read_port_num(string port); }; ///:~ +/***********************************************************************/ +/* Sua_GlobalTitleObject */ +/***********************************************************************/ +class db_Sua_GlobalTitle { + public: + short Translation_Type; + short Numbering_Plan; + short Nature_of_Address; + /*short nr_of_digits;*/ + string digits; +}; ///:~ + +/***********************************************************************/ +/* Sua_NameObject */ +/***********************************************************************/ +class db_Sua_NameObject { + public: + unsigned int SUA_assoc_id; + unsigned int sctp_assoc_id; + db_Sua_GlobalTitle GT; + string hostname; + public: + void initialize(); + +}; ///:~ + +/***********************************************************************/ +/* Sua_NameList */ +/***********************************************************************/ +class db_Sua_NameList{ + public: + int num_of_instance; + db_Sua_NameObject instance[db_MAX_REMOTE_SUA]; + public: + void initialize(); + string read_host_name( unsigned int sua_assoc_id, + string name + ); + void read_Global_Title( unsigned int sua_assoc_id, + string name + ); + signed int resolve_host_name( hostname_str& dest_name, + pointcode_str& dest_pc + ); + signed int perform_GTT( global_title_str& cld_in, + global_title_str& clg_in, + global_title_str& cld_out, + global_title_str& clg_out, + pointcode_str& dest_pc + ); + void increase_instance(); +}; ///:~ + + /***********************************************************************/ /* Sua_ApplicationServerProcessObject (ASP) */ /***********************************************************************/ @@ -285,6 +339,15 @@ class db_Sua_AssociationList{ void read_Dest_pointcode(string address); void read_Source_port(string port); void read_Dest_port(string port); + void read_Source_GT( db_Sua_NameList &NameDB, + string address + ); + void read_Dest_GT( db_Sua_NameList &NameDB, + string address + ); + string read_host_name( db_Sua_NameList &NameDB, + string address + ); void read_stream_number(string stream_num); short register_instance(SCTP_ulp_Callbacks APLCallbackFunctions, Sua_ULP_CallBacks SUACallbackFunctions, @@ -295,8 +358,6 @@ class db_Sua_AssociationList{ unsigned int &Local_sua_id, unsigned int &Remote_sua_id ); - unsigned int Find_local_sua( sccp_addr_str& local_address - ); short associate_instance( db_Sua_LocalList& local_sua, db_Sua_RemoteList& remote_sua ); @@ -317,72 +378,68 @@ class db_Sua_AssociationList{ ); short Terminate_remote_assoc_instance(); short shutdown(); - signed int resolve_host_name( hostname_str& dest_name, - pointcode_str& dest_pc - ); - signed int route_msg( sccp_addr_str& cld, - sccp_addr_str& clg, - int& sua_assoc_id - ); signed int route_on_IPpc ( ipvxunion& dest_pc, - ipvxunion& org_pc, - int& sua_assoc_id - ); + ipvxunion& org_pc, + int& sua_assoc_id + ); signed int route_on_SS7pc ( SS7union& dest_pc, - SS7union& org_pc, - int& sua_assoc_id - ); - signed int route_on_GTname ( hostname_str& dest_name, - hostname_str& org_name, - int& sua_assoc_id, - pointcode_str& dest_pc, - pointcode_str& org_pc - ); + SS7union& org_pc, + int& sua_assoc_id + ); void increase_instance(); bool activate( unsigned int sua_id, short mode - ); + ); void deactivate( unsigned int sua_id, short mode - ); + ); void down( unsigned int sua_id, short mode - ); + ); void up( unsigned int sua_id, short mode - ); + ); }; ///:~ -/***********************************************************************/ -/* Sua_NameObject */ -/***********************************************************************/ -class db_Sua_NameObject { - public: - unsigned int SUA_assoc_id; - public: - void initialize(); - -}; ///:~ /***********************************************************************/ -/* Sua_NameList */ +/* Sua_DatabaseList */ /***********************************************************************/ -class db_Sua_NameList{ +class db_Sua_DatabaseList{ public: - int num_of_instance; - db_Sua_NameObject instance[db_MAX_REMOTE_SUA]; - public: - void initialize(); - string read_host_name(string name); - string read_Global_Title(string name); - unsigned int perform_GTT( sccp_addr_str& cld_in, - sccp_addr_str& clg_in, - sccp_addr_str& cld_out, - sccp_addr_str& clg_out + db_Sua_LocalList local_sua; + db_Sua_RemoteList remote_sua; + db_Sua_AssociationList AssocDB; + db_Sua_NameList NameDB; + db_Sua_ASList ApplicServ; + public: + unsigned int Find_local_sua( sccp_addr_str& local_address + ); + unsigned int Dynamic_Associate( sccp_addr_str& cld, + sccp_addr_str& clg, + unsigned short nr_of_dest_addr, + unsigned short nr_of_input_streams, + unsigned short nr_of_output_streams + ); + signed int route_on_GTname ( hostname_str& dest_name, + hostname_str& org_name, + int& sua_assoc_id, + pointcode_str& dest_pc, + pointcode_str& org_pc + ); + signed int route_on_GTT( global_title_str& dest_GT, + global_title_str& org_GT, + int& sua_assoc_id, + pointcode_str& dest_pc, + pointcode_str& org_pc ); - void increase_instance(); + signed int route_msg( sccp_addr_str& cld, + sccp_addr_str& clg, + int& sua_assoc_id + ); }; ///:~ + #endif // SUA_DATABASE_H //end of module sua_database.h diff --git a/sualibrary/sua/sua_dataname.cpp b/sualibrary/sua/sua_dataname.cpp index f71a1ee..2b9d401 100644 --- a/sualibrary/sua/sua_dataname.cpp +++ b/sualibrary/sua/sua_dataname.cpp @@ -15,7 +15,7 @@ * * ***************************************************************************/ /* - * $Id: sua_dataname.cpp,v 1.2 2002/03/01 12:57:38 p82609 Exp $ + * $Id: sua_dataname.cpp,v 1.6 2002/11/12 11:04:12 p82609 Exp $ * * SUA implementation according to SUA draft issue 6. * @@ -53,7 +53,10 @@ * - initialise Name * SUA Name List: * - initialise Name List - * - read hostname + * - read hostname + * - read global title + * - resolve hostname + * - perform Global Title Translation */ #include "sctp.h" @@ -62,6 +65,7 @@ #include "sua_database.h" #include "sua_asp_mgnt.h" #include "sua_logging.h" +#include "sua_adapt.h" #include #include @@ -84,7 +88,15 @@ using namespace std; void db_Sua_NameObject::initialize(){ // initialise to point to a invalid SUA association - SUA_assoc_id = 0; + SUA_assoc_id = 0; + sctp_assoc_id = 0; + GT.Translation_Type = 0; + GT.Numbering_Plan = 0; + GT.Nature_of_Address = 0; + /* initialise to empty string */ + GT.digits=""; + hostname = ""; + } @@ -107,7 +119,9 @@ void db_Sua_NameList::initialize(){ /***********************************************************************/ /* Sua_NameList::read_host_name */ /***********************************************************************/ -string db_Sua_NameList::read_host_name(string name){ +string db_Sua_NameList::read_host_name( unsigned int sua_assoc_id, + string name + ){ char *hostname; const char *ip_addr_ptr; @@ -129,7 +143,7 @@ string db_Sua_NameList::read_host_name(string name){ #ifdef DEBUG cout << "Hostname " << hptr->h_name << " has the following IP address(es)\n"; #endif - + pptr = hptr->h_addr_list; for ( ; *pptr != NULL;pptr++) { @@ -143,30 +157,152 @@ string db_Sua_NameList::read_host_name(string name){ cout << ip_addr_ptr << "\n"; #endif } - + #ifdef DEBUG cout << "output IP list = " << addr_str << "\n"; #endif - - string name_str; - int last= name.size(); - unsigned int current = name.rfind('.'); - while(current != string::npos){ - name_str = name_str + name.substr(current+1,(last-current)) + "."; - last= current - 1; - current = name.rfind('.', last); - } - name_str = name_str + name.substr(0,last+1); - -#ifdef DEBUG - cout << "Ready for storing SUA dest hostname = " << name_str << " in NameDB\n"; -#endif - - + + instance[num_of_instance].SUA_assoc_id = sua_assoc_id; + + instance[num_of_instance].hostname = name; + return(addr_str); - + } +/***********************************************************************/ +/* Sua_NameList::read_Global_Title */ +/***********************************************************************/ +void db_Sua_NameList::read_Global_Title( unsigned int sua_assoc_id, + string gt + ) +{ + string GT_TT_str, GT_NP_str, GT_NA_str, GT_Digits_str; + unsigned int first = 0, last = 0; + unsigned int current = gt.find('-', first); + + first = 1; + last = current - 1; + GT_TT_str = gt.substr( first, last); + + first = current + 1; + current = gt.find('-', first); + last = current - 1; + GT_NP_str = gt.substr( first , last); + + first = current + 1; + current = gt.find('-', first); + last = current - 1; + GT_NA_str = gt.substr( first , last); + + first = current + 1; + last = gt.size(); + GT_Digits_str = gt.substr( first , last); + + instance[num_of_instance].SUA_assoc_id = sua_assoc_id; + + instance[num_of_instance].GT.Translation_Type = atoi(GT_TT_str.c_str()); + instance[num_of_instance].GT.Numbering_Plan = atoi(GT_NP_str.c_str()); + instance[num_of_instance].GT.Nature_of_Address = atoi(GT_NA_str.c_str()); + instance[num_of_instance].GT.digits = GT_Digits_str; + +} + +/***********************************************************************/ +/* db_Sua_NameList::resolve_host_name */ +/***********************************************************************/ +signed int db_Sua_NameList::resolve_host_name ( hostname_str& dest_name, + pointcode_str& dest_pc + ) +{ + struct hostent *hptr; + char **pptr; + char str[INET6_ADDRSTRLEN]; + char *dest_carr; + + /* resolving can be done via: */ + /* - local global Titel database */ + /* - resolve hostname via DNS(simplest for single hop translations) */ + dest_carr = dest_name; + + if ((hptr = gethostbyname( dest_carr )) == NULL) + { + cout << "Hostname " << dest_name << " not known in DNS.\n"; + return(-1); + } + +#ifdef DEBUG + cout << "Hostname " << dest_name << " resolved to dest IP address(es)\n"; + cout << "IP address length = "<< hptr->h_length << "\n"; +#endif + + /* initialise the length field of the structure: */ + /* length field is NOT always present in every Unix like operating system */ + dest_pc.ipvx.ch[0] = 0; + + pptr = hptr->h_addr_list; + for ( ; (*pptr != NULL) ;pptr++) + { + inet_ntop(hptr->h_addrtype, *pptr, str,sizeof(str)); +#ifdef DEBUG + cout << str << "\n"; +#endif + /* got a IP address */ + dest_pc.ipvx.sa.sa_family = hptr->h_addrtype; + if (dest_pc.ipvx.sa.sa_family == AF_INET) + inet_pton( AF_INET, + str, + &dest_pc.ipvx.sin.sin_addr + ); + else if (dest_pc.ipvx.sa.sa_family == AF_INET6) + inet_pton( AF_INET6, + str, + &dest_pc.ipvx.sin6.sin6_addr + ); + else + { + cout << "ERROR resolve_host_name: Unknown IP addresstype\n"; + return(-2); + } + } + return(0); +}; + +/***********************************************************************/ +/* db_Sua_NameList::resolve_GT */ +/***********************************************************************/ +signed int db_Sua_NameList::perform_GTT ( global_title_str& cld_in, + global_title_str& clg_in, + global_title_str& cld_out, + global_title_str& clg_out, + pointcode_str& dest_pc + ) +{ + boolean search_gt = true, gt_entry_found = false; + int i, found_gt_entry; + + /* resolving can be done via: */ + /* - local global Titel database */ + i= 0; + while (search_gt){ + gt_entry_found = ((instance[i].GT.Translation_Type == cld_in.Translation_Type) && + (instance[i].GT.Numbering_Plan == cld_in.Numbering_Plan) && + (instance[i].GT.Nature_of_Address == cld_in.Nature_of_Address) && + (instance[i].GT.digits == cld_in.digits)); + + found_gt_entry = i; + /* next entry of name table */ + i++; + } + + if (gt_entry_found) { + /* get the association number from gt database */ + dest_pc = get_destpc_addr(instance[found_gt_entry].SUA_assoc_id); + return(0); + } + else + return(-1); +}; // end of module sua_dataname.c diff --git a/sualibrary/sua/sua_datassoc.cpp b/sualibrary/sua/sua_datassoc.cpp index dd29625..bec142d 100644 --- a/sualibrary/sua/sua_datassoc.cpp +++ b/sualibrary/sua/sua_datassoc.cpp @@ -15,7 +15,7 @@ * * ***************************************************************************/ /* - * $Id: sua_datassoc.cpp,v 1.6 2002/03/15 12:53:53 p82609 Exp $ + * $Id: sua_datassoc.cpp,v 1.11 2002/11/12 11:04:12 p82609 Exp $ * * SUA implementation according to SUA draft issue 6. * @@ -241,64 +241,47 @@ void db_Sua_AssociationList:: read_stream_number(string stream_num){ } /***********************************************************************/ -/* db_Sua_AssociationList::resolve_host_name */ +/* Sua_AssociationList::read_Source_GT */ /***********************************************************************/ -signed int db_Sua_AssociationList::resolve_host_name ( hostname_str& dest_name, - pointcode_str& dest_pc - ) +void db_Sua_AssociationList::read_Source_GT( db_Sua_NameList &NameDB, + string address + ) { - struct hostent *hptr; - char **pptr; - char str[INET6_ADDRSTRLEN]; - char *dest_carr; + ; +} - /* resolving can be done via: */ - /* - local global Titel database */ - /* - resolve hostname via DNS(simplest for single hop translations) */ - dest_carr = dest_name; +/***********************************************************************/ +/* Sua_AssociationList::read_Dest_GT */ +/***********************************************************************/ +void db_Sua_AssociationList::read_Dest_GT( db_Sua_NameList &NameDB, + string address + ) +{ + unsigned int sua_assoc_id = num_of_instance; + + NameDB.read_Global_Title( sua_assoc_id, + address + ); + + NameDB.num_of_instance++; + +} - if ((hptr = gethostbyname( dest_carr )) == NULL) - { - cout << "Hostname " << dest_name << " not known in DNS.\n"; - return(-1); - } - -#ifdef DEBUG - cout << "Hostname " << dest_name << " resolved to dest IP address(es)\n"; - cout << "IP address length = "<< hptr->h_length << "\n"; -#endif - - /* initialise the length field of the structure: */ - /* length field is NOT always present in every Unix like operating system */ - dest_pc.ipvx.ch[0] = 0; - - pptr = hptr->h_addr_list; - for ( ; (*pptr != NULL) ;pptr++) - { - inet_ntop(hptr->h_addrtype, *pptr, str,sizeof(str)); -#ifdef DEBUG - cout << str << "\n"; -#endif - /* got a IP address */ - dest_pc.ipvx.sa.sa_family = hptr->h_addrtype; - if (dest_pc.ipvx.sa.sa_family == AF_INET) - inet_pton( AF_INET, - str, - &dest_pc.ipvx.sin.sin_addr - ); - else if (dest_pc.ipvx.sa.sa_family == AF_INET6) - inet_pton( AF_INET6, - str, - &dest_pc.ipvx.sin6.sin6_addr - ); - else - { - cout << "ERROR resolve_host_name: Unknown IP addresstype\n"; - return(-2); - } - } - return(0); -}; +/***********************************************************************/ +/* Sua_AssociationList::read_hostname */ +/***********************************************************************/ +string db_Sua_AssociationList::read_host_name( db_Sua_NameList &NameDB, + string address ) +{ + unsigned int sua_assoc_id = num_of_instance; + string host_ip_addr; + + host_ip_addr = NameDB.read_host_name( sua_assoc_id, + address + ); + + return(host_ip_addr); +} /***********************************************************************/ /* Sua_AssociationList::register_instance */ @@ -446,135 +429,6 @@ Find_association( unsigned int sctp_assoc_id, return(sua_assoc_id); }; -/***********************************************************************/ -/* Sua_AssociationList::Find_local_sua */ -/***********************************************************************/ -unsigned int db_Sua_AssociationList:: -Find_local_sua( sccp_addr_str& local_address - ) -{ - pointcode_str dest_pc; - short i = 1, j = 0, count, addr_start, addr_stop; - unsigned int Local_sua_id = 0; - bool result = FALSE; - - while ((i < db_MAX_REMOTE_SUA) && !(result) && (instance[i].Source.nr_of_addrs != 0)) - { - j = 0; - while ((j < instance[i].Source.nr_of_addrs) && !(result)) - { - /*result = ((instance[i].Source.addrs[j].sin.sin_addr.s_addr == local_address.pc.ipvx.sin.sin_addr.s_addr) || - (instance[i].Source.addrs[j].sin6.sin6_addr.s6_addr == local_address.pc.ipvx.sin6.sin6_addr.s6_addr)); -*/ - if (local_address.address_fields_present.pc == ipvx_pc_present) - { - result = (local_address.pc.ipvx.sa.sa_family == instance[i].Source.addrs[j].sa.sa_family); - if (local_address.pc.ipvx.sa.sa_family == AF_INET) - { - addr_start = 4; - addr_stop = addr_start + 4; - } - else if (local_address.pc.ipvx.sa.sa_family == AF_INET6) - { - addr_start = 8; - addr_stop = addr_start + 16; - } - else - { - addr_start = 0; - addr_stop = 0; - result = false; - cout << "ERROR Find_local_sua: Unknown IPvx addresstype\n"; - } - /* compare the address family field */ - result = result && - (local_address.pc.ipvx.ch[1] == instance[i].Source.addrs[j].ch[1]); - - /* compare the ipv4/ipv6 address field */ - for (count = addr_start; count < addr_stop; count++) - { - result = result && - (local_address.pc.ipvx.ch[count] == instance[i].Source.addrs[j].ch[count]); - } - } - else if (local_address.address_fields_present.pc == ss7_pc_present) - { - result = (local_address.pc.ss7.ITU14.family == instance[i].Source.pc.ITU14.family); - if (((local_address.pc.ss7.ITU14.family == ITU14bit) || - (local_address.pc.ss7.ITU14.family == ITU24bit)) || - (local_address.pc.ss7.ITU14.family == ANSI24bit)) - { - /* compare the ITU 14/24bit or ANSI 24bit PC address field */ - result = result && - (local_address.pc.ss7.ITU14.pc == instance[i].Source.pc.ITU14.pc); - } - else - { - result = false; - cout << "ERROR Find_local_sua: Unknown SS7 pointcode addresstype\n"; - } - } - else if (local_address.address_fields_present.name_gt == hostname_present) - { - count = 0; - result = resolve_host_name ( local_address.name.HostName, - dest_pc - ); - - result = (dest_pc.ipvx.sa.sa_family == instance[i].Source.addrs[j].sa.sa_family); - - if (dest_pc.ipvx.sa.sa_family == AF_INET) - { - addr_start = 4; - addr_stop = addr_start + 4; - } - else if (dest_pc.ipvx.sa.sa_family == AF_INET6) - { - addr_start = 8; - addr_stop = addr_start + 16; - } - else - { - addr_start = 0; - addr_stop = 0; - result = false; - cout << "ERROR Find_local_sua: Unknown IPvx addresstype\n"; - } - /* compare the address family field : already done */ - /* compare the ipv4/ipv6 address field */ - short k=0; - for (count = addr_start; count < addr_stop; count++) - { - result = result && - (dest_pc.ipvx.ch[count] == instance[i].Source.addrs[j].ch[count]); - k++; - } - - } - else if (local_address.address_fields_present.name_gt == GT_present) - { - cout << "ERROR Find_local_sua: GT code not implemented yet\n"; - } - else - { - cout << "ERROR Find_local_sua: Unknown SUA addresstype\n"; - result = false; - } - - if (result) - { - Local_sua_id = instance[i].local_sua_id; -#ifdef DEBUG - cout << "Find_local_sua: local_sua_id = " << Local_sua_id << " , instance "<< i << "\n"; -#endif - } - j++; - } - i++; - } - - return(Local_sua_id); -}; /***********************************************************************/ /* Sua_AssociationList::passive_associate */ @@ -610,13 +464,13 @@ passive_associate( unsigned int assoc_id, num_of_instance++; assoc_instance_idx = num_of_instance; instance[assoc_instance_idx].Source = instance[assoc_instance_idx-1].Source; - + instance[assoc_instance_idx].nr_of_inbound_streams = nr_of_input_streams ; instance[assoc_instance_idx].nr_of_outbound_streams = nr_of_input_streams ; } remote_sua.increase_instance(); - + instance[assoc_instance_idx].SCTP_assoc_id = assoc_id; instance[assoc_instance_idx].remote_sua_id = remote_sua.num_of_instance; remote_sua.instance[remote_sua.num_of_instance].ssn.ssn = local_sua.instance[local_sua.num_of_instance].ssn.ssn; @@ -628,62 +482,62 @@ passive_associate( unsigned int assoc_id, char logstring[100]; sprintf(logstring, "Associate Remote SUA(& SCTP) instance nr %d with local SUA(& SCTP) instance nr %d", assoc_id, assoc_instance_idx ); event_log("sua_database.c",logstring); - - + + result = sctp_getAssocStatus( instance[assoc_instance_idx].SCTP_assoc_id, - &status - ); + &status + ); /* conversion and fill in the destination address */ instance[assoc_instance_idx].Dest.nr_of_addrs = nr_of_dest_addr; for(k=0; k < instance[assoc_instance_idx].Dest.nr_of_addrs ; k++) { result = sctp_getPathStatus( instance[assoc_instance_idx].SCTP_assoc_id, - k, - &path_x_status - ); - instance[assoc_instance_idx].Dest.address_string[k] = path_x_status.destinationAddress; - instance[assoc_instance_idx].Dest.addrs[k].sin.sin_port = status.destPort; - } + k, + &path_x_status + ); + instance[assoc_instance_idx].Dest.address_string[k] = path_x_status.destinationAddress; + instance[assoc_instance_idx].Dest.addrs[k].sin.sin_port = status.destPort; + } /* try to figure out ipv4 or v6 address family: get it from the source address */ k = 0; instance[assoc_instance_idx].Dest.addrs[0].sa.sa_family = AF_LOCAL; cont = true; while ((k < 24) && (cont)) { - if (instance[assoc_instance_idx].Dest.address_string[0][k] == '.') - { - cont = false; - instance[assoc_instance_idx].Dest.addrs[0].sa.sa_family = AF_INET; - } - if (instance[assoc_instance_idx].Dest.address_string[0][k] == ':') - { - cont = false; - instance[assoc_instance_idx].Dest.addrs[0].sa.sa_family = AF_INET6; - } - k++; - } - + if (instance[assoc_instance_idx].Dest.address_string[0][k] == '.') + { + cont = false; + instance[assoc_instance_idx].Dest.addrs[0].sa.sa_family = AF_INET; + } + if (instance[assoc_instance_idx].Dest.address_string[0][k] == ':') + { + cont = false; + instance[assoc_instance_idx].Dest.addrs[0].sa.sa_family = AF_INET6; + } + k++; + } + for(k=0; k < instance[assoc_instance_idx].Dest.nr_of_addrs ; k++) { - if (instance[assoc_instance_idx].Dest.addrs[k].sa.sa_family == AF_INET) - bla = inet_pton( instance[assoc_instance_idx].Dest.addrs[k].sa.sa_family, - (char *)instance[assoc_instance_idx].Dest.address_string[k], - &instance[assoc_instance_idx].Dest.addrs[k].sin.sin_addr - ); + if (instance[assoc_instance_idx].Dest.addrs[k].sa.sa_family == AF_INET) + bla = inet_pton( instance[assoc_instance_idx].Dest.addrs[k].sa.sa_family, + (char *)instance[assoc_instance_idx].Dest.address_string[k], + &instance[assoc_instance_idx].Dest.addrs[k].sin.sin_addr + ); else if (instance[assoc_instance_idx].Dest.addrs[k].sa.sa_family == AF_INET6) - bla = inet_pton( instance[assoc_instance_idx].Dest.addrs[k].sa.sa_family, - (char *)instance[assoc_instance_idx].Dest.address_string[k], - &instance[assoc_instance_idx].Dest.addrs[k].sin6.sin6_addr - ); + bla = inet_pton( instance[assoc_instance_idx].Dest.addrs[k].sa.sa_family, + (char *)instance[assoc_instance_idx].Dest.address_string[k], + &instance[assoc_instance_idx].Dest.addrs[k].sin6.sin6_addr + ); else - cout << "Unsupported address family in passive associate\n"; - + cout << "Unsupported address family in passive associate\n"; + } /* no msg queued, mark assoc down(from sua management viewpoint)*/ instance[assoc_instance_idx].asp.status = asp_down; - + return(assoc_instance_idx); } @@ -731,67 +585,67 @@ route_on_IPpc ( ipvxunion& dest_pc, { found_assoc = false; j = 0; - while ((j < instance[i].Dest.nr_of_addrs) && (!found_assoc)) - { - found_assoc = (dest_pc.sa.sa_family == instance[i].Dest.addrs[j].sa.sa_family); - if (dest_pc.sa.sa_family == AF_INET) - { - addr_start = 4; - addr_stop = addr_start + 4; - } - else if (dest_pc.sa.sa_family == AF_INET6) - { - addr_start = 8; - addr_stop = addr_start + 16; - } - else - { - addr_start = 0; - addr_stop = 0; - found_assoc = false; - cout << "ERROR route_on_IPpc: Unknown addresstype\n"; - } - /* compare the address family field */ - found_assoc = found_assoc && (dest_pc.ch[1] == instance[i].Dest.addrs[j].ch[1]); - - /* compare the ipv4/ipv6 address field */ - for (count = addr_start; count < addr_stop; count++) - { - found_assoc = found_assoc - && (dest_pc.ch[count] == instance[i].Dest.addrs[j].ch[count]); - } - j++; - } - + while ((j < instance[i].Dest.nr_of_addrs) && (!found_assoc)) + { + found_assoc = (dest_pc.sa.sa_family == instance[i].Dest.addrs[j].sa.sa_family); + if (dest_pc.sa.sa_family == AF_INET) + { + addr_start = 4; + addr_stop = addr_start + 4; + } + else if (dest_pc.sa.sa_family == AF_INET6) + { + addr_start = 8; + addr_stop = addr_start + 16; + } + else + { + addr_start = 0; + addr_stop = 0; + found_assoc = false; + cout << "ERROR route_on_IPpc: Unknown addresstype\n"; + } + /* compare the address family field */ + found_assoc = found_assoc && (dest_pc.ch[1] == instance[i].Dest.addrs[j].ch[1]); + + /* compare the ipv4/ipv6 address field */ + for (count = addr_start; count < addr_stop; count++) + { + found_assoc = found_assoc + && (dest_pc.ch[count] == instance[i].Dest.addrs[j].ch[count]); + } + j++; + } + if (found_assoc) - { - cont = false; - sctp_assoc_id = instance[i].SCTP_assoc_id; - sua_assoc_id = i; + { + cont = false; + sctp_assoc_id = instance[i].SCTP_assoc_id; + sua_assoc_id = i; #ifdef DEBUG - cout << "Found Sua association " << i << " with SCTP assoc " << sctp_assoc_id << "\n"; - - if (dest_pc.sa.sa_family == AF_INET) - { - cout << "CLD ip v4 = " << dest_pc.sin.sin_addr.s_addr << "\n"; - cout << "Remote IP = " << instance[i].Dest.addrs[0].sin.sin_addr.s_addr << "\n"; - } - else if (dest_pc.sa.sa_family == AF_INET6) - { - cout << "CLD ip v6 = " << dest_pc.sin6.sin6_addr.s6_addr << "\n"; - cout << "Remote IP = " << instance[i].Dest.addrs[0].sin6.sin6_addr.s6_addr << "\n"; - } - else - cout << "Unknown CLD IP address type format\n"; + cout << "Found Sua association " << i << " with SCTP assoc " << sctp_assoc_id << "\n"; + + if (dest_pc.sa.sa_family == AF_INET) + { + cout << "CLD ip v4 = " << dest_pc.sin.sin_addr.s_addr << "\n"; + cout << "Remote IP = " << instance[i].Dest.addrs[0].sin.sin_addr.s_addr << "\n"; + } + else if (dest_pc.sa.sa_family == AF_INET6) + { + cout << "CLD ip v6 = " << dest_pc.sin6.sin6_addr.s6_addr << "\n"; + cout << "Remote IP = " << instance[i].Dest.addrs[0].sin6.sin6_addr.s6_addr << "\n"; + } + else + cout << "Unknown CLD IP address type format\n"; #endif - } + } else - { - i++; - cont = (i <= num_of_instance); - } + { + i++; + cont = (i <= num_of_instance); + } } - + return(sctp_assoc_id); }; @@ -854,121 +708,6 @@ route_on_SS7pc ( SS7union& dest_pc, return(sctp_assoc_id); }; -/***********************************************************************/ -/* Sua_AssociationList::route_on_GTname */ -/***********************************************************************/ -signed int db_Sua_AssociationList:: -route_on_GTname ( hostname_str& dest_name, - hostname_str& org_name, - int& sua_assoc_id, - pointcode_str& dest_pc, - pointcode_str& org_pc - ) -{ - int result = 0; - unsigned int sctp_assoc_id = 0; - - sua_assoc_id = 0; - - /* resolving can be done via: */ - /* - local global Titel database */ - /* - resolve hostname via DNS(simplest for single hop translations) */ - result = resolve_host_name ( dest_name, - dest_pc - ); - - /*result = resolve_host_name ( org_name, - org_pc - ); */ - - sctp_assoc_id = route_on_IPpc( dest_pc.ipvx, - org_pc.ipvx, - sua_assoc_id - ); - - if (sctp_assoc_id != 0 ) - return(sctp_assoc_id); - - - return(sctp_assoc_id); -}; - -/***********************************************************************/ -/* Sua_AssociationList::route_msg */ -/***********************************************************************/ -signed int db_Sua_AssociationList:: -route_msg( sccp_addr_str& cld, - sccp_addr_str& clg, - int& sua_assoc_id - ){ - - unsigned int sctp_assoc_id = 0; - - sua_assoc_id = 0; - -#ifdef DEBUG - cout << "num_of_instance : "<< num_of_instance << "\n"; -#endif - - if ((cld.address_fields_present.pc == ipvx_pc_present) && - (cld.routing_ind == route_on_ssn)) - { - sctp_assoc_id = route_on_IPpc( cld.pc.ipvx, - clg.pc.ipvx, - sua_assoc_id - ); - } - else if ((cld.address_fields_present.name_gt == hostname_present) && - (cld.routing_ind == route_on_name_gt)) - { - sctp_assoc_id = route_on_GTname( cld.name.HostName, - clg.name.HostName, - sua_assoc_id, - cld.pc, - clg.pc - ); - } - else if ((cld.address_fields_present.name_gt == hostname_present) && - (cld.address_fields_present.pc == ipvx_pc_present) && - (cld.routing_ind == route_on_name_gt_next_office)) - { - sctp_assoc_id = route_on_IPpc( cld.pc.ipvx, - clg.pc.ipvx, - sua_assoc_id - ); - } - else if ((cld.address_fields_present.pc == ss7_pc_present) && - (cld.routing_ind == route_on_ssn)) - { - sctp_assoc_id = route_on_SS7pc( cld.pc.ss7, - clg.pc.ss7, - sua_assoc_id - ); - } - else - { - cout << "Unknown routing requested\n"; - } - -#ifdef SUA_MANAGEMENT - /* check if allowed to send msg over the association */ - if ((sua_assoc_id > 0) && - (sua_assoc_id <= num_of_instance) && - (instance[sua_assoc_id].asp.status != asp_active)) - { - sctp_assoc_id = (-sctp_assoc_id); - } -#endif - -#ifdef DEBUG - cout << "route msg towards remote SUA(& SCTP) association " << sctp_assoc_id << " \n"; -#endif - char logstring[100]; - sprintf(logstring, "Route msg towards Remote SUA(& SCTP) instance nr %d", sctp_assoc_id ); - event_log("sua_database.c",logstring); - - return(sctp_assoc_id); -}; /***********************************************************************/ /* Sua_AssociationList::increase_instance */ @@ -979,101 +718,6 @@ void db_Sua_AssociationList:: increase_instance(){ } -/***********************************************************************/ -/* Sua_AssociationList::Dynamic_Associate */ -/***********************************************************************/ -unsigned int db_Sua_AssociationList::Dynamic_Associate( - db_Sua_LocalList& local_sua, - db_Sua_RemoteList& remote_sua, - sccp_addr_str& cld, - sccp_addr_str& clg, - unsigned short nr_of_dest_addr, - unsigned short nr_of_input_streams, - unsigned short nr_of_output_streams - ) -{ - short sua_portnumber = SUA_PORT; - - short i = 1, assoc_instance_idx = 1, assoc_source_idx = 0; - bool partial_assoc_found = FALSE; - - while ((i <= num_of_instance) && !(partial_assoc_found)){ - partial_assoc_found = (instance[i].Dest.nr_of_addrs == 0); - if (partial_assoc_found) - assoc_instance_idx = i; - i++; - } - - if (!(partial_assoc_found)) - { - /* all assoc's are complete, allocate a new one */ - num_of_instance++; - assoc_instance_idx = num_of_instance; - - } - - assoc_source_idx = Find_local_sua ( clg); - -#ifdef DEBUG - cout << " assoc source idx = " << assoc_source_idx << ", assoc_instance_idx = " << assoc_instance_idx << "\n"; -#endif - - instance[assoc_instance_idx].Source = instance[assoc_source_idx].Source; - instance[assoc_instance_idx].SCTP_instance_name = instance[assoc_source_idx].SCTP_instance_name; - instance[assoc_instance_idx].local_sua_id = instance[assoc_source_idx].local_sua_id; - instance[assoc_instance_idx].nr_of_inbound_streams = nr_of_input_streams ; - instance[assoc_instance_idx].nr_of_outbound_streams = nr_of_input_streams ; - - /* conversion and fill in the destination address */ - instance[assoc_instance_idx].Dest.nr_of_addrs = 1; - instance[assoc_instance_idx].Dest.addrs[0] = cld.pc.ipvx; - - short k; - const char *ptr; - for(k=0; k < instance[assoc_instance_idx].Dest.nr_of_addrs ; k++) - { - if ( instance[assoc_instance_idx].Dest.addrs[k].sa.sa_family == AF_INET ) - ptr = inet_ntop( instance[assoc_instance_idx].Dest.addrs[k].sa.sa_family, - &instance[assoc_instance_idx].Dest.addrs[k].sin.sin_addr, - (char *)instance[assoc_instance_idx].Dest.address_string[k], - SCTP_MAX_IP_LEN - ); - else if ( instance[assoc_instance_idx].Dest.addrs[k].sa.sa_family == AF_INET6 ) - ptr = inet_ntop( instance[assoc_instance_idx].Dest.addrs[k].sa.sa_family, - &instance[assoc_instance_idx].Dest.addrs[k].sin6.sin6_addr, - (char *)instance[assoc_instance_idx].Dest.address_string[k], - SCTP_MAX_IP_LEN - ); - else - cout << "Unsupported address family in dynamic associate\n"; - } - - remote_sua.increase_instance(); - - instance[assoc_instance_idx].SCTP_assoc_id = - sctp_associate( instance[assoc_instance_idx].SCTP_instance_name, - instance[assoc_instance_idx].nr_of_outbound_streams, - instance[assoc_instance_idx].Dest.address_string[0], - sua_portnumber, - NULL - ); - instance[assoc_instance_idx].remote_sua_id = remote_sua.num_of_instance; - remote_sua.instance[remote_sua.num_of_instance].ssn.ssn = local_sua.instance[instance[assoc_instance_idx].local_sua_id].ssn.ssn; - - /* a message is queued for this association -> send decision is taken */ - /* on receiving the communicationUp notification of SCTP AND whether */ - /* SUA management is going to be used */ - instance[assoc_instance_idx].asp.status = asp_down_traf_hold; - -#ifdef DEBUG - cout << "Dynamic Associate remote SUA(& SCTP) instance nr " << assoc_instance_idx << " with local SUA(& SCTP) instance nr " << instance[assoc_instance_idx].local_sua_id << " \n"; -#endif - char logstring[100]; - sprintf(logstring, "Dynamic Associate Remote SUA(& SCTP) instance nr %d with local SUA(& SCTP) instance nr %d", assoc_instance_idx, instance[assoc_instance_idx].local_sua_id ); - event_log("sua_datasoc.c",logstring); - - return(assoc_instance_idx); -} /***********************************************************************/ /* Sua_AssociationList::Activate_Association */ @@ -1123,6 +767,398 @@ void db_Sua_AssociationList::up( unsigned int sua_assoc_id, ); } +/***********************************************************************/ +/* Sua_DatabaseList */ +/***********************************************************************/ +/***********************************************************************/ +/* Sua_DatabaseList::Find_local_sua */ +/***********************************************************************/ +unsigned int db_Sua_DatabaseList:: +Find_local_sua( sccp_addr_str& local_address + ) +{ + pointcode_str dest_pc; + short i = 1, j = 0, count, addr_start, addr_stop; + unsigned int Local_sua_id = 0; + bool result = FALSE; + + while ((i < db_MAX_REMOTE_SUA) && !(result) && (AssocDB.instance[i].Source.nr_of_addrs != 0)) + { + j = 0; + while ((j < AssocDB.instance[i].Source.nr_of_addrs) && !(result)) + { + /*result = ((AssocDB.instance[i].Source.addrs[j].sin.sin_addr.s_addr == local_address.pc.ipvx.sin.sin_addr.s_addr) || + (AssocDB.instance[i].Source.addrs[j].sin6.sin6_addr.s6_addr == local_address.pc.ipvx.sin6.sin6_addr.s6_addr)); + */ + if (local_address.address_fields_present.pc == ipvx_pc_present) + { + result = (local_address.pc.ipvx.sa.sa_family == AssocDB.instance[i].Source.addrs[j].sa.sa_family); + if (local_address.pc.ipvx.sa.sa_family == AF_INET) + { + addr_start = 4; + addr_stop = addr_start + 4; + } + else if (local_address.pc.ipvx.sa.sa_family == AF_INET6) + { + addr_start = 8; + addr_stop = addr_start + 16; + } + else + { + addr_start = 0; + addr_stop = 0; + result = false; + cout << "ERROR Find_local_sua: Unknown IPvx addresstype\n"; + } + /* compare the address family field */ + result = result && + (local_address.pc.ipvx.ch[1] == AssocDB.instance[i].Source.addrs[j].ch[1]); + + /* compare the ipv4/ipv6 address field */ + for (count = addr_start; count < addr_stop; count++) + { + result = result && + (local_address.pc.ipvx.ch[count] == AssocDB.instance[i].Source.addrs[j].ch[count]); + } + } + else if (local_address.address_fields_present.pc == ss7_pc_present) + { + result = (local_address.pc.ss7.ITU14.family == AssocDB.instance[i].Source.pc.ITU14.family); + if (((local_address.pc.ss7.ITU14.family == ITU14bit) || + (local_address.pc.ss7.ITU14.family == ITU24bit)) || + (local_address.pc.ss7.ITU14.family == ANSI24bit)) + { + /* compare the ITU 14/24bit or ANSI 24bit PC address field */ + result = result && + (local_address.pc.ss7.ITU14.pc == AssocDB.instance[i].Source.pc.ITU14.pc); + } + else + { + result = false; + cout << "ERROR Find_local_sua: Unknown SS7 pointcode addresstype\n"; + } + } + else if (local_address.address_fields_present.name_gt == hostname_present) + { + count = 0; + result = NameDB.resolve_host_name ( local_address.name.HostName, + dest_pc + ); + + result = (dest_pc.ipvx.sa.sa_family == AssocDB.instance[i].Source.addrs[j].sa.sa_family); + + if (dest_pc.ipvx.sa.sa_family == AF_INET) + { + addr_start = 4; + addr_stop = addr_start + 4; + } + else if (dest_pc.ipvx.sa.sa_family == AF_INET6) + { + addr_start = 8; + addr_stop = addr_start + 16; + } + else + { + addr_start = 0; + addr_stop = 0; + result = false; + cout << "ERROR Find_local_sua: Unknown IPvx addresstype\n"; + } + /* compare the address family field : already done */ + /* compare the ipv4/ipv6 address field */ + short k=0; + for (count = addr_start; count < addr_stop; count++) + { + result = result && + (dest_pc.ipvx.ch[count] == AssocDB.instance[i].Source.addrs[j].ch[count]); + k++; + } + + } + else if (local_address.address_fields_present.name_gt == GT_present) + { + cout << "ERROR Find_local_sua: GT code not implemented yet\n"; + } + else + { + cout << "ERROR Find_local_sua: Unknown SUA addresstype\n"; + result = false; + } + + if (result) + { + Local_sua_id = AssocDB.instance[i].local_sua_id; +#ifdef DEBUG + cout << "Find_local_sua: local_sua_id = " << Local_sua_id << " , instance "<< i << "\n"; +#endif + } + j++; + } + i++; + } + + return(Local_sua_id); +}; + +/***********************************************************************/ +/* Sua_DatabaseList::route_on_GTname */ +/***********************************************************************/ +signed int db_Sua_DatabaseList:: +route_on_GTname ( hostname_str& dest_name, + hostname_str& org_name, + int& sua_assoc_id, + pointcode_str& dest_pc, + pointcode_str& org_pc + ) +{ + int result = 0; + unsigned int sctp_assoc_id = 0; + + sua_assoc_id = 0; + + /* resolving can be done via: */ + /* - local global Titel database */ + /* - resolve hostname via DNS(simplest for single hop translations) */ + result = NameDB.resolve_host_name ( dest_name, + dest_pc + ); + + /*result = resolve_host_name ( org_name, + org_pc + ); */ + + sctp_assoc_id = AssocDB.route_on_IPpc( dest_pc.ipvx, + org_pc.ipvx, + sua_assoc_id + ); + + if (sctp_assoc_id != 0 ) + return(sctp_assoc_id); + + + return(sctp_assoc_id); +}; + +/***********************************************************************/ +/* Sua_DatabaseList::route_on_GTT */ +/***********************************************************************/ +signed int db_Sua_DatabaseList:: +route_on_GTT ( global_title_str& dest_gt, + global_title_str& org_gt, + int& sua_assoc_id, + pointcode_str& dest_pc, + pointcode_str& org_pc + ) +{ + int result = 0; + unsigned int sctp_assoc_id = 0; + global_title_str dest_tr_gt, org_tr_gt; + + sua_assoc_id = 0; + + /* resolving can be done via: */ + /* - local global Titel database */ + result = NameDB.perform_GTT ( dest_gt, + org_gt, + dest_tr_gt, + org_tr_gt, + dest_pc + ); + + sctp_assoc_id = AssocDB.route_on_IPpc( dest_pc.ipvx, + org_pc.ipvx, + sua_assoc_id + ); + + if (sctp_assoc_id != 0 ) + return(sctp_assoc_id); + + + return(sctp_assoc_id); +}; + + +/***********************************************************************/ +/* Sua_DatabaseList::route_msg */ +/***********************************************************************/ +signed int db_Sua_DatabaseList:: +route_msg( sccp_addr_str& cld, + sccp_addr_str& clg, + int& sua_assoc_id + ){ + + unsigned int sctp_assoc_id = 0; + + sua_assoc_id = 0; + +#ifdef DEBUG + cout << "num_of_instance : "<< AssocDB.num_of_instance << "\n"; +#endif + + if ((cld.address_fields_present.pc == ipvx_pc_present) && + (cld.routing_ind == route_on_ssn)) + { + sctp_assoc_id = AssocDB.route_on_IPpc( cld.pc.ipvx, + clg.pc.ipvx, + sua_assoc_id + ); + } + else if ((cld.address_fields_present.name_gt == hostname_present) && + (cld.routing_ind == route_on_name_gt)) + { + sctp_assoc_id = route_on_GTname( cld.name.HostName, + clg.name.HostName, + sua_assoc_id, + cld.pc, + clg.pc + ); + } + else if ((cld.address_fields_present.name_gt == GT_present) && + (cld.routing_ind == route_on_name_gt)) + { + sctp_assoc_id = route_on_GTT( cld.name.GT, + clg.name.GT, + sua_assoc_id, + cld.pc, + clg.pc + ); + } + else if ((cld.address_fields_present.name_gt == hostname_present) && + (cld.address_fields_present.pc == ipvx_pc_present) && + (cld.routing_ind == route_on_name_gt_next_office)) + { + sctp_assoc_id = AssocDB.route_on_IPpc( cld.pc.ipvx, + clg.pc.ipvx, + sua_assoc_id + ); + } + else if ((cld.address_fields_present.pc == ss7_pc_present) && + (cld.routing_ind == route_on_ssn)) + { + sctp_assoc_id = AssocDB.route_on_SS7pc( cld.pc.ss7, + clg.pc.ss7, + sua_assoc_id + ); + } + else + { + cout << "Unknown routing requested\n"; + } + +#ifdef SUA_MANAGEMENT + /* check if allowed to send msg over the association */ + if ((sua_assoc_id > 0) && + (sua_assoc_id <= AssocDB.num_of_instance) && + (AssocDB.instance[sua_assoc_id].asp.status != asp_active)) + { + sctp_assoc_id = (-sctp_assoc_id); + } +#endif + +#ifdef DEBUG + cout << "route msg towards remote SUA(& SCTP) association " << sctp_assoc_id << " \n"; +#endif + char logstring[100]; + sprintf(logstring, "Route msg towards Remote SUA(& SCTP) instance nr %d", sctp_assoc_id ); + event_log("sua_database.c",logstring); + + return(sctp_assoc_id); +}; + +/***********************************************************************/ +/* Sua_DatabaseList::Dynamic_Associate */ +/***********************************************************************/ +unsigned int db_Sua_DatabaseList::Dynamic_Associate( sccp_addr_str& cld, + sccp_addr_str& clg, + unsigned short nr_of_dest_addr, + unsigned short nr_of_input_streams, + unsigned short nr_of_output_streams + ) +{ + short sua_portnumber = SUA_PORT; + + short i = 1, assoc_instance_idx = 1, assoc_source_idx = 0; + bool partial_assoc_found = FALSE; + + while ((i <= AssocDB.num_of_instance) && !(partial_assoc_found)){ + partial_assoc_found = (AssocDB.instance[i].Dest.nr_of_addrs == 0); + if (partial_assoc_found) + assoc_instance_idx = i; + i++; + } + + if (!(partial_assoc_found)) + { + /* all assoc's are complete, allocate a new one */ + AssocDB.num_of_instance++; + assoc_instance_idx = AssocDB.num_of_instance; + + } + + assoc_source_idx = Find_local_sua ( clg); + +#ifdef DEBUG + cout << " assoc source idx = " << assoc_source_idx << ", assoc_instance_idx = " << assoc_instance_idx << "\n"; +#endif + + AssocDB.instance[assoc_instance_idx].Source = AssocDB.instance[assoc_source_idx].Source; + AssocDB.instance[assoc_instance_idx].SCTP_instance_name = AssocDB.instance[assoc_source_idx].SCTP_instance_name; + AssocDB.instance[assoc_instance_idx].local_sua_id = AssocDB.instance[assoc_source_idx].local_sua_id; + AssocDB.instance[assoc_instance_idx].nr_of_inbound_streams = nr_of_input_streams ; + AssocDB.instance[assoc_instance_idx].nr_of_outbound_streams = nr_of_input_streams ; + + /* conversion and fill in the destination address */ + AssocDB.instance[assoc_instance_idx].Dest.nr_of_addrs = 1; + AssocDB.instance[assoc_instance_idx].Dest.addrs[0] = cld.pc.ipvx; + + short k; + const char *ptr; + for(k=0; k < AssocDB.instance[assoc_instance_idx].Dest.nr_of_addrs ; k++) + { + if ( AssocDB.instance[assoc_instance_idx].Dest.addrs[k].sa.sa_family == AF_INET ) + ptr = inet_ntop( AssocDB.instance[assoc_instance_idx].Dest.addrs[k].sa.sa_family, + &AssocDB.instance[assoc_instance_idx].Dest.addrs[k].sin.sin_addr, + (char *)AssocDB.instance[assoc_instance_idx].Dest.address_string[k], + SCTP_MAX_IP_LEN + ); + else if ( AssocDB.instance[assoc_instance_idx].Dest.addrs[k].sa.sa_family == AF_INET6 ) + ptr = inet_ntop( AssocDB.instance[assoc_instance_idx].Dest.addrs[k].sa.sa_family, + &AssocDB.instance[assoc_instance_idx].Dest.addrs[k].sin6.sin6_addr, + (char *)AssocDB.instance[assoc_instance_idx].Dest.address_string[k], + SCTP_MAX_IP_LEN + ); + else + cout << "Unsupported address family in dynamic associate\n"; + } + + remote_sua.increase_instance(); + + AssocDB.instance[assoc_instance_idx].SCTP_assoc_id = + sctp_associate( AssocDB.instance[assoc_instance_idx].SCTP_instance_name, + AssocDB.instance[assoc_instance_idx].nr_of_outbound_streams, + AssocDB.instance[assoc_instance_idx].Dest.address_string[0], + sua_portnumber, + NULL + ); + AssocDB.instance[assoc_instance_idx].remote_sua_id = remote_sua.num_of_instance; + remote_sua.instance[remote_sua.num_of_instance].ssn.ssn = local_sua.instance[AssocDB.instance[assoc_instance_idx].local_sua_id].ssn.ssn; + + /* a message is queued for this association -> send decision is taken */ + /* on receiving the communicationUp notification of SCTP AND whether */ + /* SUA management is going to be used */ + AssocDB.instance[assoc_instance_idx].asp.status = asp_down_traf_hold; + +#ifdef DEBUG + cout << "Dynamic Associate remote SUA(& SCTP) instance nr " << assoc_instance_idx << " with local SUA(& SCTP) instance nr " << AssocDB.instance[assoc_instance_idx].local_sua_id << " \n"; +#endif + char logstring[100]; + sprintf(logstring, "Dynamic Associate Remote SUA(& SCTP) instance nr %d with local SUA(& SCTP) instance nr %d", assoc_instance_idx, AssocDB.instance[assoc_instance_idx].local_sua_id ); + event_log("sua_datasoc.c",logstring); + + + return(assoc_instance_idx); +} + // end of module sua_database.c diff --git a/sualibrary/sua/sua_debug.h b/sualibrary/sua/sua_debug.h index 9d0bf9b..a2eb436 100644 --- a/sualibrary/sua/sua_debug.h +++ b/sualibrary/sua/sua_debug.h @@ -15,7 +15,7 @@ * * ***************************************************************************/ /* - * $Id: sua_debug.h,v 1.2 2002/02/22 16:12:11 p82609 Exp $ + * $Id: sua_debug.h,v 1.5 2002/11/12 11:02:49 p82609 Exp $ * * SUA implementation according to SUA draft issue 6. * @@ -57,11 +57,12 @@ #ifndef SUA_DEBUG_H #define SUA_DEBUG_H -//#define DEBUG /* activates debuging msg on screen */ -//#define FILE_DEBUG /* activates debugging info to output file */ +#define DEBUG /* activates debuging msg on screen */ +#define FILE_DEBUG /* activates debugging info to output file */ #define SUA_MANAGEMENT /* activates SUA management */ -#define SG_ASP_MODE /* implementation acts as ASP towards a SG */ - +/*#define SG_ASP_MODE implementation acts as ASP towards a SG */ +/*#define SG_MODE implementation acts as SG */ +/*#define IPSP_SINGLE implementation acts in IPSP single mode */ #endif // SUA_DEBUG_H diff --git a/sualibrary/sua/sua_distribution.cpp b/sualibrary/sua/sua_distribution.cpp index c588f49..d01b93a 100644 --- a/sualibrary/sua/sua_distribution.cpp +++ b/sualibrary/sua/sua_distribution.cpp @@ -15,7 +15,7 @@ * * ***************************************************************************/ /* - * $Id: sua_distribution.cpp,v 1.1.1.1 2002/02/04 14:30:41 p82609 Exp $ + * $Id: sua_distribution.cpp,v 1.7 2002/11/12 11:02:49 p82609 Exp $ * * SUA implementation according to SUA draft issue 6. * @@ -73,6 +73,8 @@ #include "sua_cl.h" #include "sua_co.h" #include "sua_distribution.h" +#include "sua_asp_mgnt.h" +#include "sua_snm_mgnt.h" #include @@ -92,21 +94,23 @@ Sua_container msg; // storage for received SUA messages vector rec_msg_pool; -extern db_Sua_LocalList local_sua; -extern db_Sua_RemoteList remote_sua; -extern db_Sua_AssociationList Assoc_sua; +extern db_Sua_DatabaseList sua; + extern tcb_Sua_TCB_arr tcb_pool; extern tcb_Sua_msgqueue_pool msg_store; +/* cvs shit */ /***********************************************************************/ /* sctp_DataArriveNotif */ /***********************************************************************/ -void sctp_DataArriveNotif( unsigned int sctp_assoc_id, - unsigned int stream_id, - unsigned int len, - unsigned int protocol_id, - unsigned int unordered_flag, - void * ulp_data_ptr +void sctp_DataArriveNotif( unsigned int sctp_assoc_id, + unsigned int stream_id, + unsigned int len, + unsigned short data_streamSN, + unsigned int data_tsn, + unsigned int protocol_id, + unsigned int unordered_flag, + void * ulp_data_ptr ) { @@ -114,6 +118,8 @@ void sctp_DataArriveNotif( unsigned int sctp_assoc_id, unsigned int Sua_ConnId; unsigned int sua_assoc_id; unsigned int local_sua_id,remote_sua_id; + unsigned short streamSN; + unsigned int tsn; tcb_Sua_TCB_str *tcb_ptr; Sua_syntax_error_struct error; char databuf[BUFSIZE]; @@ -130,6 +136,8 @@ void sctp_DataArriveNotif( unsigned int sctp_assoc_id, stream_id, (unsigned char *) databuf, &len, + &streamSN, + &tsn, flags ); @@ -153,10 +161,10 @@ void sctp_DataArriveNotif( unsigned int sctp_assoc_id, char logstring[100]; sprintf(logstring, "Decoding error in received SUA message : index = %d,", error.msg_index); event_log("sua_distribution.c",logstring); - char *spare = new char[error.error_text.length()]; - error.error_text.copy(spare, error.error_text.length()); - sprintf(logstring, "Error string = %s,", spare); - event_log("sua_distribution.c",logstring); + /*char *spare = new char[error.error_text.length()];*/ + /*error.error_text.copy(spare, error.error_text.length());*/ + /*sprintf(logstring, "Error string = %s,", spare);*/ + /*event_log("sua_distribution.c",logstring);*/ cout << "Decoding error in received SUA message : "<< error.error_text << ", index = " << error.msg_index << "\n"; msg.sua_prim.hdr_msg_class = sua_max; return; @@ -176,11 +184,11 @@ void sctp_DataArriveNotif( unsigned int sctp_assoc_id, #ifdef DEBUG cout << "CL: Unitdata message handling\n"; #endif - unsigned int local_sua_id,remote_sua_id; - sua_assoc_id = Assoc_sua.Find_association( sctp_assoc_id, - local_sua_id, - remote_sua_id - ); + + sua_assoc_id = sua.AssocDB.Find_association( sctp_assoc_id, + local_sua_id, + remote_sua_id + ); result = process_unitdata_msg ( local_sua_id, sua_assoc_id, msg @@ -197,6 +205,16 @@ void sctp_DataArriveNotif( unsigned int sctp_assoc_id, #ifdef DEBUG cout << "CL: Unitdata Service message handling\n"; #endif + + sua_assoc_id = sua.AssocDB.Find_association( sctp_assoc_id, + local_sua_id, + remote_sua_id + ); + result = process_UDTService_msg ( local_sua_id, + sua_assoc_id, + msg + ); + char logstring[100]; sprintf(logstring, "Received Unitdata Service msg"); event_log("sua_distribution.c",logstring); @@ -232,7 +250,7 @@ void sctp_DataArriveNotif( unsigned int sctp_assoc_id, unsigned int local_sua_id,remote_sua_id; - sua_assoc_id = Assoc_sua.Find_association( sctp_assoc_id, + sua_assoc_id = sua.AssocDB.Find_association( sctp_assoc_id, local_sua_id, remote_sua_id ); @@ -386,7 +404,7 @@ void sctp_DataArriveNotif( unsigned int sctp_assoc_id, case (sua_mngt): // SUA management msg - sua_assoc_id = Assoc_sua.Find_association( sctp_assoc_id, + sua_assoc_id = sua.AssocDB.Find_association( sctp_assoc_id, local_sua_id, remote_sua_id ); @@ -434,7 +452,7 @@ void sctp_DataArriveNotif( unsigned int sctp_assoc_id, case (sua_ssnm): // Signalling Network Management(SNM) msg - sua_assoc_id = Assoc_sua.Find_association( sctp_assoc_id, + sua_assoc_id = sua.AssocDB.Find_association( sctp_assoc_id, local_sua_id, remote_sua_id ); @@ -471,7 +489,11 @@ void sctp_DataArriveNotif( unsigned int sctp_assoc_id, #ifdef DEBUG cout << "SNM: Destination state audit message handling\n"; #endif - + result = process_DAUD_msg ( sua_assoc_id, + local_sua_id, + remote_sua_id, + msg + ); char logstring[100]; sprintf(logstring, "Received DAUD msg"); event_log("sua_distribution.c",logstring); @@ -529,7 +551,7 @@ void sctp_DataArriveNotif( unsigned int sctp_assoc_id, case (sua_aspsm): // ASP State maintenance msg - sua_assoc_id = Assoc_sua.Find_association( sctp_assoc_id, + sua_assoc_id = sua.AssocDB.Find_association( sctp_assoc_id, local_sua_id, remote_sua_id ); @@ -653,7 +675,7 @@ void sctp_DataArriveNotif( unsigned int sctp_assoc_id, case (sua_asptm): // ASP Traffic maintenance msg - sua_assoc_id = Assoc_sua.Find_association( sctp_assoc_id, + sua_assoc_id = sua.AssocDB.Find_association( sctp_assoc_id, local_sua_id, remote_sua_id ); @@ -805,11 +827,11 @@ void sctp_CommunicationLostNotif( unsigned int sctp_assoc_id, event_log("sua_distribution.c",logstring); #ifdef SUA_MANAGEMENT - if ((sua_assoc_id = Assoc_sua.Find_association(sctp_assoc_id, local_sua_id,remote_sua_id)) != 0) + if ((sua_assoc_id = sua.AssocDB.Find_association(sctp_assoc_id, local_sua_id,remote_sua_id)) != 0) { /* if we found the sua assoc then the SUA ASP is marked down, */ /* as the sctp association has failed */ - Assoc_sua.down(sua_assoc_id, 0); + sua.AssocDB.down(sua_assoc_id, 0); #ifdef DEBUG cout << "ASP down for SUA association " << sua_assoc_id << "\n"; #endif @@ -823,10 +845,11 @@ void sctp_CommunicationLostNotif( unsigned int sctp_assoc_id, /* sctp_CommunicationUpNotif */ /***********************************************************************/ void *sctp_CommunicationUpNotif( unsigned int sctp_assoc_id, - unsigned short status_event, - int nr_of_dest_addr, + int status_event, + unsigned int nr_of_dest_addr, unsigned short nr_of_input_streams, unsigned short nr_of_output_streams, + int support_PRsctp, void * ulp_data_ptr ) { @@ -852,13 +875,13 @@ void *sctp_CommunicationUpNotif( unsigned int sctp_assoc_id, - if ((sua_assoc_id = Assoc_sua.Find_association(sctp_assoc_id, local_sua_id,remote_sua_id)) == 0) { + if ((sua_assoc_id = sua.AssocDB.Find_association(sctp_assoc_id, local_sua_id,remote_sua_id)) == 0) { #ifdef DEBUG cout << "association " << sctp_assoc_id << " is not present\n"; #endif - sua_assoc_id = Assoc_sua.passive_associate( sctp_assoc_id, - local_sua, - remote_sua, + sua_assoc_id = sua.AssocDB.passive_associate( sctp_assoc_id, + sua.local_sua, + sua.remote_sua, nr_of_dest_addr, nr_of_input_streams, nr_of_output_streams @@ -867,7 +890,7 @@ void *sctp_CommunicationUpNotif( unsigned int sctp_assoc_id, /* code include if SUA management is NOT used */ #ifndef SUA_MANAGEMENT - if ( Assoc_sua.instance[sua_assoc_id].status == asp_down_traf_hold) + if ( sua.AssocDB.instance[sua_assoc_id].status == asp_down_traf_hold) { /* - get the saved msg ansd send it on the association that is setup */ sua_msg = msg_store.get_msg ( sua_assoc_id ); @@ -910,7 +933,7 @@ void *sctp_CommunicationUpNotif( unsigned int sctp_assoc_id, } /* SUA ASP is marked down */ - Assoc_sua.down(sua_assoc_id,0); + sua.AssocDB.down(sua_assoc_id,0); } #endif @@ -920,12 +943,14 @@ void *sctp_CommunicationUpNotif( unsigned int sctp_assoc_id, #ifdef DEBUG cout << "sua_distribution.c:should send ASPUP\n"; #endif +#ifndef SG_MODE /* send ASP-UP to remote to start activating local & remote ASP */ result = sua_send_ASPUP( sua_assoc_id ); +#endif #endif - return NULL; + return NULL; } /***********************************************************************/ @@ -959,14 +984,14 @@ void sctp_RestartNotif( unsigned int sctp_assoc_id, #endif #ifdef SUA_MANAGEMENT - if ((sua_assoc_id = Assoc_sua.Find_association(sctp_assoc_id, local_sua_id,remote_sua_id)) == 0) + if ((sua_assoc_id = sua.AssocDB.Find_association(sctp_assoc_id, local_sua_id,remote_sua_id)) == 0) { #ifdef DEBUG - cout << "ASP status = " << Assoc_sua.instance[sua_assoc_id].asp.status <<" for SUA association " << sua_assoc_id << "\n"; + cout << "ASP status = " << sua.AssocDB.instance[sua_assoc_id].asp.status <<" for SUA association " << sua_assoc_id << "\n"; #endif /* restart association: ASP state should be set to down */ - Assoc_sua.down(sua_assoc_id,0); + sua.AssocDB.down(sua_assoc_id,0); /* if we found the sua assoc then we restart the ASP bringup sequence */ /* as the sctp association has come back online */ diff --git a/sualibrary/sua/sua_distribution.h b/sualibrary/sua/sua_distribution.h index f384f29..6a62f50 100644 --- a/sualibrary/sua/sua_distribution.h +++ b/sualibrary/sua/sua_distribution.h @@ -15,7 +15,7 @@ * * ***************************************************************************/ /* - * $Id: sua_distribution.h,v 1.1.1.1 2002/02/04 14:30:41 p82609 Exp $ + * $Id: sua_distribution.h,v 1.2 2002/10/15 14:53:48 p82609 Exp $ * * SUA implementation according to SUA draft issue 6. * @@ -89,12 +89,14 @@ typedef struct { /***********************************************************************/ /* sctp_DataArriveNotif */ /***********************************************************************/ -void sctp_DataArriveNotif( unsigned int assoc_id, - unsigned int stream_id, - unsigned int len, - unsigned int protocol_id, - unsigned int unordered_flag, - void * ulp_data_ptr +void sctp_DataArriveNotif( unsigned int assoc_id, + unsigned int stream_id, + unsigned int len, + unsigned short streamSN, + unsigned int tsn, + unsigned int protocol_id, + unsigned int unordered_flag, + void * ulp_data_ptr ); @@ -131,10 +133,11 @@ void sctp_CommunicationLostNotif( unsigned int assoc_id, /* sctp_CommunicationUpNotif */ /***********************************************************************/ void* sctp_CommunicationUpNotif( unsigned int assoc_id, - unsigned short status_event, - int nr_of_dest_addr, + int status_event, + unsigned int nr_of_dest_addr, unsigned short nr_of_input_streams, unsigned short nr_of_output_streams, + int support_PRsctp, void * ulp_data_ptr ); diff --git a/sualibrary/sua/sua_file.cpp b/sualibrary/sua/sua_file.cpp index c5ad667..a901992 100644 --- a/sualibrary/sua/sua_file.cpp +++ b/sualibrary/sua/sua_file.cpp @@ -15,9 +15,9 @@ * * ***************************************************************************/ /* - * $Id: sua_file.cpp,v 1.1.1.1 2002/02/04 14:30:41 p82609 Exp $ + * $Id: sua_file.cpp,v 1.3 2002/11/12 11:02:49 p82609 Exp $ * - * SUA implementation according to SUA draft issue 6. + * SUA implementation according to SUA draft issue 13. * * Author(s): Lode Coene * @@ -80,11 +80,13 @@ using namespace std; - +/***********************************************************************/ +/* get_argument */ +/***********************************************************************/ string get_argument(string line, - int& begin, - int& end, - unsigned int& num_of_char_in_line) + int& begin, + int& end, + unsigned int& num_of_char_in_line) { int len = 0; bool cont = true; @@ -125,7 +127,9 @@ string get_argument(string line, return(sua_arg); } - +/***********************************************************************/ +/* read sua file */ +/***********************************************************************/ int read_sua_file(string filename, db_Sua_LocalList& local_sua, db_Sua_RemoteList& remote_sua, @@ -149,17 +153,22 @@ int read_sua_file(string filename, cout << "file to read = " << filename << " \n"; #endif cout << "SUA local sua instantation parameters(mandatory) \n"; - cout << "-s x.x.x.x -l yyy [-u] \n"; + cout << "-s[n] x.x.x.x -l yyy [-7s 7777] [-gs tt-nat-np-digits][-u] \n"; cout << "-s : source address \n"; cout << "-l : source local sua portnumber \n"; + cout << "-sn: source name \n"; + cout << "-7s: source SS7 pointcode\n"; cout << "-u : listen on local port number \n"; cout << "SUA parameters of the sua tester (optional)\n"; cout << "Not supported yet (-b 1000 -o -v) \n"; cout << "SUA parameters of the SUA remote instantation(s) (optional)\n"; - cout << "-d x.x.x.x -r yyy [-g tt-nat-np-digits] [-a ASnumber] \n"; + cout << "-d[n] x.x.x.x -r yyy [-7d 7777] [-gd tt-nat-np-digits] [-a ASnumber] \n"; cout << "-d : destination address \n"; cout << "-r : destination sua portnumber \n"; - cout << "-g : global title(TTID-NAT-NUMPLAN-Digits) linked to destination address \n"; + cout << "-dn: destination name \n"; + cout << "-7d: destination SS7 pointcode\n"; + cout << "-gs: source global title(TTID-NAT-NUMPLAN-Digits) linked to -s address or -sn name \n"; + cout << "-gd: destination global title(TTID-NAT-NUMPLAN-Digits) linked to -d address or -dn name\n"; cout << "-a : Application Server(AS) this address belongs to \n"; ifstream infile(filename.c_str()); @@ -209,7 +218,7 @@ int read_sua_file(string filename, Assoc_sua.instance[Assoc_sua.num_of_instance].nr_of_outbound_streams = 1; if (ch2 == 'n') { - ip_addr_str = NameDB_sua.read_host_name(address_str); + ip_addr_str = Assoc_sua.read_host_name(NameDB_sua, address_str); Assoc_sua.read_Source_addr(ip_addr_str); } else { @@ -235,7 +244,7 @@ int read_sua_file(string filename, present_remote_instance = 0; } if (ch2 == 'n') { - ip_addr_str = NameDB_sua.read_host_name(address_str); + ip_addr_str = Assoc_sua.read_host_name(NameDB_sua, address_str); Assoc_sua.read_Dest_addr(ip_addr_str); } else { @@ -328,6 +337,36 @@ int read_sua_file(string filename, num_of_arg++; break; } + case 'g': + { + /* read global title */ + switch (ch2) + { + case 's': // read source Global Title for sua + { + num_of_arg++; + address_str = get_argument(sua_line,b,e,num_of_char_in_line); + + Assoc_sua.read_Source_GT(NameDB_sua, address_str); + + break; + } + case 'd': + { // read destination Global Title for sua + num_of_arg++; + address_str = get_argument(sua_line,b,e,num_of_char_in_line); + + Assoc_sua.read_Dest_GT(NameDB_sua, address_str); + + break; + } + default: + { + break; + } + } + break; + } case 'i': { // ignore character, is not a error, go to next argument @@ -341,16 +380,16 @@ int read_sua_file(string filename, { num_of_arg++; address_str = get_argument(sua_line,b,e,num_of_char_in_line); - + Assoc_sua.read_Source_pointcode(address_str); - + break; } case 'd': { // read destination pointcode for sua num_of_arg++; address_str = get_argument(sua_line,b,e,num_of_char_in_line); - + Assoc_sua.read_Dest_pointcode(address_str); break; @@ -375,27 +414,159 @@ int read_sua_file(string filename, break; } } - sua_arg = get_argument(sua_line,b,e,num_of_char_in_line); - num_of_arg++; + sua_arg = get_argument(sua_line,b,e,num_of_char_in_line); + num_of_arg++; } // finished reading the whole line num_of_char = num_of_char + num_of_char_in_line; cout << "Line " << num_of_lines << " : " << sua_line << "\n"; } - + #ifdef DEBUG cout << "End of file: statistics \n"; cout << "Number of lines = " << num_of_lines <<"\n"; cout << "Number of characters in file = " << num_of_char << "\n"; - + #endif - + return (0); - + } /* end of read_sua_file */ +/***********************************************************************/ +/* create host parameter handling */ +/***********************************************************************/ +void sua_cr_host( string host_parm_str, + db_Sua_LocalList& local_sua + ) +{ + int host_id; + /* get host id from param string, use as index in local_sua table */ + + host_id = 1; + + string ip_addr_str( host_parm_str, (host_parm_str.find("org_ip=")+7),host_parm_str.length()); + /* get all(=multihomed) addresses till next parameter */ + /* fill in IP address as string in local_sua */ + /*local_sua.instance[host_id].ip_addr_str = ip_addr_str;*/ + + /* get the local port number for this instance */ + /* local_sua.instance[host_id].portnumber=14001 */ + + /* get the local ssn for this local sua host instantiation */ + /* local_sua.instance[host_id].ssn = 5 */ + + /* get the number of streams supported for this sua instantiation */ + /* local_sua.instance[host_id].streams=16 */ + +} + +/***********************************************************************/ +/* create association parameter handling */ +/***********************************************************************/ +void sua_cr_assoc( string assoc_parm_str, + db_Sua_AssociationList& Assoc_sua, + db_Sua_LocalList& local_sua + ) +{ + int assoc_id; + /* get assoc id from param string, use as index in assoc_sua table */ + + assoc_id = 1; + + string ip_addr_str( assoc_parm_str, (assoc_parm_str.find("dest_ip=")+8),assoc_parm_str.length()); + /* get all(=multihomed) addresses till next parameter */ + /* fill in IP address as string & network in assoc_sua */ + /* Assoc_sua.instance[assoc_id].ip_addr_str = ip_addr_str;*/ + + /* get the local port number for this instance */ + /* Assoc_sua.instance[assoc_id].portnumber=14001 */ + + /* get the local ssn for this local sua host instantiation */ + /* local_sua.instance[host_id].ssn = 5 */ + + /* get the number of streams supported for this sua instantiation */ + /* local_sua.instance[host_id].streams=16 */ + +} + +/***********************************************************************/ +/* read sua configuration file */ +/***********************************************************************/ +int read_sua_conf_file( string filename, + db_Sua_DatabaseList sua + ) +{ + string sua_filename; + string sua_arg; + char readBuffer[256]; + + cout << "SUA configuration file to read = " << filename << " \n"; + + cout << "SUA local sua instantation parameters(mandatory) \n"; + cout << "cr host:host_id = j, org_ip= t.t.t.t, org_port= yyyyy \n"; + cout << "cr assoc:assoc_id= i, init= false, host_id = j, dest_ip = x.x.x.x, dest_port= yyyy \n"; + cout << "cr orgpc: pc = wwww, host_id = j\n"; + cout << "cr destpc: pc = wwww, rc = x \n"; + cout << "cr hostname: namegt_id= k name= www.sctp.be \n"; + cout << "cr gt:namegt_id = k,tt= tt, na= nn, np= ppp, digits= 123456789abcdef \n"; + cout << "cr route: dpc= www, assoc_id = i AND/OR\n"; + cout << "cr route: dest_ip = x.x.x.x, assoc_id = i AND/OR\n"; + cout << "cr route: namegt_id= k, assoc_id = i \n"; + + ifstream infile(filename.c_str()); + + while (infile.getline(readBuffer,256,'\n')) + { + string cmdline(readBuffer,strlen(readBuffer)); + + if (cmdline.length() == 0) + { + cout << "empty line?\n"; + } + else if (cmdline.find("/") != cmdline.npos) + { + /* comment line: do not execute */ + } + else if (cmdline.find("cr host:") != cmdline.npos) + { + string parm_str( cmdline, (cmdline.find("cr host:")+8),cmdline.length()); + sua_cr_host( parm_str, + sua.local_sua + ); + } + else if (cmdline.find("cr assoc:") != cmdline.npos) + { + string parm_str( cmdline, (cmdline.find("cr assoc:")+9),cmdline.length()); + sua_cr_assoc( parm_str, + sua.AssocDB, + sua.local_sua + ); + } + else if (cmdline.find("cr destpc:") != cmdline.npos) + { + + } + else if (cmdline.find("cr hostname:") != cmdline.npos) + { + + } + else if (cmdline.find("cr gt:") != cmdline.npos) + { + + } + else if (cmdline.find("cr xxxx:") != cmdline.npos) + { + + } + else + cout << "ERROR: Unknown " << cmdline << "command\n"; + } +} /* end of read_sua_conf_file */ // end of module sua_file.c + + diff --git a/sualibrary/sua/sua_file.h b/sualibrary/sua/sua_file.h index df7c3d5..eb77381 100644 --- a/sualibrary/sua/sua_file.h +++ b/sualibrary/sua/sua_file.h @@ -15,7 +15,7 @@ * * ***************************************************************************/ /* - * $Id: sua_file.h,v 1.1.1.1 2002/02/04 14:30:41 p82609 Exp $ + * $Id: sua_file.h,v 1.2 2002/11/12 11:02:49 p82609 Exp $ * * SUA implementation according to SUA draft issue 6. * @@ -69,6 +69,11 @@ int read_sua_file(string filename, db_Sua_ASList& ApplicServ_sua ); + +int read_sua_conf_file( string filename, + db_Sua_DatabaseList sua + ); + #endif // SUA_FILE_H // end of module sua_file.h diff --git a/sualibrary/sua/sua_logging.cpp b/sualibrary/sua/sua_logging.cpp index 8bc9757..7a1ce96 100644 --- a/sualibrary/sua/sua_logging.cpp +++ b/sualibrary/sua/sua_logging.cpp @@ -81,6 +81,8 @@ #define MAX_BYTES_IN_LINE 20 +using namespace std; + ofstream logfile; char log_filename[100]; diff --git a/sualibrary/sua/sua_snm_mgnt.cpp b/sualibrary/sua/sua_snm_mgnt.cpp new file mode 100644 index 0000000..fadd04d --- /dev/null +++ b/sualibrary/sua/sua_snm_mgnt.cpp @@ -0,0 +1,195 @@ +/*************************************************************************** + sua_snm_mgnt.cpp - description + ------------------- + begin : Tue Nov 4 2002 + copyright : (C) 2002 by Lode Coene + email : lode.coene@siemens.atea.be + ***************************************************************************/ + +/*************************************************************************** + * * + * This program 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. * + * * + ***************************************************************************/ +/* + * $Id: sua_snm_mgnt.cpp,v 1.1 2002/11/12 11:04:12 p82609 Exp $ + * + * SUA implementation according to SUA draft issue 14. + * + * Author(s): Lode Coene + * + * + * Copyright (C) 2001 by Siemens Atea, Herentals, Belgium. + * + * Realized in co-operation between Siemens Atea and + * Siemens AG, Munich, Germany. + * + * This program 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. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * Contact: gery.verwimp@siemens.atea.be + * lode.coene@siemens.atea.be + * + * The alternative comment + * inspiration : Sabine + * "Due to small parts(Booleans), this code is not suitable for" + * "childeren under 3 years." + * + * Purpose: This code-file defines the SUA management handling functions for + * sending and receiving SignallingNetwork Management(SNM) messages: + * - send a Destination avialeble (DAVA) msg to remote node + * - Receive/process Destination State audit(DAUD) msg + */ + +#include "sua_debug.h" +#include "sua_asp_mgnt.h" +#include "sua_database.h" +#include "sua_syntax.h" +#include "sua_logging.h" +#include "sua_tcb.h" + +#include +#include +#include + +using namespace std; + +extern db_Sua_DatabaseList sua; + +extern tcb_Sua_msgqueue_pool msg_store; + +/***********************************************************************/ +/* Sending SUA Signalling Network Management msg(SNM) */ +/***********************************************************************/ +/***********************************************************************/ +/* sua_send_DAVA */ +/***********************************************************************/ +int sua_send_DAVA( unsigned int Sua_assoc_id + ) +{ + Sua_container msg; + Sua_syntax_error_struct error; + int error_value = 0; + int string_size, datalen; + signed int sctp_assoc_id; + short stream_id = 0; + int delivery_type, result; + + // init the message + msg.sua_init(); + + // fill in the main sua header + msg.sua_prim.hdr_msg_class = sua_ssnm; + msg.sua_prim.hdr_msg_type.ssnm = ssnm_dava; + msg.sua_prim.aff_pc_pres = TRUE; + msg.sua_prim.aff_pc = 1; + msg.sua_prim.info_pres = FALSE; + + // encode the SUA DAVA message + error = msg.sua_encode(); + string_size = msg.sua_msg.size(); + + delivery_type = SCTP_UNORDERED_DELIVERY; + + sctp_assoc_id = sua.AssocDB.instance[Sua_assoc_id].SCTP_assoc_id; + + /* does association exist? */ + if (sctp_assoc_id > 0) + { + // send data to SCTP + char* databuf = new char[msg.sua_msg.length()]; + msg.sua_msg.copy(databuf, msg.sua_msg.length()); + datalen = msg.sua_msg.length(); + + /* yes it does, continue, no problem, send the msg */ +#ifdef DEBUG + // display byte array + display_byte_array(databuf , msg.sua_msg.length()); +#endif + char logstring[100]; + sprintf(logstring, "SUA encoded message, ready for being send to SCTP assoc %d", sctp_assoc_id); + event_log("sua_snm_mgnt.c",logstring); + log_byte_array("sua_snm_mgnt.c", databuf,msg.sua_msg.length()); + + result = sctp_send ( sctp_assoc_id, + stream_id, + (unsigned char *) databuf, + datalen, + SUA_PPI, + SCTP_USE_PRIMARY, + SCTP_NO_CONTEXT, + SCTP_INFINITE_LIFETIME, + delivery_type, + SCTP_BUNDLING_DISABLED + ); + + error_value = result; + delete databuf; +#ifdef DEBUG + cout << "sua_asp_mgnt.c:result DAVA sctp send = "<< result << "\n"; +#endif + } + + return(error_value); +} + + +/***********************************************************************/ +/* Receiving SUA Signalling Network Management msg */ +/***********************************************************************/ +/***********************************************************************/ +/* sua_process_ASPUP_msg */ +/***********************************************************************/ +int process_DAUD_msg ( unsigned int sua_assoc_id, + int local_sua_id, + int remote_sua_id, + Sua_container sua_asp_msg + ) +{ + + int error_value; + +#ifdef DEBUG + cout << "sua_snm_mgnt.c:DAUD received, send back a DAVA, DUNA or DRST.\n"; +#endif + + /*sua.AssocDB.up(sua_assoc_id,0);*/ + + error_value = sua_send_DAVA( sua_assoc_id ); + +#ifdef DEBUG + cout << "sua_asp_mgnt.c:result send DUNA/DAVA/DRST = "<< error_value << "\n"; +#endif + + return(error_value); +} + + +//end of module sua_asp_mgnt.c++ + + + + + + + + + + + + + diff --git a/sualibrary/sua/sua_snm_mgnt.h b/sualibrary/sua/sua_snm_mgnt.h new file mode 100644 index 0000000..8634035 --- /dev/null +++ b/sualibrary/sua/sua_snm_mgnt.h @@ -0,0 +1,85 @@ +/*************************************************************************** + sua_snm_mgnt.h - description + ------------------- + begin : Tue Nov 5 2002 + copyright : (C) 2002 by Lode Coene + email : lode.coene@siemens.atea.be + ***************************************************************************/ + +/*************************************************************************** + * * + * This program 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. * + * * + ***************************************************************************/ +/* + * $Id: sua_snm_mgnt.h,v 1.1 2002/11/12 11:04:12 p82609 Exp $ + * + * SUA implementation according to SUA draft issue 14. + * + * Author(s): Lode Coene + * + * + * Copyright (C) 2001 by Siemens Atea, Herentals, Belgium. + * + * Realized in co-operation between Siemens Atea and + * Siemens AG, Munich, Germany. + * + * This program 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. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * Contact: gery.verwimp@siemens.atea.be + * lode.coene@siemens.atea.be + * + * Purpose: This header-file defines the SUA management handling functions for + * sending and receiving Application Server Process(ASP) messages: + */ + +#ifndef SUA_SNM_MGNT_H +#define SUA_SNM_MGNT_H + +#include "sua.h" +#include "sua_syntax.h" + +#include + + + +int sua_send_DAVA( unsigned int Sua_assoc_id + ); + +int process_DAUD_msg ( unsigned int sua_assoc_id, + int local_sua_id, + int remote_sua_id, + Sua_container sua_asp_msg + ); + +#endif // SUA_SNM_MGNT_H + +//end of module sua_snm_mgnt.h + + + + + + + + + + + + + diff --git a/sualibrary/sua/sua_sual.cpp b/sualibrary/sua/sua_sual.cpp index 1b23cc0..b26c5a3 100644 --- a/sualibrary/sua/sua_sual.cpp +++ b/sualibrary/sua/sua_sual.cpp @@ -15,7 +15,7 @@ * * ***************************************************************************/ /* - * $Id: sua_sual.cpp,v 1.1.1.1 2002/02/04 14:30:41 p82609 Exp $ + * $Id: sua_sual.cpp,v 1.2 2002/04/11 14:13:34 p82609 Exp $ * * SUA implementation according to SUA draft issue 6. * @@ -95,10 +95,9 @@ #define MAX_DATA_LENGTH 2000 using namespace std; + /* definition of SUA local object and of remote object */ -extern db_Sua_LocalList local_sua; -extern db_Sua_RemoteList remote_sua; -extern db_Sua_AssociationList Assoc_sua; +extern db_Sua_DatabaseList sua; typedef struct { unsigned int local_sua_id; @@ -122,9 +121,9 @@ int sual_init(unsigned char *pConfFile) cout << "Initialising SUA datastructures\n "; init_logging_file(); - local_sua.initialize(); - remote_sua.initialize(); - Assoc_sua.initialize(); + sua.local_sua.initialize(); + sua.remote_sua.initialize(); + sua.AssocDB.initialize(); cout << "Finished initialising SUAL data\n "; return (0); } /* end of sua_initialisation */ diff --git a/sualibrary/sua/sua_syntax.cpp b/sualibrary/sua/sua_syntax.cpp index f7d67f4..2b5b755 100644 --- a/sualibrary/sua/sua_syntax.cpp +++ b/sualibrary/sua/sua_syntax.cpp @@ -15,7 +15,7 @@ * * ***************************************************************************/ /* - * $Id: sua_syntax.cpp,v 1.1.1.1 2002/02/04 14:30:41 p82609 Exp $ + * $Id: sua_syntax.cpp,v 1.2 2002/11/12 11:02:49 p82609 Exp $ * * SUA implementation according to SUA draft issue 8. * @@ -57,6 +57,7 @@ #include "sua_syntax.h" #include #include + using namespace std; /********************************************************************/ @@ -178,7 +179,7 @@ boolean encode_data (string& msg, string& data) { int pdu_index = msg.size(); msg.resize(pdu_index + 4); /* Encode tag */ - OVERLAY.dw[0] = htons(0x0003); + OVERLAY.dw[0] = htons(0x010b); msg[pdu_index] = OVERLAY.db[0]; pdu_index++; msg[pdu_index] = OVERLAY.db[1]; @@ -771,6 +772,29 @@ boolean encode_SCCP_cause (string& msg, SCCP_cause_struct cause) { return TRUE; } +boolean encode_credit (string& msg, uint32_t credit) { + /* Reserve 8 bytes for credit number */ + int pdu_index = msg.size(); + msg.resize(pdu_index + 8); + /* Encode tag */ + OVERLAY.dw[0] = htons(0x010A); + msg[pdu_index] = OVERLAY.db[0]; + pdu_index++; + msg[pdu_index] = OVERLAY.db[1]; + pdu_index++; + /* Encode length, always 8 bytes */ + OVERLAY.dw[1] = htons(8); + msg[pdu_index] = OVERLAY.db[2]; + pdu_index++; + msg[pdu_index] = OVERLAY.db[3]; + pdu_index++; + /* Encode value : 2 spare bytes, then received seq nr, more data flag and sent seq nr */ + OVERLAY.dq = htonl(credit); // fill in credit value + for(int i = 0; i < 4; i++) + msg[pdu_index + i] = OVERLAY.db[i]; + return TRUE; +} + boolean encode_seq_nr (string& msg, Sua_seq_nr_struct seq_nr) { /* Reserve 8 bytes for sequence number */ int pdu_index = msg.size(); @@ -1422,6 +1446,7 @@ boolean encode_co_conn_ack_msg (Sua_primitive_struct& prim, string& msg) { - Protocol class - Destination reference - Source reference + - sequence control Following parameters are optional : - Routing context - Destination address @@ -1471,6 +1496,16 @@ boolean encode_co_conn_ack_msg (Sua_primitive_struct& prim, string& msg) { return FALSE; } } + + if (prim.seq_control_pres && no_error) + no_error = encode_seq_ctrl (msg, prim.seq_control); + else { + if (no_error) { + /* Signal error : mandatory parameter missing */ + SYNTAX_ERR.error_text = "Encoding : Sequence Control parameter missing"; + return FALSE; + } + } if (prim.dest_addr_pres && no_error) no_error = encode_dest_addr (msg, prim.dest_addr); if (prim.importance_pres && no_error) @@ -3351,7 +3386,7 @@ boolean decode_cl_data_msg (Sua_primitive_struct& prim, string& msg) { OVERLAY.db[1] = msg[pdu_index + 1]; par_tag = ntohs(OVERLAY.dw[0]); switch (par_tag) { - case 0x0003 : + case 0x010b : if (!prim.data_pres) no_error = decode_data (prim, msg, pdu_index); else { @@ -3401,7 +3436,7 @@ boolean decode_cl_data_msg (Sua_primitive_struct& prim, string& msg) { return FALSE; } break; - case 0x0116 : /* tag may change, see SUA v9 */ + case 0x0116 : if (!prim.seq_control_pres) no_error = decode_seq_ctrl (prim, msg, pdu_index); else { @@ -3515,7 +3550,7 @@ boolean decode_cl_data_resp_msg (Sua_primitive_struct& prim, string& msg) { OVERLAY.db[1] = msg[pdu_index + 1]; par_tag = ntohs(OVERLAY.dw[0]); switch (par_tag) { - case 0x0003 : + case 0x010b : if (!prim.data_pres) no_error = decode_data (prim, msg, pdu_index); else { @@ -3650,7 +3685,7 @@ boolean decode_co_conn_req_msg (Sua_primitive_struct& prim, string& msg) { OVERLAY.db[1] = msg[pdu_index + 1]; par_tag = ntohs(OVERLAY.dw[0]); switch (par_tag) { - case 0x0003 : + case 0x010b : if (!prim.data_pres) no_error = decode_data (prim, msg, pdu_index); else { @@ -3793,7 +3828,7 @@ boolean decode_co_conn_ack_msg (Sua_primitive_struct& prim, string& msg) { OVERLAY.db[1] = msg[pdu_index + 1]; par_tag = ntohs(OVERLAY.dw[0]); switch (par_tag) { - case 0x0003 : + case 0x010b : if (!prim.data_pres) no_error = decode_data (prim, msg, pdu_index); else { @@ -3926,7 +3961,7 @@ boolean decode_co_conn_ref_msg (Sua_primitive_struct& prim, string& msg) { OVERLAY.db[1] = msg[pdu_index + 1]; par_tag = ntohs(OVERLAY.dw[0]); switch (par_tag) { - case 0x0003 : + case 0x010b : if (!prim.data_pres) no_error = decode_data (prim, msg, pdu_index); else { @@ -4042,7 +4077,7 @@ boolean decode_co_rel_req_msg (Sua_primitive_struct& prim, string& msg) { OVERLAY.db[1] = msg[pdu_index + 1]; par_tag = ntohs(OVERLAY.dw[0]); switch (par_tag) { - case 0x0003 : + case 0x010b : if (!prim.data_pres) no_error = decode_data (prim, msg, pdu_index); else { @@ -4254,7 +4289,7 @@ boolean decode_co_data_msg (Sua_primitive_struct& prim, string& msg) { OVERLAY.db[1] = msg[pdu_index + 1]; par_tag = ntohs(OVERLAY.dw[0]); switch (par_tag) { - case 0x0003 : + case 0x010b : if (!prim.data_pres) no_error = decode_data (prim, msg, pdu_index); else { diff --git a/sualibrary/sua/sua_tcb.cpp b/sualibrary/sua/sua_tcb.cpp index e896cb1..b4bb7b8 100644 --- a/sualibrary/sua/sua_tcb.cpp +++ b/sualibrary/sua/sua_tcb.cpp @@ -15,7 +15,7 @@ * * ***************************************************************************/ /* - * $Id: sua_tcb.cpp,v 1.1.1.1 2002/02/04 14:30:42 p82609 Exp $ + * $Id: sua_tcb.cpp,v 1.2 2002/10/24 16:12:06 p82609 Exp $ * * SUA implementation according to SUA draft issue 6. * @@ -97,6 +97,7 @@ void tcb_Sua_TCB_str::init_TCB_elem() Source_LR = 0; User_ref_id = 0; sctp_Association_id = 0; + scoc_tcb_id = 0; prcl_class = class0 ; return_option = FALSE; } diff --git a/sualibrary/sua/sua_tcb.h b/sualibrary/sua/sua_tcb.h index dd2ec60..ef9f0ce 100644 --- a/sualibrary/sua/sua_tcb.h +++ b/sualibrary/sua/sua_tcb.h @@ -15,7 +15,7 @@ * * ***************************************************************************/ /* - * $Id: sua_tcb.h,v 1.1.1.1 2002/02/04 14:30:42 p82609 Exp $ + * $Id: sua_tcb.h,v 1.2 2002/10/24 16:12:06 p82609 Exp $ * * SUA implementation according to SUA draft issue 6. * @@ -91,6 +91,7 @@ class tcb_Sua_TCB_str unsigned int Source_LR; unsigned int User_ref_id; unsigned int sctp_Association_id; + unsigned int scoc_tcb_id; protocol_class_set prcl_class; unsigned int seq_number; bool return_option; diff --git a/sualibrary/testup/Makefile.am b/sualibrary/testup/Makefile.am index d535bf8..27b0159 100644 --- a/sualibrary/testup/Makefile.am +++ b/sualibrary/testup/Makefile.am @@ -1,7 +1,4 @@ ####### kdevelop will overwrite this part!!! (begin)########## -noinst_LIBRARIES = libtestup.a - -libtestup_a_SOURCES = testuser.cpp main.cpp EXTRA_DIST = main.cpp testuser.cpp testuser.h @@ -13,8 +10,6 @@ testup_SOURCES = main.cpp testuser.cpp testuser.h #testup_LDADD = -L/usr/local/lib -lsua @glib_LIBS@ @sctp_LIBS@ testup_LDADD = ../sua/libsua.a @glib_LIBS@ @sctp_LIBS@ -INCLUDES = -I/usr/local/include -#the library path search path -#sualib_LDFLAGS = $(all_libraries) +INCLUDES = -I../sua -I/usr/local/include AUTOMAKE_OPTIONS = no-dependencies diff --git a/sualibrary/testup/main.cpp b/sualibrary/testup/main.cpp index c032d62..fbcd983 100644 --- a/sualibrary/testup/main.cpp +++ b/sualibrary/testup/main.cpp @@ -15,7 +15,7 @@ * * ***************************************************************************/ /* - * $Id: main.cpp,v 1.1.1.1 2002/02/04 14:30:42 p82609 Exp $ + * $Id: main.cpp,v 1.2 2002/10/15 14:37:59 p82609 Exp $ * * SUA Test user part implementation. * @@ -73,6 +73,15 @@ #include #include +#ifdef HAVE_SYS_POLL_H + #include +#else + #define POLLIN 0x001 + #define POLLPRI 0x002 + #define POLLOUT 0x004 + #define POLLERR 0x008 +#endif + using namespace std; char own_hostname[512]; @@ -290,10 +299,13 @@ int main(int argc, char **argv ) res = sua_associate(); // register sua and its users - sctp_registerUserCallback( fileno(stdin), - &testip_stdin_cb, - NULL - ); + res = sctp_registerUserCallback( fileno(stdin), + &testip_stdin_cb, + NULL, + POLLIN|POLLPRI + ); + + cout << "sctp_registerUserCallback result = "<< res << "\n"; init_testip_stdin(); diff --git a/sualibrary/testup/testuser.cpp b/sualibrary/testup/testuser.cpp index 2a9d69f..0d7facf 100644 --- a/sualibrary/testup/testuser.cpp +++ b/sualibrary/testup/testuser.cpp @@ -15,7 +15,7 @@ * * ***************************************************************************/ /* - * $Id: testuser.cpp,v 1.2 2002/02/15 16:20:29 p82609 Exp $ + * $Id: testuser.cpp,v 1.7 2002/11/14 15:29:24 p82609 Exp $ * * SUA Test user part implementation. * @@ -189,13 +189,17 @@ void init_testip_stdin() /***********************************************************************/ /* Test User Part : testip_stdin_cb */ /***********************************************************************/ -void testip_stdin_cb( int fd, - short int revents, - void *dummy +void testip_stdin_cb( int fd, + short int revents, + short int *gotevents, + void *dummy ) { int i,length; + unsigned int k, outstr_len; char readBuffer[256]; + char output_str[INET6_ADDRSTRLEN]; + const char *ptr; unsigned int xsxx; sccp_QOS_str udt_QOS, co_QOS; @@ -237,6 +241,12 @@ void testip_stdin_cb( int fd, /* exit program */ exit(0); } + else if (cmdline.find("term") != cmdline.npos) + { + /* add some cleanups */ + sua_shutdown(); + cout << "Closing down the SCTP & SUA associations\n"; + } else if ((cmdline.find("rep:") != cmdline.npos)) { cout << "Repeat sending CL/CO data to remote end every " << rep_timer << " sec\n"; @@ -254,15 +264,57 @@ void testip_stdin_cb( int fd, else if (cmdline.find("disp mngt") != cmdline.npos) { /* Display the management status of all SUA instances */ - cout << "| Association | SUA management status |\n"; - cout << "+-------------+-----------------------+\n"; + cout << "Display SUA administration and Mangagement data of all associations\n"; + cout << "|-------+--------+--------------------+--------------------+-----|\n"; + cout << "| Assoc | status | local IP addr | Remote IP addr | SSN |\n"; + cout << "|-------+--------+--------------------+--------------------+-----|\n"; i = 1; while ( SUA_PATH_NO_ERROR == sua_getPath(i,pathinfo) ) { - cout << "| " << i <<" | "<< pathinfo.ASP_status << " |\n"; + cout << "| " << i <<" | "<< pathinfo.ASP_status << " | "; + if (pathinfo.local_addr.pc.ipvx.sa.sa_family == AF_INET) + { /* ipv4 */ + ptr = inet_ntop( pathinfo.local_addr.pc.ipvx.sa.sa_family, + &pathinfo.local_addr.pc.ipvx.sin.sin_addr, + output_str, + sizeof(output_str) + ); + cout << output_str; + outstr_len = strlen(output_str); + for(k=0; k < (20 - 3 - outstr_len); k++) + cout << " "; + cout << "| "; + ptr = inet_ntop( pathinfo.remote_addr.pc.ipvx.sa.sa_family, + &pathinfo.remote_addr.pc.ipvx.sin.sin_addr, + output_str, + sizeof(output_str) + ); + cout << output_str; + for(k=0; k < /*(20 -*/ 3 /*- outstr_len)*/; k++) + cout << " "; + cout << "| "; + cout << pathinfo.remote_addr.ssn << " |\n"; + } + else + { /* ipv6 */ + ptr = inet_ntop( pathinfo.local_addr.pc.ipvx.sa.sa_family, + &pathinfo.local_addr.pc.ipvx.sin6.sin6_addr, + output_str, + sizeof(output_str) + ); + cout << output_str << " | "; + ptr = inet_ntop( pathinfo.remote_addr.pc.ipvx.sa.sa_family, + &pathinfo.remote_addr.pc.ipvx.sin6.sin6_addr, + output_str, + sizeof(output_str) + ); + cout << output_str << " | "; + cout << pathinfo.remote_addr.ssn << " |\n"; + } + i++; } - cout << "+-------------+-----------------------+\n"; + cout << "|-------+--------+--------------------+--------------------+-----|\n"; cout << "ASP status values: see sua_asp_mgnt.h\n"; } else if (cmdline.find("term") != cmdline.npos) @@ -333,7 +385,7 @@ void testip_stdin_cb( int fd, called_pty_addr.address_fields_present.ssn_port = ssn_present; called_pty_addr.address_fields_present.field_in_header = include_nothing; strcpy(called_pty_addr.name.HostName,addr_str.c_str()); - called_pty_addr.ssn = 255; + called_pty_addr.ssn = calling_pty_addr.ssn; called_pty_addr.routing_ind = route_on_name_gt; cout << "DNS/SUA dest hostname = " << addr_str << "\n"; @@ -345,7 +397,7 @@ void testip_stdin_cb( int fd, calling_pty_addr.address_fields_present.name_gt = hostname_present; strcpy(calling_pty_addr.name.HostName, own_hostname); - calling_pty_addr.ssn = 255; + calling_pty_addr.ssn = 5; calling_pty_addr.routing_ind = route_on_name_gt; cout << "DNS/SUA source hostname = " << addr2_str << "\n"; @@ -364,10 +416,10 @@ void testip_stdin_cb( int fd, called_pty_addr.address_fields_present.field_in_header = include_nothing; called_pty_addr.pc.ss7.ITU24.family = ITU24bit; called_pty_addr.pc.ss7.ITU24.pc = atoi(addr_char); - called_pty_addr.ssn = 255; + called_pty_addr.ssn = calling_pty_addr.ssn; called_pty_addr.routing_ind = route_on_ssn; - calling_pty_addr.ssn = 255; + calling_pty_addr.ssn = 5; calling_pty_addr.routing_ind = route_on_ssn; cout << "Address of remote end stored. Msg will be sent to this one\n"; @@ -448,8 +500,6 @@ void testip_stdin_cb( int fd, calling_pty_addr.address_fields_present.field_in_header = called_pty_addr.address_fields_present.field_in_header; string addr4_str = own_hostname; - /*char *name4_char = new char [addr4_str.length()+1]; */ - /*name4_char = shost_to_suaname ( addr4_str ); */ strcpy(calling_pty_addr.name.HostName, own_hostname); calling_pty_addr.pc.ipvx = pathinfo.local_addr.pc.ipvx; @@ -503,7 +553,8 @@ void timer_expired(unsigned int tID, sendcnt++; cout << "Send a PING\n"; doPingPong(Sua_ConnId); - timerID = sctp_startTimer( 10000, + timerID = sctp_startTimer( 10, /* seconds */ + 0, /* microseconds */ &timer_expired, NULL, NULL @@ -728,7 +779,8 @@ void ulp_ConnConfIndNotif( unsigned int local_sua_Id, // received the connection confirmed msg // this is the initiator of the connection // start a timer for sending the data to the responder - timerID = sctp_startTimer( 5000, + timerID = sctp_startTimer( 15, /* seconds */ + 0, /* microseconds */ &timer_expired, NULL, NULL diff --git a/sualibrary/testup/testuser.h b/sualibrary/testup/testuser.h index 3b9a7b8..105b018 100644 --- a/sualibrary/testup/testuser.h +++ b/sualibrary/testup/testuser.h @@ -15,7 +15,7 @@ * * ***************************************************************************/ /* - * $Id: testuser.h,v 1.1.1.1 2002/02/04 14:30:42 p82609 Exp $ + * $Id: testuser.h,v 1.2 2002/10/22 13:45:11 p82609 Exp $ * * SUA Test user part implementation. * @@ -77,9 +77,10 @@ using namespace std; void init_testip_stdin(void ); -void testip_stdin_cb( int fd, - short int revents, - void *dummy +void testip_stdin_cb( int fd, + short int revents, + short int *gotevents, + void *dummy );