aboutsummaryrefslogtreecommitdiffstats
path: root/sualibrary/sua/sua_co.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sualibrary/sua/sua_co.cpp')
-rw-r--r--sualibrary/sua/sua_co.cpp306
1 files changed, 124 insertions, 182 deletions
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