@ -15,7 +15,7 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* $ Id : sua_asp_mgnt . cpp , v 1.1 2003 / 01 / 14 14 : 15 : 36 p82609 Exp $
* $ Id : sua_asp_mgnt . cpp , v 1.2 2003 / 09 / 09 08 : 43 : 25 p82609 Exp $
*
* SUA implementation according to SUA draft issue 6.
*
@ -59,6 +59,7 @@
* - send a ASP - ACTIVE msg to remote node
* - send a ASP - ACTIVE ACKnowledge msg to remote node
* - send a ASP - INactive Acknowledge msg to remote node
* - send a NOTIFY msg to remote node
* - Receive / process ASP UP msg
* - Receive / process ASP UP ACKnowladge msg
* - Receive / process ASP DOWN msg
@ -94,7 +95,9 @@ extern tcb_Sua_msgqueue_pool msg_store;
/***********************************************************************/
/* sua_send_ASPUP */
/***********************************************************************/
int sua_send_ASPUP ( unsigned int Sua_assoc_id
int sua_send_ASPUP ( unsigned int Sua_assoc_id ,
boolean ASP_id_pres ,
uint32_t ASP_id
)
{
Sua_container msg ;
@ -111,8 +114,10 @@ int sua_send_ASPUP( unsigned int Sua_assoc_id
// fill in the main sua header
msg . sua_prim . hdr_msg_class = sua_aspsm ;
msg . sua_prim . hdr_msg_type . aspsm = aspsm_up ;
msg . sua_prim . ASP_id_pres = TRUE ;
msg . sua_prim . ASP_id = 1 ;
msg . sua_prim . ASP_id_pres = ASP_id_pres ;
if ( ASP_id_pres )
msg . sua_prim . ASP_id = ASP_id ;
msg . sua_prim . asp_cap_pres = FALSE ;
msg . sua_prim . info_pres = FALSE ;
@ -165,7 +170,7 @@ int sua_send_ASPUP( unsigned int Sua_assoc_id
}
/***********************************************************************/
/* sua_send_ASPUP_ACK */
/* sua_send_ASPUP_ACK */
/***********************************************************************/
int sua_send_ASPUP_ACK ( unsigned int Sua_assoc_id ,
boolean ASP_id_pres ,
@ -241,6 +246,79 @@ int sua_send_ASPUP_ACK( unsigned int Sua_assoc_id,
return ( error_value ) ;
}
/***********************************************************************/
/* sua_send_ASPDOWN */
/***********************************************************************/
int sua_send_ASPDOWN ( 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_aspsm ;
msg . sua_prim . hdr_msg_type . aspsm = aspsm_down ;
msg . sua_prim . asp_cap_pres = FALSE ;
msg . sua_prim . info_pres = FALSE ;
// encode the SUA unitdata 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_asp_mgnt.c " , logstring ) ;
log_byte_array ( " sua_asp_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 ASPDOWN sctp send = " < < result < < " \n " ;
# endif
}
return ( error_value ) ;
}
/***********************************************************************/
/* sua_send_ASPDOWN_ACK */
/***********************************************************************/
@ -458,7 +536,10 @@ int sua_send_BEAT_ACK( unsigned int Sua_assoc_id,
/***********************************************************************/
/* sua_send_ASPAC */
/***********************************************************************/
int sua_send_ASPAC ( unsigned int Sua_assoc_id
int sua_send_ASPAC ( unsigned int Sua_assoc_id ,
Sua_traffic_mode_type traff_mode ,
boolean routing_context_present ,
uint32_t routing_context
)
{
Sua_container msg ;
@ -476,11 +557,18 @@ int sua_send_ASPAC( unsigned int Sua_assoc_id
msg . sua_prim . hdr_msg_class = sua_asptm ;
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_override ;
if ( traff_mode = = tmt_unknown )
msg . sua_prim . traf_mode_pres = false ;
else {
msg . sua_prim . traf_mode_pres = true ;
msg . sua_prim . traf_mode = traff_mode ;
}
/* rest is optional */
msg . sua_prim . rout_con_pres = TRUE ;
msg . sua_prim . rout_con = 1 ;
msg . sua_prim . rout_con_pres = routing_context_present ;
if ( msg . sua_prim . rout_con_pres )
msg . sua_prim . rout_con = routing_context ;
msg . sua_prim . info_pres = FALSE ;
// encode the SUA unitdata message
@ -616,6 +704,83 @@ int sua_send_ASPAC_ACK( unsigned int Sua_assoc_id,
}
/***********************************************************************/
/* sua_send_ASPINAC */
/***********************************************************************/
int sua_send_ASPINAC ( unsigned int Sua_assoc_id ,
boolean routing_context_present ,
uint32_t routing_context
)
{
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_asptm ;
msg . sua_prim . hdr_msg_type . asptm = asptm_inact ;
msg . sua_prim . rout_con_pres = routing_context_present ;
if ( msg . sua_prim . rout_con_pres )
msg . sua_prim . rout_con = routing_context ;
msg . sua_prim . info_pres = FALSE ;
// encode the SUA unitdata 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_asp_mgnt.c " , logstring ) ;
log_byte_array ( " sua_asp_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 ASPINAC sctp send = " < < result < < " \n " ;
# endif
}
return ( error_value ) ;
}
/***********************************************************************/
/* sua_send_ASPINAC_ACK */
/***********************************************************************/
@ -639,7 +804,9 @@ int sua_send_ASPINAC_ACK( unsigned int Sua_assoc_id,
msg . sua_prim . hdr_msg_class = sua_asptm ;
msg . sua_prim . hdr_msg_type . asptm = asptm_inact_ack ;
msg . sua_prim . rout_con_pres = routing_context_present ;
msg . sua_prim . rout_con = routing_context ;
if ( msg . sua_prim . rout_con_pres )
msg . sua_prim . rout_con = routing_context ;
msg . sua_prim . info_pres = FALSE ;
// encode the SUA unitdata message
@ -690,6 +857,91 @@ int sua_send_ASPINAC_ACK( unsigned int Sua_assoc_id,
return ( error_value ) ;
}
/***********************************************************************/
/* sua_send_NOTIFY */
/***********************************************************************/
int sua_send_NOTIFY ( unsigned int Sua_assoc_id ,
boolean ASP_id_pres ,
uint32_t ASP_id ,
boolean routing_context_present ,
uint32_t routing_context ,
uint8_t status_type ,
uint8_t status_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_mngt ;
msg . sua_prim . hdr_msg_type . mngt = mngt_notify ;
msg . sua_prim . status_pres = true ;
msg . sua_prim . status . status_type = status_type ;
msg . sua_prim . status . status_ID = status_id ;
msg . sua_prim . ASP_id_pres = ASP_id_pres ;
msg . sua_prim . ASP_id = ASP_id ;
msg . sua_prim . rout_con_pres = routing_context_present ;
if ( routing_context_present )
msg . sua_prim . rout_con = routing_context ;
msg . sua_prim . info_pres = FALSE ;
// encode the SUA notify 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_asp_mgnt.c " , logstring ) ;
log_byte_array ( " sua_asp_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 NOTIFY sctp send = " < < result < < " \n " ;
# endif
}
return ( error_value ) ;
}
/***********************************************************************/
/* Receiving SUA Management msg */
/***********************************************************************/
@ -749,7 +1001,11 @@ int process_ASPUP_ACK_msg ( unsigned int sua_assoc_id,
# ifndef IPSP_SINGLE
/* send activation to remote */
error_value = sua_send_ASPAC ( sua_assoc_id ) ;
error_value = sua_send_ASPAC ( sua_assoc_id ,
tmt_unknown ,
true ,
1
) ;
# ifdef DEBUG
cout < < " sua_asp_mgnt.c:result send ASPAC = " < < error_value < < " \n " ;
@ -1003,6 +1259,9 @@ int process_ASPINAC_ACK_msg ( unsigned int sua_assoc_id,
)
{
int error_value = 0 ;
sua . AssocDB . deactivate ( sua_assoc_id , 0 ) ;
# ifdef DEBUG
cout < < " sua_asp_mgnt.c:ASPINAC_ACK received, nothing further to do. \n " ;
# endif
@ -1018,9 +1277,9 @@ void Asp_mngt_standby ( unsigned int sua_AS_id,
)
{
sua . ApplicServ . override_ASP ( sua_asp_id ,
sua_AS_id ,
mode
) ;
sua_AS_id ,
mode
) ;
}
/***********************************************************************/