aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2010-07-09 20:56:56 +0200
committerHarald Welte <laforge@gnumonks.org>2010-07-09 20:56:56 +0200
commit7e7186ca00b33e9735c809ce200e310636006a22 (patch)
tree37ae4c48db5cfb2218830a7237a69ec787613f0b
parentacd8cf60130f88a4dd477dde5506faa4c142540c (diff)
update to sualibrary-0.1.1 from 2002-03-15:
* Contains Relaying functionality using hostnames. * Correct some bugs (multihoming....) * Compiles and runs on Linux, FreeBSD .... * Tested on IPv4 and IPV6 networks * interoperable with other SUA implementations * corresponds to sua draft v11 * requires SCTP implementation from www.sctp.de
-rw-r--r--sualibrary.kdevprj162
-rw-r--r--sualibrary/sua/sua_cl.cpp302
-rw-r--r--sualibrary/sua/sua_cl.h39
-rw-r--r--sualibrary/sua/sua_co.cpp306
-rw-r--r--sualibrary/sua/sua_database.h28
-rw-r--r--sualibrary/sua/sua_dataname.cpp6
-rw-r--r--sualibrary/sua/sua_datassoc.cpp288
-rw-r--r--sualibrary/sua/sua_debug.h6
8 files changed, 706 insertions, 431 deletions
diff --git a/sualibrary.kdevprj b/sualibrary.kdevprj
index 7f82109..5dbacfa 100644
--- a/sualibrary.kdevprj
+++ b/sualibrary.kdevprj
@@ -1,57 +1,57 @@
# KDE Config File
-[Workspace_1]
-openfiles=Untitled.h,Untitled.cpp,/home/p82609/siemens/sualibrary/sualibrary/docs/en/index.html,/home/p82609/siemens/sualibrary/sualibrary/docs/en/index-1.html,/home/p82609/siemens/sualibrary/sualibrary/docs/en/index-4.html,/home/p82609/siemens/sualibrary/sualibrary/docs/en/index-2.html,/home/p82609/siemens/sualibrary/sualibrary/docs/en/index-3.html,/home/p82609/siemens/sualibrary/sualibrary/docs/en/index-5.html,/home/p82609/siemens/sualibrary/sualibrary/docs/en/index-6.html,/home/p82609/siemens/sualibrary/sualibrary/docs/en/Makefile.in,/home/p82609/siemens/sualibrary/sualibrary/docs/en/index.sgml,
-show_outputview=true
-show_treeview=true
-header_file=/home/p82609/siemens/sualibrary/sualibrary/docs/en/index-4.html
-cpp_file=Untitled.cpp
-browser_file=file:/opt/kde/share/doc/HTML/default/kdevelop/reference/C/LIBRARIES/libraries.html
[sualibrary/docs/en/index-6.html]
install_location=
dist=true
install=false
type=DATA
-[sualibrary/sua/sua_logging.h]
+[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
-type=HEADER
-[sualibrary/sua/sua_logging.cpp]
+type=DATA
+[sualibrary/sua/sua_adapt.cpp]
install_location=
dist=true
install=false
type=SOURCE
-[sualibrary/sua/sua_adapt.cpp]
+[sualibrary/sua/sua_logging.cpp]
install_location=
dist=true
install=false
type=SOURCE
-[COPYING]
+[sualibrary/sua/sua_logging.h]
install_location=
dist=true
install=false
-type=DATA
+type=HEADER
[sualibrary/sua/sua_database.h]
install_location=
dist=true
install=false
type=HEADER
-[sualibrary/sua/sua_tcb.h]
+[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.h]
+[sualibrary/sua/sua_tcb.h]
install_location=
dist=true
install=false
type=HEADER
-[Config for BinMakefileAm]
-ldflags=
-addcxxflags=
-ldadd=
-bin_program=sualibrary
-cxxflags=-O0 -g3 -Wall
[sualibrary/testup/main.cpp]
install_location=
dist=true
@@ -62,22 +62,22 @@ install_location=
dist=true
install=false
type=DATA
-[sualibrary/sua/sua_file.h]
+[sualibrary/sua/sua_asp_mgnt.h]
install_location=
dist=true
install=false
type=HEADER
-[sualibrary/sua/sua_asp_mgnt.h]
+[sualibrary/sua/sua_file.h]
install_location=
dist=true
install=false
type=HEADER
-[sualibrary.kdevprj]
+[sualibrary/docs/en/index-1.html]
install_location=
dist=true
install=false
type=DATA
-[sualibrary/docs/en/index-1.html]
+[sualibrary.kdevprj]
install_location=
dist=true
install=false
@@ -93,21 +93,26 @@ 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/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,
-type=normal
-sub_dirs=
[sualibrary/docs/en/index.html]
install_location=
dist=true
install=false
type=DATA
-[sualibrary/sua/sua_file.cpp]
+[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
@@ -117,22 +122,22 @@ install_location=
dist=true
install=false
type=SOURCE
-[sualibrary/sua/sua_asp_mgnt.cpp]
+[sualibrary/sua/sua_file.cpp]
install_location=
dist=true
install=false
type=SOURCE
-[sualibrary/docs/en/index-3.html]
+[sualibrary/testup/assoc.sua]
install_location=
-dist=true
+dist=false
install=false
type=DATA
[sualibrary/docs/Makefile.am]
-type=normal
sub_dirs=en,
-[sualibrary/testup/assoc.sua]
+type=normal
+[sualibrary/docs/en/index-4.html]
install_location=
-dist=false
+dist=true
install=false
type=DATA
[sualibrary/sua/sua_distribution.h]
@@ -140,35 +145,30 @@ install_location=
dist=true
install=false
type=HEADER
-[sualibrary/docs/en/index-4.html]
+[sualibrary/sua/sua_syntax.cpp]
install_location=
dist=true
install=false
-type=DATA
+type=SOURCE
[sualibrary/testup/testuser.h]
install_location=
dist=true
install=false
type=HEADER
-[sualibrary/sua/sua_syntax.cpp]
-install_location=
-dist=true
-install=false
-type=SOURCE
-[sualibrary/sua/sua_tcb.cpp]
+[sualibrary.lsm]
install_location=
dist=true
install=false
-type=SOURCE
+type=DATA
[sualibrary/Makefile.am]
files=
-type=prog_main
sub_dirs=docs,sua,testup,
-[sualibrary.lsm]
+type=prog_main
+[sualibrary/sua/sua_tcb.cpp]
install_location=
dist=true
install=false
-type=DATA
+type=SOURCE
[sualibrary/docs/en/index-5.html]
install_location=
dist=true
@@ -179,83 +179,87 @@ install_location=
dist=true
install=false
type=SOURCE
-[sualibrary/sua/sua_cl.cpp]
+[ChangeLog]
install_location=
dist=true
install=false
-type=SOURCE
-[ChangeLog]
+type=DATA
+[sualibrary/sua/sua_cl.cpp]
install_location=
dist=true
install=false
-type=DATA
+type=SOURCE
[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
-project_type=normal_cpp
author=Lode Coene
+project_type=normal_cpp
sub_dir=sualibrary/
lfv_open_groups=
workspace=1
-project_name=Sualibrary
version=0.1
-AMChanged=true
+project_name=Sualibrary
+AMChanged=false
sgml_file=/home/p82609/sualibrary/sualibrary/docs/en/index.sgml
short_info=,
email=lode.coene@siemens.atea.be
kdevprj_version=1.2
configure_args=
modifyMakefiles=true
-[INSTALL]
+[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
-[TODO]
+[INSTALL]
install_location=
dist=true
install=false
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,
-type=static_library
[sualibrary/sua/sua_syntax.h]
install_location=
dist=true
install=false
type=HEADER
-[sualibrary/sua/sua_co.h]
-install_location=
-dist=true
-install=false
-type=HEADER
[sualibrary/testup/local.sua]
install_location=local.sua
dist=false
install=false
type=DATA
-[sualibrary/testup/testuser.cpp]
+[sualibrary/sua/sua_co.h]
install_location=
dist=true
install=false
-type=SOURCE
-[sualibrary/sua/sua_database.cpp]
+type=HEADER
+[sualibrary/sua/sua_adapt.h]
install_location=
dist=true
install=false
-type=SOURCE
+type=HEADER
[sualibrary/sua/sua_co.cpp]
install_location=
dist=true
install=false
type=SOURCE
-[sualibrary/sua/sua_adapt.h]
+[sualibrary/sua/sua_database.cpp]
install_location=
dist=true
install=false
-type=HEADER
-[sualibrary/sua/sua_sual.h]
+type=SOURCE
+[sualibrary/testup/testuser.cpp]
+install_location=
+dist=true
+install=false
+type=SOURCE
+[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=
dist=true
install=false
@@ -265,24 +269,20 @@ install_location=
dist=true
install=false
type=SOURCE
-[sualibrary/sua/sua_cl.h]
+[sualibrary/sua/sua_sual.h]
install_location=
dist=true
install=false
type=HEADER
-[Makefile.am]
-files=sualibrary.kdevprj,AUTHORS,COPYING,ChangeLog,INSTALL,README,TODO,sualibrary.lsm,
-type=normal
-sub_dirs=sualibrary,
-[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,
-sub_dirs=
-type=static_library
[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=
dist=true
diff --git a/sualibrary/sua/sua_cl.cpp b/sualibrary/sua/sua_cl.cpp
index 4ec0bb7..10eaf6e 100644
--- a/sualibrary/sua/sua_cl.cpp
+++ b/sualibrary/sua/sua_cl.cpp
@@ -15,7 +15,7 @@
* *
***************************************************************************/
/*
- * $Id: sua_cl.cpp,v 1.1.1.1 2002/02/04 14:30:41 p82609 Exp $
+ * $Id: sua_cl.cpp,v 1.3 2002/03/01 12:57:38 p82609 Exp $
*
* SUA implementation according to SUA draft issue 6.
*
@@ -48,7 +48,9 @@
* inspiration : Dorothee
* "Always admire the local beauties in their natural enviroment."
*
- * Purpose: This code-file defines the SUA connectionless message handling:
+ * Purpose: This code-file defines the SUA connectionless message handling:
+ * - 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)
* - Process a Unitdata msg
@@ -92,24 +94,180 @@ extern tcb_Sua_msgqueue_pool msg_store;
// import the received msg pool
extern vector<sua_save_str> rec_msg_pool;
+
+/***********************************************************************/
+/* sua_send_Message */
+/***********************************************************************/
+int sua_send_Message( signed int sctp_assoc_id,
+ short int sctp_stream_id,
+ int sctp_delivery_type,
+ unsigned int sctp_loadshare,
+ char *databuf,
+ unsigned int datalen
+ )
+{
+ signed int result;
+ /* send data to SCTP */
+ /* yes it does, continue, no problem, send the msg */
+#ifdef DEBUG
+ /* display byte array */
+ display_byte_array(databuf , datalen);
+#endif
+ char logstring[100];
+ sprintf(logstring, "SUA encoded message, ready for being send to SCTP assoc %d", 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
+ );
+
+
+#ifdef DEBUG
+ cout << "sua_cl.c:result sctp send = "<< result << "\n";
+ printf( "%d \n", result);
+#endif
+
+ 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 */
/***********************************************************************/
-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_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;
+ int error_value = 0;
int string_size, datalen;
signed int sctp_assoc_id;
- unsigned int sua_assoc_id;
- short stream_id = 0;
- int delivery_type, result;
+ 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
@@ -134,14 +292,14 @@ int sua_send_Unitdata(sccp_QOS_str &QOS,
msg.sua_prim.prot_class.pcl = prot_class_0;
msg.sua_prim.seq_control_pres = TRUE;
msg.sua_prim.seq_control = QOS.sequence_number;
- delivery_type = SCTP_UNORDERED_DELIVERY;
+ sctp_delivery_type = SCTP_UNORDERED_DELIVERY;
break;
case(class1):
msg.sua_prim.prot_class_pres = TRUE;
msg.sua_prim.prot_class.pcl = prot_class_1;
msg.sua_prim.seq_control_pres = TRUE;
msg.sua_prim.seq_control = QOS.sequence_number;
- delivery_type = SCTP_ORDERED_DELIVERY;
+ sctp_delivery_type = SCTP_ORDERED_DELIVERY;
break;
default:
return(PROTOCOL_CLASS_NOT_SPECIFIED);
@@ -297,46 +455,35 @@ int sua_send_Unitdata(sccp_QOS_str &QOS,
cout << "call routing function\n";
#endif
sctp_assoc_id = Assoc_sua.route_msg( called_pty_address,
- calling_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)
{
- // send data to SCTP
- 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();
- /* 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_cl.c",logstring);
- log_byte_array("sua_cl.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;
+ 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)
{
@@ -361,12 +508,12 @@ int sua_send_Unitdata(sccp_QOS_str &QOS,
/* - save the msg till the association is setup or */
/* association setup fails -> drop saved msg */
sua_msg.byte = msg.sua_msg;
- sua_msg.delivery_type = delivery_type;
- sua_msg.stream_id = stream_id;
+ sua_msg.delivery_type = sctp_delivery_type;
+ 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;
}
@@ -385,8 +532,9 @@ short process_unitdata_msg ( int local_sua_id,
Sua_container &msg
)
{
-
sua_save_str temp;
+ int result = 0;
+ int sctp_assoc_id = 0;
temp.primitive = N_UNITDATA;
temp.user_ref = 0;
@@ -435,7 +583,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 = ITU24bit;
+ 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.pc = msg.sua_prim.source_addr.pc;
}
if (msg.sua_prim.source_addr.gt_pres == TRUE)
@@ -483,11 +631,25 @@ short process_unitdata_msg ( int local_sua_id,
// 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 = Assoc_sua.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;
+ }
+ }
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 = Assoc_sua.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)
@@ -525,19 +687,33 @@ short process_unitdata_msg ( int local_sua_id,
temp.userdata = msg.sua_prim.data_string;
else
cout << "sua_cl.c: no sua user data in unitdata 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_ClDataIndNotif
- ( local_sua_id,
- N_UNITDATA,
- temp.userdata.length()
- );
+ /* 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()
+ );
+ }
+ 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);
}
diff --git a/sualibrary/sua/sua_cl.h b/sualibrary/sua/sua_cl.h
index 6c32df3..ed9bdc7 100644
--- a/sualibrary/sua/sua_cl.h
+++ b/sualibrary/sua/sua_cl.h
@@ -15,7 +15,7 @@
* *
***************************************************************************/
/*
- * $Id: sua_cl.h,v 1.1.1.1 2002/02/04 14:30:41 p82609 Exp $
+ * $Id: sua_cl.h,v 1.2 2002/03/01 12:57:38 p82609 Exp $
*
* SUA implementation according to SUA draft issue 6.
*
@@ -44,7 +44,9 @@
* Contact: gery.verwimp@siemens.atea.be
* lode.coene@siemens.atea.be
*
- * Purpose: This header-file defines the SUA connectionless message handling:
+ * Purpose: This header-file defines the SUA connectionless message handling:
+ * - 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)
* - Process a Unitdata msg
@@ -69,17 +71,32 @@
using namespace std;
-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_Message( signed int sctp_assoc_id,
+ short int sctp_stream_id,
+ int sctp_delivery_type,
+ unsigned int sctp_loadshare,
+ char *databuf,
+ unsigned int datalen
+ );
+
+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 sua_send_Unitdata( sccp_QOS_str &QOS,
+ sccp_addr_str &called_pty_address,
+ sccp_addr_str &calling_pty_address,
+ char *buffer,
+ unsigned int len
+ );
short process_unitdata_msg ( int local_sua_id,
- unsigned int sua_assoc_id,
- Sua_container &sua_msg
- );
+ unsigned int sua_assoc_id,
+ Sua_container &sua_msg
+ );
#endif // SUA_CL_H
diff --git a/sualibrary/sua/sua_co.cpp b/sualibrary/sua/sua_co.cpp
index 0b08a1f..cdfbbaa 100644
--- a/sualibrary/sua/sua_co.cpp
+++ b/sualibrary/sua/sua_co.cpp
@@ -15,7 +15,7 @@
* *
***************************************************************************/
/*
- * $Id: sua_co.cpp,v 1.1.1.1 2002/02/04 14:30:41 p82609 Exp $
+ * $Id: sua_co.cpp,v 1.2 2002/03/01 12:57:38 p82609 Exp $
*
* SUA implementation according to SUA draft issue 6.
*
@@ -70,7 +70,7 @@
#include "sua_distribution.h"
#include "sua_logging.h"
#include "sua_tcb.h"
-
+#include "sua_cl.h"
#ifdef LINUX
#include <unistd.h>
@@ -122,9 +122,10 @@ int sua_send_CORE( sccp_QOS_str &QOS,
int error_value;
int string_size, datalen;
signed int SCTP_assoc_id;
- unsigned int sua_assoc_id;
- short stream_id = 0;
- int delivery_type, result;
+ 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;
@@ -150,7 +151,7 @@ int sua_send_CORE( sccp_QOS_str &QOS,
msg.sua_prim.prot_class.pcl = prot_class_2;
msg.sua_prim.seq_control_pres = TRUE;
msg.sua_prim.seq_control = 1;
- delivery_type = SCTP_UNORDERED_DELIVERY;
+ sctp_delivery_type = SCTP_UNORDERED_DELIVERY;
break;
case(class3):
return(PROTOCOL_CLASS_NOT_SPECIFIED);
@@ -320,10 +321,11 @@ int sua_send_CORE( sccp_QOS_str &QOS,
cout << "call routing function\n";
#endif
SCTP_assoc_id = Assoc_sua.route_msg( called_pty_address,
- calling_pty_address
- );
+ calling_pty_address,
+ sua_assoc_id
+ );
#ifdef DEBUG
- cout << "routed to SCTP assoc " << SCTP_assoc_id << "\n";
+ cout << "routed to SCTP assoc " << SCTP_assoc_id << "/SUA association " << sua_assoc_id << "\n";
#endif
// fill in the TCB
@@ -337,35 +339,24 @@ int sua_send_CORE( sccp_QOS_str &QOS,
/* does association exist? */
if (SCTP_assoc_id > 0)
{
- // send data to SCTP
- 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;
+ error_value = 0;
- /* 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_co.c",logstring);
- log_byte_array("sua_co.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_co.c:result sctp send = "<< result << "\n";
#endif
@@ -395,8 +386,8 @@ int sua_send_CORE( sccp_QOS_str &QOS,
/* - save the msg till the association is setup or */
/* association setup fails -> drop saved msg */
sua_msg.byte = msg.sua_msg;
- sua_msg.delivery_type = delivery_type;
- sua_msg.stream_id = stream_id;
+ sua_msg.delivery_type = sctp_delivery_type;
+ sua_msg.stream_id = sctp_stream_id;
sua_msg.valid = true;
msg_store.add_msg ( sua_assoc_id,
sua_msg
@@ -425,8 +416,9 @@ int sua_send_CORESP( sccp_QOS_str &QOS,
unsigned int SCTP_assoc_id;
unsigned int sua_assoc_id;
unsigned int local_sua_id,remote_sua_id;
- short stream_id = 0;
- int delivery_type, result = 0;
+ signed int sctp_loadshare = SCTP_USE_PRIMARY;
+ short sctp_stream_id = 0;
+ int sctp_delivery_type, result = 0;
// init the message
msg.sua_init();
@@ -450,7 +442,7 @@ int sua_send_CORESP( sccp_QOS_str &QOS,
msg.sua_prim.prot_class.pcl = prot_class_2;
msg.sua_prim.seq_control_pres = TRUE;
msg.sua_prim.seq_control = tcb_ptr->seq_number ;
- delivery_type = SCTP_UNORDERED_DELIVERY;
+ sctp_delivery_type = SCTP_UNORDERED_DELIVERY;
break;
case(class3):
return(PROTOCOL_CLASS_NOT_SPECIFIED);
@@ -508,35 +500,24 @@ int sua_send_CORESP( sccp_QOS_str &QOS,
if (Assoc_sua.instance[sua_assoc_id].asp.status == asp_active)
{
#endif
- // send data to SCTP
- 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();
-
-#ifdef DEBUG
- // display byte array
- display_byte_array(databuf , msg.sua_msg.length());
-#endif
+
+ // send data to SCTP
+ result = sua_send_Message( SCTP_assoc_id,
+ sctp_stream_id,
+ sctp_delivery_type,
+ sctp_loadshare,
+ databuf,
+ datalen
+ );
+
+ delete databuf;
+ error_value = 0;
- char logstring[100];
- sprintf(logstring, "SUA encoded message, ready for being send to SCTP assoc %d", SCTP_assoc_id);
- event_log("sua_co.c",logstring);
- log_byte_array("sua_co.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 SUA_MANAGEMENT
}
else
@@ -572,8 +553,9 @@ int sua_send_CODATA( sccp_QOS_str &QOS,
unsigned int SCTP_assoc_id;
unsigned int sua_assoc_id;
unsigned int local_sua_id,remote_sua_id;
- short stream_id = 0;
- int delivery_type, result = 0;
+ signed int sctp_loadshare = SCTP_USE_PRIMARY;
+ short sctp_stream_id = 0;
+ int sctp_delivery_type, result = 0;
// init the message
@@ -598,7 +580,7 @@ int sua_send_CODATA( sccp_QOS_str &QOS,
msg.sua_prim.prot_class.pcl = prot_class_2;
msg.sua_prim.seq_control_pres = TRUE;
msg.sua_prim.seq_control = tcb_ptr->seq_number ;
- delivery_type = SCTP_UNORDERED_DELIVERY;
+ sctp_delivery_type = SCTP_UNORDERED_DELIVERY;
break;
case(class3):
return(PROTOCOL_CLASS_NOT_SPECIFIED);
@@ -650,35 +632,25 @@ int sua_send_CODATA( sccp_QOS_str &QOS,
if (Assoc_sua.instance[sua_assoc_id].asp.status == asp_active)
{
#endif
- // send data to SCTP
- 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();
-
-#ifdef DEBUG
- // display byte array
- display_byte_array(databuf , msg.sua_msg.length());
-#endif
+
+ // send data to SCTP
+ result = sua_send_Message( SCTP_assoc_id,
+ sctp_stream_id,
+ sctp_delivery_type,
+ sctp_loadshare,
+ databuf,
+ datalen
+ );
+
+ delete databuf;
+ error_value = 0;
+
- char logstring[100];
- sprintf(logstring, "SUA encoded message, ready for being send to SCTP assoc %d", SCTP_assoc_id);
- event_log("sua_co.c",logstring);
- log_byte_array("sua_co.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 SUA_MANAGEMENT
}
else
@@ -714,8 +686,9 @@ int sua_send_CORELRQ( sccp_QOS_str &QOS,
unsigned int SCTP_assoc_id;
unsigned int sua_assoc_id;
unsigned int local_sua_id,remote_sua_id;
- short stream_id = 0;
- int delivery_type, result = 0;
+ signed int sctp_loadshare = SCTP_USE_PRIMARY;
+ short sctp_stream_id = 0;
+ int sctp_delivery_type, result = 0;
// init the message
@@ -740,7 +713,7 @@ int sua_send_CORELRQ( sccp_QOS_str &QOS,
msg.sua_prim.prot_class.pcl = prot_class_2;
msg.sua_prim.seq_control_pres = TRUE;
msg.sua_prim.seq_control = tcb_ptr->seq_number ;
- delivery_type = SCTP_UNORDERED_DELIVERY;
+ sctp_delivery_type = SCTP_UNORDERED_DELIVERY;
break;
case(class3):
return(PROTOCOL_CLASS_NOT_SPECIFIED);
@@ -797,35 +770,24 @@ int sua_send_CORELRQ( sccp_QOS_str &QOS,
if (Assoc_sua.instance[sua_assoc_id].asp.status == asp_active)
{
#endif
- // send data to SCTP
- 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();
-#ifdef DEBUG
- // display byte array
- display_byte_array(databuf , msg.sua_msg.length());
-#endif
+ 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;
+ error_value = 0;
- char logstring[100];
- sprintf(logstring, "SUA encoded message, ready for being send to SCTP assoc %d", SCTP_assoc_id);
- event_log("sua_co.c",logstring);
- log_byte_array("sua_co.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 SUA_MANAGEMENT
}
else
@@ -861,8 +823,9 @@ int sua_send_CORELCO( sccp_QOS_str &QOS,
unsigned int SCTP_assoc_id;
unsigned int sua_assoc_id;
unsigned int local_sua_id,remote_sua_id;
- short stream_id = 0;
- int delivery_type, result = 0;
+ signed int sctp_loadshare = SCTP_USE_PRIMARY;
+ short sctp_stream_id = 0;
+ int sctp_delivery_type, result = 0;
// init the message
@@ -887,7 +850,7 @@ int sua_send_CORELCO( sccp_QOS_str &QOS,
msg.sua_prim.prot_class.pcl = prot_class_2;
msg.sua_prim.seq_control_pres = TRUE;
msg.sua_prim.seq_control = tcb_ptr->seq_number ;
- delivery_type = SCTP_UNORDERED_DELIVERY;
+ sctp_delivery_type = SCTP_UNORDERED_DELIVERY;
break;
case(class3):
return(PROTOCOL_CLASS_NOT_SPECIFIED);
@@ -940,35 +903,24 @@ int sua_send_CORELCO( sccp_QOS_str &QOS,
if (Assoc_sua.instance[sua_assoc_id].asp.status == asp_active)
{
#endif
- // send data to SCTP
- 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();
-
-#ifdef DEBUG
- // display byte array
- display_byte_array(databuf , msg.sua_msg.length());
-#endif
+
+ // send data to SCTP
+ result = sua_send_Message( SCTP_assoc_id,
+ sctp_stream_id,
+ sctp_delivery_type,
+ sctp_loadshare,
+ databuf,
+ datalen
+ );
+
+ delete databuf;
+ error_value = 0;
- char logstring[100];
- sprintf(logstring, "SUA encoded message, ready for being send to SCTP assoc %d", SCTP_assoc_id);
- event_log("sua_co.c",logstring);
- log_byte_array("sua_co.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 SUA_MANAGEMENT
}
else
@@ -1007,8 +959,9 @@ int sua_send_COREF( sccp_QOS_str &QOS,
unsigned int SCTP_assoc_id;
unsigned int sua_assoc_id;
unsigned int local_sua_id,remote_sua_id;
- short stream_id = 0;
- int delivery_type, result = 0;
+ signed int sctp_loadshare = SCTP_USE_PRIMARY;
+ short sctp_stream_id = 0;
+ int sctp_delivery_type, result = 0;
sccp_addr_str called_pty_address;
// init the message
@@ -1033,7 +986,7 @@ int sua_send_COREF( sccp_QOS_str &QOS,
msg.sua_prim.prot_class.pcl = prot_class_2;
msg.sua_prim.seq_control_pres = TRUE;
msg.sua_prim.seq_control = tcb_ptr->seq_number ;
- delivery_type = SCTP_UNORDERED_DELIVERY;
+ sctp_delivery_type = SCTP_UNORDERED_DELIVERY;
break;
case(class3):
return(PROTOCOL_CLASS_NOT_SPECIFIED);
@@ -1125,35 +1078,24 @@ int sua_send_COREF( sccp_QOS_str &QOS,
if (Assoc_sua.instance[sua_assoc_id].asp.status == asp_active)
{
#endif
- // send data to SCTP
- 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();
-#ifdef DEBUG
- // display byte array
- display_byte_array(databuf , msg.sua_msg.length());
-#endif
+ 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;
+ error_value = 0;
- char logstring[100];
- sprintf(logstring, "SUA encoded message, ready for being send to SCTP assoc %d", SCTP_assoc_id);
- event_log("sua_co.c",logstring);
- log_byte_array("sua_co.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 SUA_MANAGEMENT
}
else
diff --git a/sualibrary/sua/sua_database.h b/sualibrary/sua/sua_database.h
index 9b2005a..7fce372 100644
--- a/sualibrary/sua/sua_database.h
+++ b/sualibrary/sua/sua_database.h
@@ -15,7 +15,7 @@
* *
***************************************************************************/
/*
- * $Id: sua_database.h,v 1.2 2002/02/07 16:34:27 p82609 Exp $
+ * $Id: sua_database.h,v 1.4 2002/03/01 12:57:38 p82609 Exp $
*
* SUA implementation according to SUA draft issue 8.
*
@@ -317,23 +317,27 @@ class db_Sua_AssociationList{
);
short Terminate_remote_assoc_instance();
short shutdown();
- signed int route_msg(sccp_addr_str& cld,
- sccp_addr_str& clg
- );
+ 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
);
signed int route_on_SS7pc ( SS7union& dest_pc,
- SS7union& org_pc,
- int& sua_assoc_id
- );
+ 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
- );
+ hostname_str& org_name,
+ int& sua_assoc_id,
+ pointcode_str& dest_pc,
+ pointcode_str& org_pc
+ );
void increase_instance();
bool activate( unsigned int sua_id,
short mode
diff --git a/sualibrary/sua/sua_dataname.cpp b/sualibrary/sua/sua_dataname.cpp
index b1e6914..f71a1ee 100644
--- a/sualibrary/sua/sua_dataname.cpp
+++ b/sualibrary/sua/sua_dataname.cpp
@@ -15,7 +15,7 @@
* *
***************************************************************************/
/*
- * $Id: sua_dataname.cpp,v 1.1.1.1 2002/02/04 14:30:41 p82609 Exp $
+ * $Id: sua_dataname.cpp,v 1.2 2002/03/01 12:57:38 p82609 Exp $
*
* SUA implementation according to SUA draft issue 6.
*
@@ -104,6 +104,9 @@ void db_Sua_NameList::initialize(){
}
}
+/***********************************************************************/
+/* Sua_NameList::read_host_name */
+/***********************************************************************/
string db_Sua_NameList::read_host_name(string name){
char *hostname;
@@ -165,6 +168,7 @@ string db_Sua_NameList::read_host_name(string name){
}
+
// end of module sua_dataname.c
diff --git a/sualibrary/sua/sua_datassoc.cpp b/sualibrary/sua/sua_datassoc.cpp
index c3bcc5f..dd29625 100644
--- a/sualibrary/sua/sua_datassoc.cpp
+++ b/sualibrary/sua/sua_datassoc.cpp
@@ -15,7 +15,7 @@
* *
***************************************************************************/
/*
- * $Id: sua_datassoc.cpp,v 1.3 2002/02/15 16:19:46 p82609 Exp $
+ * $Id: sua_datassoc.cpp,v 1.6 2002/03/15 12:53:53 p82609 Exp $
*
* SUA implementation according to SUA draft issue 6.
*
@@ -70,6 +70,7 @@
* - route on IP pointcode address
* - route on Global Title/Hostname
* - route message to a association
+ * - Final destination?
* - increase instance
* - Dynamic association setup(initiating)
*/
@@ -240,6 +241,66 @@ void db_Sua_AssociationList:: read_stream_number(string stream_num){
}
/***********************************************************************/
+/* db_Sua_AssociationList::resolve_host_name */
+/***********************************************************************/
+signed int db_Sua_AssociationList::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);
+};
+
+/***********************************************************************/
/* Sua_AssociationList::register_instance */
/***********************************************************************/
short db_Sua_AssociationList::
@@ -390,28 +451,125 @@ Find_association( unsigned int sctp_assoc_id,
/***********************************************************************/
unsigned int db_Sua_AssociationList::
Find_local_sua( sccp_addr_str& local_address
- )
+ )
{
- short i = 1, j = 0;
- unsigned int Local_sua_id = 0;
- bool result = FALSE;
+ 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) ||
+ {
+ /*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 (result)
- {
- Local_sua_id = instance[i].local_sua_id;
+*/
+ 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 << "local_sua_id = " << Local_sua_id << " , instance "<< i << "\n";
+ cout << "Find_local_sua: local_sua_id = " << Local_sua_id << " , instance "<< i << "\n";
#endif
- }
- j++;
- }
+ }
+ j++;
+ }
i++;
}
@@ -431,6 +589,7 @@ passive_associate( unsigned int assoc_id,
){
SCTP_AssociationStatus status;
+ SCTP_Path_Status path_x_status;
int result;
short k;
int bla;
@@ -471,13 +630,21 @@ passive_associate( unsigned int assoc_id,
event_log("sua_database.c",logstring);
- result = sctp_getAssocStatus(instance[assoc_instance_idx].SCTP_assoc_id, &status);
+ result = sctp_getAssocStatus( instance[assoc_instance_idx].SCTP_assoc_id,
+ &status
+ );
/* conversion and fill in the destination address */
instance[assoc_instance_idx].Dest.nr_of_addrs = nr_of_dest_addr;
- instance[assoc_instance_idx].Dest.address_string[0] = status.primaryDestinationAddress;
- instance[assoc_instance_idx].Dest.addrs[0].sin.sin_port = status.destPort;
-
+ 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;
+ }
/* 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;
@@ -692,72 +859,36 @@ route_on_SS7pc ( SS7union& dest_pc,
/***********************************************************************/
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
- )
+ hostname_str& org_name,
+ int& sua_assoc_id,
+ pointcode_str& dest_pc,
+ pointcode_str& org_pc
+ )
{
- struct hostent *hptr;
- char **pptr;
- unsigned int sctp_assoc_id = 0;
- char str[INET6_ADDRSTRLEN];
- char *dest_carr;
+ 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) */
- 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;
- org_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 IP address, look if association already exists */
- 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 route_on_GTname: Unknown IP addresstype\n";
+ 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
- );
+ sctp_assoc_id = route_on_IPpc( dest_pc.ipvx,
+ org_pc.ipvx,
+ sua_assoc_id
+ );
- if (sctp_assoc_id != 0 )
- return(sctp_assoc_id);
+ if (sctp_assoc_id != 0 )
+ return(sctp_assoc_id);
- }
return(sctp_assoc_id);
};
@@ -766,12 +897,14 @@ route_on_GTname ( hostname_str& dest_name,
/* Sua_AssociationList::route_msg */
/***********************************************************************/
signed int db_Sua_AssociationList::
-route_msg( sccp_addr_str& cld,
- sccp_addr_str& clg
+route_msg( sccp_addr_str& cld,
+ sccp_addr_str& clg,
+ int& sua_assoc_id
){
unsigned int sctp_assoc_id = 0;
- int sua_assoc_id = 0;
+
+ sua_assoc_id = 0;
#ifdef DEBUG
cout << "num_of_instance : "<< num_of_instance << "\n";
@@ -837,7 +970,6 @@ route_msg( sccp_addr_str& cld,
return(sctp_assoc_id);
};
-
/***********************************************************************/
/* Sua_AssociationList::increase_instance */
/***********************************************************************/
diff --git a/sualibrary/sua/sua_debug.h b/sualibrary/sua/sua_debug.h
index a4e3d83..9d0bf9b 100644
--- a/sualibrary/sua/sua_debug.h
+++ b/sualibrary/sua/sua_debug.h
@@ -15,7 +15,7 @@
* *
***************************************************************************/
/*
- * $Id: sua_debug.h,v 1.1.1.1 2002/02/04 14:30:41 p82609 Exp $
+ * $Id: sua_debug.h,v 1.2 2002/02/22 16:12:11 p82609 Exp $
*
* SUA implementation according to SUA draft issue 6.
*
@@ -57,8 +57,8 @@
#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 */