diff options
author | Harald Welte <laforge@gnumonks.org> | 2010-07-09 20:59:00 +0200 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2010-07-09 20:59:00 +0200 |
commit | 3b3b534da81fbe127cb704918eb5974156686725 (patch) | |
tree | aa209027bf13b49ac33ecb4c66431414b5df3d28 /sualibrary/sua | |
parent | c9c547aafe5b6c6df8714cf30d2bde0fdd4d0722 (diff) |
update to sualibrary-0.1.4 released 2003-10-15
* In addition to 1.3 Contains :
* SSNM support(DAUD, DAVA, DUNA).
* improved ASP management support.
* test user can initiate certain ASP and SSNM proecdures.
* Correct some bugs
* Compiles and runs on Linux, FreeBSD, Max OS X ....
* Tested on IPv4 and IPV6 networks
* interoperable with other SUA implementations
* corresponds to sua draft v15
* requires SCTP implementation sctplib-1.0.0-pre19 from www.sctp.de
Diffstat (limited to 'sualibrary/sua')
-rw-r--r-- | sualibrary/sua/sua.h | 36 | ||||
-rw-r--r-- | sualibrary/sua/sua_adapt.cpp | 125 | ||||
-rw-r--r-- | sualibrary/sua/sua_adapt.h | 5 | ||||
-rw-r--r-- | sualibrary/sua/sua_asp_mgnt.cpp | 289 | ||||
-rw-r--r-- | sualibrary/sua/sua_asp_mgnt.h | 33 | ||||
-rw-r--r-- | sualibrary/sua/sua_cl.cpp | 34 | ||||
-rw-r--r-- | sualibrary/sua/sua_database.cpp | 165 | ||||
-rw-r--r-- | sualibrary/sua/sua_database.h | 18 | ||||
-rw-r--r-- | sualibrary/sua/sua_dataname.cpp | 50 | ||||
-rw-r--r-- | sualibrary/sua/sua_datassoc.cpp | 22 | ||||
-rw-r--r-- | sualibrary/sua/sua_distribution.cpp | 108 | ||||
-rw-r--r-- | sualibrary/sua/sua_distribution.h | 24 | ||||
-rw-r--r-- | sualibrary/sua/sua_file.cpp | 41 | ||||
-rw-r--r-- | sualibrary/sua/sua_snm_mgnt.cpp | 361 | ||||
-rw-r--r-- | sualibrary/sua/sua_snm_mgnt.h | 42 | ||||
-rw-r--r-- | sualibrary/sua/sua_syntax.cpp | 838 | ||||
-rw-r--r-- | sualibrary/sua/sua_syntax.h | 27 |
17 files changed, 2121 insertions, 97 deletions
diff --git a/sualibrary/sua/sua.h b/sualibrary/sua/sua.h index dd2e658..9c70744 100644 --- a/sualibrary/sua/sua.h +++ b/sualibrary/sua/sua.h @@ -15,7 +15,7 @@ * * ***************************************************************************/ /* - * $Id: sua.h,v 1.1 2003/01/14 14:15:36 p82609 Exp $ + * $Id: sua.h,v 1.4 2003/09/09 08:43:25 p82609 Exp $ * * SUA implementation according to SUA draft issue 13. * @@ -63,8 +63,11 @@ * - terminate a association * - Send a SUA primtive to SUA * - Receive a SUA primitive from SUA - * - convert Hostname(string) to SUAname(Character array) - * - convert SUAname(Character array) to Hostname(Character array) + * - get the SUA destination pointcode and status + * - get the SUA origination pointcode + * - activate the SUA association + * - deactivate the SUA association + * - do a SS7 mngt audit(DAUD) on all destinations */ #define __EXTENSIONS__ @@ -400,6 +403,33 @@ unsigned int Receive_sua_primitive( unsigned int &primitive, ); +#define SUA_GETPC_NO_ERROR 0 +#define SUA_GETPC_ERROR 1 + +unsigned int sua_get_sourcepc_addr( unsigned int sua_id, + pointcode_str &pc + ); + +unsigned int sua_get_destpc_addr( unsigned int sua_id, + pointcode_str &pc, + unsigned int &sua_assoc_id, + unsigned int &status + ); + +#define SUA_MNGT_NO_ERROR 0 +#define SUA_MNGT_ERROR 1 + +unsigned int sua_Activate_assoc( unsigned int sua_id + ); + +unsigned int sua_DeActivate_assoc( unsigned int sua_id + ); + +#define SUA_DAUD_NO_ERROR 0 +#define SUA_DAUD_ERROR 1 + +unsigned int sua_send_daud(); + #endif // SUA_GLOBAL_H diff --git a/sualibrary/sua/sua_adapt.cpp b/sualibrary/sua/sua_adapt.cpp index 2501cf6..1511949 100644 --- a/sualibrary/sua/sua_adapt.cpp +++ b/sualibrary/sua/sua_adapt.cpp @@ -15,7 +15,7 @@ * * ***************************************************************************/ /* - * $Id: sua_adapt.cpp,v 1.3 2003/01/31 11:36:39 p82609 Exp $ + * $Id: sua_adapt.cpp,v 1.7 2003/09/09 08:43:25 p82609 Exp $ * * SUA implementation according to SUA draft issue 13. * @@ -54,10 +54,11 @@ * - reading the SUA configuration file * - registering a local SUA instance * - Setting up the association with a remote SUA node - * - get info on a certain (SUA) association * - terminate a association - * - convert Hostname(string) to SUAname(Character array) - * - convert SUAname(Character array) to Hostname(Character array) + * - get SUA path info on a certain (SUA) association + * - get SUA destination pointcode (IP and SS7) and status + * - get SUA origination pointcode (IP and SS7) + * - deactivate a SUA association */ // sua_adapt.c++ @@ -147,7 +148,10 @@ unsigned int sua_registerInstance ( Sua_ULP_CallBacks ulp_callback SCTPCallbackFunctions.communicationErrorNotif = &sctp_CommunicationErrorNotif; SCTPCallbackFunctions.restartNotif = &sctp_RestartNotif; SCTPCallbackFunctions.shutdownCompleteNotif = &sctp_ShutDownCompleteNotif; - + SCTPCallbackFunctions.peerShutdownReceivedNotif = &sctp_ShutDownCompleteNotif; + SCTPCallbackFunctions.queueStatusChangeNotif = &sctp_queueStatusChangeNotif; + SCTPCallbackFunctions.asconfStatusNotif = &sctp_asconfStatusNotif; + result = sua.local_sua.register_instance ( SCTPCallbackFunctions, ulp_callback ); @@ -211,24 +215,39 @@ unsigned int sua_getPath( unsigned int assoc_id, /***********************************************************************/ /* get destination pointcode address */ /***********************************************************************/ -pointcode_str get_destpc_addr( unsigned int sua_id) +unsigned int sua_get_destpc_addr( unsigned int sua_id, + pointcode_str &pc, + unsigned int &sua_assoc_id, + unsigned int &status + ) { - pointcode_str pc; - - pc.ipvx = sua.AssocDB.instance[sua_id].Dest.addrs[0]; - pc.ss7 = sua.AssocDB.instance[sua_id].Dest.pc; - return(pc); + if (( sua_id > 0) && (sua_id <= ((unsigned int)sua.remote_sua.num_of_instance))) + { + pc.ipvx = sua.remote_sua.instance[sua_id].Dest.addrs[0]; + pc.ss7 = sua.remote_sua.instance[sua_id].Dest.pc; + sua_assoc_id = sua.remote_sua.instance[sua_id].SUA_assoc_id; + status = (unsigned int ) sua.remote_sua.instance[sua_id].status; + return(SUA_GETPC_NO_ERROR); + } + else + return(SUA_GETPC_ERROR); } /***********************************************************************/ /* get source pointcode address */ /***********************************************************************/ -pointcode_str get_sourcepc_addr( unsigned int sua_id) +unsigned int sua_get_sourcepc_addr( unsigned int sua_id, + pointcode_str &pc + ) { - pointcode_str pc; - pc.ipvx = sua.AssocDB.instance[sua_id].Source.addrs[0]; - pc.ss7 = sua.AssocDB.instance[sua_id].Source.pc; - return(pc); + if (( sua_id > 0) && (sua_id <= ((unsigned int) sua.local_sua.num_of_instance))) + { + pc.ipvx = sua.local_sua.instance[sua_id].Source.addrs[0]; + pc.ss7 = sua.local_sua.instance[sua_id].Source.pc; + return(SUA_GETPC_NO_ERROR); + } + else + return(SUA_GETPC_ERROR); } /***********************************************************************/ @@ -259,6 +278,80 @@ unsigned int sua_terminate( ) } +/***********************************************************************/ +/* sua_Activate_assoc */ +/***********************************************************************/ +unsigned int sua_Activate_assoc( unsigned int sua_assoc_id + ) +{ + unsigned int result = SUA_MNGT_NO_ERROR; + + switch (sua.AssocDB.instance[sua_assoc_id].asp.status) + { + case(asp_inactive): + case(asp_inactive_traf_hold): + { + result = sua_send_ASPAC( sua_assoc_id, + tmt_unknown, + true, + 1 + ); + break; + } + case( asp_active): + { + /* do nothing, association is already active */ + break; + } + default: + { + result = sua_send_ASPUP( sua_assoc_id , + false, + 1 + ); + break; + } + } + return (result); + +} + +/***********************************************************************/ +/* sua_DeActivate_assoc */ +/***********************************************************************/ +unsigned int sua_DeActivate_assoc( unsigned int sua_assoc_id + ) +{ + unsigned int result = SUA_MNGT_NO_ERROR; + + switch (sua.AssocDB.instance[sua_assoc_id].asp.status) + { + case(asp_inactive): + case(asp_inactive_traf_hold): + { + result = sua_send_ASPDOWN( sua_assoc_id ); + + break; + } + case( asp_active): + { + result = sua_send_ASPINAC( sua_assoc_id, + true, + 1 + ); + break; + } + default: + { + /* do nothing, association is already inactive(idle or down)*/ + break; + } + } + + return (result); + +} + // end of module sua_adapt.c++ diff --git a/sualibrary/sua/sua_adapt.h b/sualibrary/sua/sua_adapt.h index 35b7aa0..60ca14b 100644 --- a/sualibrary/sua/sua_adapt.h +++ b/sualibrary/sua/sua_adapt.h @@ -15,7 +15,7 @@ * * ***************************************************************************/ /* - * $Id: sua_adapt.h,v 1.1 2003/01/14 14:15:36 p82609 Exp $ + * $Id: sua_adapt.h,v 1.2 2003/08/26 11:43:57 p82609 Exp $ * * SUA implementation according to SUA draft issue 6. * @@ -71,9 +71,6 @@ 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 2f9e1a6..e63bbde 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 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, @@ -242,6 +247,79 @@ int sua_send_ASPUP_ACK( unsigned int Sua_assoc_id, } /***********************************************************************/ +/* 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 */ /***********************************************************************/ int sua_send_ASPDOWN_ACK( unsigned int Sua_assoc_id @@ -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 @@ -617,6 +705,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 */ /***********************************************************************/ int sua_send_ASPINAC_ACK( unsigned int Sua_assoc_id, @@ -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 @@ -691,6 +858,91 @@ int sua_send_ASPINAC_ACK( unsigned int Sua_assoc_id, } /***********************************************************************/ +/* 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 + ); } /***********************************************************************/ diff --git a/sualibrary/sua/sua_asp_mgnt.h b/sualibrary/sua/sua_asp_mgnt.h index 625d687..2ece470 100644 --- a/sualibrary/sua/sua_asp_mgnt.h +++ b/sualibrary/sua/sua_asp_mgnt.h @@ -15,7 +15,7 @@ * * ***************************************************************************/ /* - * $Id: sua_asp_mgnt.h,v 1.1 2003/01/14 14:15:37 p82609 Exp $ + * $Id: sua_asp_mgnt.h,v 1.2 2003/09/09 08:43:25 p82609 Exp $ * * SUA implementation according to SUA draft issue 6. * @@ -93,12 +93,33 @@ typedef enum { lm_override, // 0: standard loadshare: only 1 ASP lm_share_BC // 3: Broadcasting }asp_Sua_loadmode_set; -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 ); -int sua_send_ASPAC( unsigned int Sua_assoc_id +int sua_send_ASPDOWN( 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 ); +int sua_send_ASPINAC( unsigned int Sua_assoc_id, + boolean routing_context_present, + uint32_t routing_context + ); + +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 + ); int process_ASPUP_msg ( unsigned int sua_assoc_id, int local_sua_id, @@ -113,9 +134,9 @@ int process_ASPUP_ACK_msg ( unsigned int sua_assoc_id, ); int process_ASPDOWN_msg ( unsigned int sua_assoc_id, - int local_sua_id, - int remote_sua_id, - Sua_container sua_asp_msg + int local_sua_id, + int remote_sua_id, + Sua_container sua_asp_msg ); int process_ASPDOWN_ACK_msg ( unsigned int sua_assoc_id, diff --git a/sualibrary/sua/sua_cl.cpp b/sualibrary/sua/sua_cl.cpp index 6c21b39..3120ac5 100644 --- a/sualibrary/sua/sua_cl.cpp +++ b/sualibrary/sua/sua_cl.cpp @@ -15,7 +15,7 @@ * * ***************************************************************************/ /* - * $Id: sua_cl.cpp,v 1.4 2003/02/17 14:38:08 p82609 Exp $ + * $Id: sua_cl.cpp,v 1.5 2003/09/09 08:43:25 p82609 Exp $ * * SUA implementation according to SUA draft issue 6. * @@ -274,9 +274,22 @@ int sua_route_Message( unsigned int &sctp_assoc_id, cout << "routed to SCTP assoc " << sctp_assoc_id << "/SUA assoc id " << sua_assoc_id <<"\n"; #endif - /* does association exist? */ + if ((msg.sua_prim.hop_count_pres) && (msg.sua_prim.hop_count <= 0)) + { + sctp_assoc_id = 0; +#ifdef DEBUG + cout << "Hopcounter reach 0: drop/send response back msg\n"; +#endif + } + + + /* does association exist? */ if (sctp_assoc_id > 0) { + /* if hopcounter present decrement him */ + if (msg.sua_prim.hop_count_pres) + msg.sua_prim.hop_count--; + /* YES, encode the SUA unitdata message and ... */ error = msg.sua_encode(); @@ -412,7 +425,7 @@ int sua_send_Unitdata ( sccp_QOS_str &QOS, msg.sua_prim.prot_class_pres = TRUE; msg.sua_prim.prot_class.pcl = prot_class_0; msg.sua_prim.seq_control_pres = TRUE; - msg.sua_prim.seq_control = QOS.sequence_number; + msg.sua_prim.seq_control = 0; sctp_delivery_type = SCTP_UNORDERED_DELIVERY; break; case(class1): @@ -698,6 +711,8 @@ short process_unitdata_msg ( int local_sua_id, temp.primitive = N_UNITDATA; temp.user_ref = 0; + /* change routing context hard coded for test with CMG-logica */ + /*msg.sua_prim.rout_con = 6;*/ if (msg.sua_prim.prot_class_pres) { @@ -917,6 +932,7 @@ short process_UDTService_msg ( int local_sua_id, sua_save_str temp; int i, result = 0; unsigned int sctp_assoc_id = 0; + char digit_char; temp.primitive = N_NOTICE; temp.user_ref = 0; @@ -976,8 +992,10 @@ short process_UDTService_msg ( int local_sua_id, 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]; + for (i=0; i < temp.calling_pty_address.name.GT.nr_of_digits; i++){ + sprintf(&digit_char, "%d", msg.sua_prim.source_addr.gt.digits[i]); + temp.calling_pty_address.name.GT.digits[i] = digit_char; + } temp.calling_pty_address.name.GT.digits[temp.calling_pty_address.name.GT.nr_of_digits] = '\0'; } @@ -1050,8 +1068,10 @@ short process_UDTService_msg ( int local_sua_id, 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]; + for (i=0; i < temp.called_pty_address.name.GT.nr_of_digits; i++){ + sprintf(&digit_char, "%d", msg.sua_prim.dest_addr.gt.digits[i]); + temp.called_pty_address.name.GT.digits[i] = digit_char; + } temp.called_pty_address.name.GT.digits[temp.called_pty_address.name.GT.nr_of_digits] = '\0'; } diff --git a/sualibrary/sua/sua_database.cpp b/sualibrary/sua/sua_database.cpp index a8987b7..f636bbc 100644 --- a/sualibrary/sua/sua_database.cpp +++ b/sualibrary/sua/sua_database.cpp @@ -15,7 +15,7 @@ * * ***************************************************************************/ /* - * $Id: sua_database.cpp,v 1.2 2003/01/16 15:07:56 p82609 Exp $ + * $Id: sua_database.cpp,v 1.5 2003/08/28 09:30:20 p82609 Exp $ * * SUA implementation according to SUA draft issue 6. * @@ -411,6 +411,29 @@ return(0); } /***********************************************************************/ +/* Sua_LocalList::found */ +/***********************************************************************/ +bool db_Sua_LocalList:: found( SS7union pc ){ + int i = 1; + bool found_pc = false; + + while (( i <= num_of_instance ) && (!found_pc)) + { + if (pc.ITU14.family == ITU14bit) // standard ITU: 14 bits + found_pc = ((pc.ITU14.pc == instance[i].Source.pc.ITU14.pc)); + else if (pc.ITU24.family == ITU24bit) // chinese PC length: 24 bits + found_pc = ((pc.ITU24.pc == instance[i].Source.pc.ITU24.pc)); + else if (pc.ANSI24.family == ANSI24bit) // ANSI PC length: 24 bits + found_pc = ((pc.ANSI24.pc == instance[i].Source.pc.ANSI24.pc)); + else + found_pc = false; + + i++; + } + return(found_pc); +} + +/***********************************************************************/ /* functions of the object class SUA Remote Object */ /***********************************************************************/ /***********************************************************************/ @@ -418,7 +441,7 @@ return(0); /***********************************************************************/ void db_Sua_RemoteObject::initialize(){ - ; + status = ssnm_unavailable; } /***********************************************************************/ @@ -461,6 +484,144 @@ void db_Sua_RemoteList:: increase_instance(){ }; /***********************************************************************/ +/* Sua_RemoteList::Dest_Available */ +/***********************************************************************/ +void db_Sua_RemoteList:: Dest_Available( SS7union pc) +{ + int i = 0; + bool found_pc = false; + + while (( i < num_of_instance ) && (!found_pc)) + { + i++; + if (pc.ITU14.family == ITU14bit) // standard ITU: 14 bits + found_pc = ((pc.ITU14.pc == instance[i].Dest.pc.ITU14.pc)); + else if (pc.ITU24.family == ITU24bit) // chinese PC length: 24 bits + found_pc = ((pc.ITU24.pc == instance[i].Dest.pc.ITU24.pc)); + else if (pc.ANSI24.family == ANSI24bit) // ANSI PC length: 24 bits + found_pc = ((pc.ANSI24.pc == instance[i].Dest.pc.ANSI24.pc)); + else + found_pc = false; + + }; + if (found_pc) + instance[i].status = ssnm_available; + +} + +/***********************************************************************/ +/* Sua_RemoteList::Dest_Unavailable */ +/***********************************************************************/ +void db_Sua_RemoteList:: Dest_Unavailable( SS7union pc) +{ + int i = 0; + bool found_pc = false; + + while (( i < num_of_instance ) && (!found_pc)) + { + i++; + if (pc.ITU14.family == ITU14bit) // standard ITU: 14 bits + found_pc = ((pc.ITU14.pc == instance[i].Dest.pc.ITU14.pc)); + else if (pc.ITU24.family == ITU24bit) // chinese PC length: 24 bits + found_pc = ((pc.ITU24.pc == instance[i].Dest.pc.ITU24.pc)); + else if (pc.ANSI24.family == ANSI24bit) // ANSI PC length: 24 bits + found_pc = ((pc.ANSI24.pc == instance[i].Dest.pc.ANSI24.pc)); + else + found_pc = false; + + }; + if (found_pc) + instance[i].status = ssnm_unavailable; +} + +/***********************************************************************/ +/* Sua_RemoteList::deactivate_dests */ +/***********************************************************************/ +void db_Sua_RemoteList:: Deactivate_dests( unsigned int sua_assoc_id) +{ + int i = 0; + + while (( i < num_of_instance )) + { + i++; + if (sua_assoc_id == instance[i].SUA_assoc_id) // found assoc_id + instance[i].status = ssnm_unavailable; + + } + +} + +/***********************************************************************/ +/* Sua_RemoteList::Activate_dests */ +/***********************************************************************/ +void db_Sua_RemoteList:: Activate_dests( unsigned int sua_assoc_id) +{ + int i = 0; + + while (( i < num_of_instance )) + { + i++; + if (sua_assoc_id == instance[i].SUA_assoc_id) // found assoc_id + instance[i].status = ssnm_available; + + } + +} +/***********************************************************************/ +/* Sua_RemoteList::get_Dest_status */ +/***********************************************************************/ +snm_Sua_pc_state_set db_Sua_RemoteList:: get_Dest_status( SS7union pc ) +{ + int i = 0; + bool found_pc = false; + + while (( i < num_of_instance ) && (!found_pc)) + { + i++; + if (pc.ITU14.family == ITU14bit) // standard ITU: 14 bits + found_pc = ((pc.ITU14.pc == instance[i].Dest.pc.ITU14.pc)); + else if (pc.ITU24.family == ITU24bit) // chinese PC length: 24 bits + found_pc = ((pc.ITU24.pc == instance[i].Dest.pc.ITU24.pc)); + else if (pc.ANSI24.family == ANSI24bit) // ANSI PC length: 24 bits + found_pc = ((pc.ANSI24.pc == instance[i].Dest.pc.ANSI24.pc)); + else + found_pc = false; + + } + if (found_pc) + return(instance[i].status); + else + return(ssnm_unavailable); + +} + +/***********************************************************************/ +/* Sua_RemoteList::found */ +/***********************************************************************/ +bool db_Sua_RemoteList:: found( SS7union pc ){ + int i = 0; + bool found_pc = false; + + while (( i < num_of_instance ) && (!found_pc)) + { + i++; + if (pc.ITU14.family == ITU14bit) // standard ITU: 14 bits + found_pc = ((pc.ITU14.pc == instance[i].Dest.pc.ITU14.pc)); + else if (pc.ITU24.family == ITU24bit) // chinese PC length: 24 bits + found_pc = ((pc.ITU24.pc == instance[i].Dest.pc.ITU24.pc)); + else if (pc.ANSI24.family == ANSI24bit) // ANSI PC length: 24 bits + found_pc = ((pc.ANSI24.pc == instance[i].Dest.pc.ANSI24.pc)); + else + found_pc = false; + + } + + return(found_pc); + +} + + +/***********************************************************************/ /* functions of the object class SUA Application Server Process (ASP) */ /***********************************************************************/ /***********************************************************************/ diff --git a/sualibrary/sua/sua_database.h b/sualibrary/sua/sua_database.h index 20505c7..fa548c0 100644 --- a/sualibrary/sua/sua_database.h +++ b/sualibrary/sua/sua_database.h @@ -15,7 +15,7 @@ * * ***************************************************************************/ /* - * $Id: sua_database.h,v 1.4 2003/01/31 11:36:39 p82609 Exp $ + * $Id: sua_database.h,v 1.7 2003/08/28 09:30:20 p82609 Exp $ * * SUA implementation according to SUA draft issue 8. * @@ -69,6 +69,7 @@ #include "sua.h" #include "sua_asp_mgnt.h" +#include "sua_snm_mgnt.h" #include <string> @@ -143,6 +144,7 @@ class db_Sua_LocalList{ ); short unregister_instance(); void increase_instance(); + bool found( SS7union pc); }; ///:~ /***********************************************************************/ @@ -150,11 +152,13 @@ class db_Sua_LocalList{ /***********************************************************************/ class db_Sua_RemoteObject{ public: - db_Sua_SSNObject ssn; + db_Sua_SSNObject ssn; /* contains the association sua id with which it is linked. */ - unsigned int SUA_assoc_id; + unsigned int SUA_assoc_id; + /* status of the remote node */ + snm_Sua_pc_state_set status; /* dest address of the remote sua node */ - db_Sua_AddressObject Dest; + db_Sua_AddressObject Dest; public: // functions of the Class void initialize(); @@ -171,6 +175,12 @@ class db_Sua_RemoteList{ void initialize(); void read_ssn(string ssn); void increase_instance(); + bool found( SS7union pc); + void Dest_Available( SS7union pc); + void Dest_Unavailable( SS7union pc); + void Activate_dests( unsigned int sua_assoc_id); + void Deactivate_dests( unsigned int sua_assoc_id); + snm_Sua_pc_state_set get_Dest_status(SS7union pc); }; ///:~ /***********************************************************************/ diff --git a/sualibrary/sua/sua_dataname.cpp b/sualibrary/sua/sua_dataname.cpp index 76737cf..aba7774 100644 --- a/sualibrary/sua/sua_dataname.cpp +++ b/sualibrary/sua/sua_dataname.cpp @@ -15,7 +15,7 @@ * * ***************************************************************************/ /* - * $Id: sua_dataname.cpp,v 1.2 2003/01/31 11:36:39 p82609 Exp $ + * $Id: sua_dataname.cpp,v 1.4 2003/09/09 08:43:44 p82609 Exp $ * * SUA implementation according to SUA draft issue 6. * @@ -270,8 +270,9 @@ signed int db_Sua_NameList::perform_GTT ( global_title_str& cld_in, pointcode_str& dest_pc ) { - boolean search_gt = true, gt_entry_found = false; - int i, found_gt_entry; + boolean search_gt = true, gt_entry_found = false; + int i, found_gt_entry,res; + unsigned int sua_assoc_id, status; /* resolving can be done via: */ /* - local global Titel database */ @@ -290,9 +291,36 @@ signed int db_Sua_NameList::perform_GTT ( global_title_str& cld_in, i++; } + cout << "found_gt_entry = " << found_gt_entry << "\n"; + cout << "tt = " << cld_in.Translation_Type << "\n"; + cout << "NP = " << cld_in.Numbering_Plan << "\n"; + cout << "NA = " << cld_in.Nature_of_Address << "\n"; + cout << "CLD number of digits = " << cld_in.nr_of_digits << "\n"; + cout << "CLD digits = " << cld_in.digits[0]; + cout << cld_in.digits[1]; + cout << cld_in.digits[2]; + cout << cld_in.digits[3]; + cout << cld_in.digits[4]; + cout << cld_in.digits[5]; + cout << cld_in.digits[6]; + cout << cld_in.digits[7]; + cout << cld_in.digits[8]; + cout << cld_in.digits[9]; + cout << cld_in.digits[10]; + cout << cld_in.digits[11]; + cout << "\n"; + cout << "CLG number of digits = " << clg_in.nr_of_digits << "\n"; + cout << "CLG digits = " << clg_in.digits << "\n"; + + + if (gt_entry_found) { /* get the association number from gt database */ - dest_pc = get_destpc_addr(instance[found_gt_entry].SUA_assoc_id); + res = sua_get_destpc_addr(instance[found_gt_entry].SUA_assoc_id, + dest_pc, + sua_assoc_id, + status + ); return(0); } else @@ -317,3 +345,17 @@ void db_Sua_NameList:: increase_instance(){ + + + + + + + + + + + + + + diff --git a/sualibrary/sua/sua_datassoc.cpp b/sualibrary/sua/sua_datassoc.cpp index 8530b5e..2159c03 100644 --- a/sualibrary/sua/sua_datassoc.cpp +++ b/sualibrary/sua/sua_datassoc.cpp @@ -15,7 +15,7 @@ * * ***************************************************************************/ /* - * $Id: sua_datassoc.cpp,v 1.8 2003/02/17 14:38:08 p82609 Exp $ + * $Id: sua_datassoc.cpp,v 1.9 2003/09/09 08:43:44 p82609 Exp $ * * SUA implementation according to SUA draft issue 6. * @@ -363,12 +363,22 @@ passive_associate( unsigned int sctp_assoc_id, &status ); +#ifdef DEBUG + cout << "SCTP association " << sctp_assoc_id <<" result = " << result<< "\n"; +#endif + +#ifdef DEBUG + cout << "number of asoc = " << num_of_instance << "\n"; +#endif while ((i <= num_of_instance) && !(assoc_found)){ assoc_found = (instance[i].Dest.nr_of_addrs == status.numberOfAddresses); if (assoc_found) { k = 0; found_addr = false; +#ifdef DEBUG + cout << "same number of addresses\n"; +#endif while ((k < instance[i].Dest.nr_of_addrs) && (!found_addr)) { j=0; @@ -380,6 +390,9 @@ passive_associate( unsigned int sctp_assoc_id, k++; } if (found_addr){ +#ifdef DEBUG + cout << "found same ip address\n"; +#endif assoc_found = ( found_addr && (instance[i].Dest.addrs[0].sin.sin_port == status.destPort)); assoc_instance_idx = i; } @@ -393,6 +406,9 @@ passive_associate( unsigned int sctp_assoc_id, { /* unknown association added */ /* not allowed: drop it */ +#ifdef DEBUG + cout << "not found ???\n"; +#endif assoc_instance_idx = 0; result = sctp_abort(sctp_assoc_id); } @@ -872,6 +888,10 @@ route_on_GTT ( global_title_str& dest_gt, dest_pc ); +#ifdef DEBUG + cout << "result of GT translation : " << result << "\n"; + cout << "dest IP address = " << dest_pc.ipvx.sa.sa_family << "\n"; +#endif sctp_assoc_id = route_on_IPpc( dest_pc.ipvx, org_pc.ipvx, sua_assoc_id diff --git a/sualibrary/sua/sua_distribution.cpp b/sualibrary/sua/sua_distribution.cpp index 99b3ecc..d8b342b 100644 --- a/sualibrary/sua/sua_distribution.cpp +++ b/sualibrary/sua/sua_distribution.cpp @@ -15,7 +15,7 @@ * * ***************************************************************************/ /* - * $Id: sua_distribution.cpp,v 1.3 2003/01/27 16:47:43 p82609 Exp $ + * $Id: sua_distribution.cpp,v 1.6 2003/09/09 08:43:25 p82609 Exp $ * * SUA implementation according to SUA draft issue 6. * @@ -466,8 +466,12 @@ void sctp_DataArriveNotif( unsigned int sctp_assoc_id, #ifdef DEBUG cout << "SNM: Destination unavialable\n"; #endif - - + + result = process_DUNA_msg ( sua_assoc_id, + local_sua_id, + remote_sua_id, + msg + ); char logstring[100]; sprintf(logstring, "Received DUNA msg"); event_log("sua_distribution.c",logstring); @@ -480,6 +484,12 @@ void sctp_DataArriveNotif( unsigned int sctp_assoc_id, cout << "SNM: Destination avialable message handling\n"; #endif + result = process_DAVA_msg ( sua_assoc_id, + local_sua_id, + remote_sua_id, + msg + ); + char logstring[100]; sprintf(logstring, "Received DAVA msg"); event_log("sua_distribution.c",logstring); @@ -495,7 +505,8 @@ void sctp_DataArriveNotif( unsigned int sctp_assoc_id, local_sua_id, remote_sua_id, msg - ); + ); + char logstring[100]; sprintf(logstring, "Received DAUD msg"); event_log("sua_distribution.c",logstring); @@ -508,6 +519,12 @@ void sctp_DataArriveNotif( unsigned int sctp_assoc_id, cout << "SNM: Network congestion message handling\n"; #endif + result = process_SCON_msg ( sua_assoc_id, + local_sua_id, + remote_sua_id, + msg + ); + char logstring[100]; sprintf(logstring, "Received SCON msg"); event_log("sua_distribution.c",logstring); @@ -520,6 +537,12 @@ void sctp_DataArriveNotif( unsigned int sctp_assoc_id, cout << "SNM: Destination User Part Unavialable message handling\n"; #endif + result = process_DUPU_msg ( sua_assoc_id, + local_sua_id, + remote_sua_id, + msg + ); + char logstring[100]; sprintf(logstring, "Received DUPU msg"); event_log("sua_distribution.c",logstring); @@ -531,7 +554,13 @@ void sctp_DataArriveNotif( unsigned int sctp_assoc_id, #ifdef DEBUG cout << "SNM: Destination restricted message handling\n"; #endif - + + result = process_DRST_msg ( sua_assoc_id, + local_sua_id, + remote_sua_id, + msg + ); + char logstring[100]; sprintf(logstring, "Received DRST msg"); event_log("sua_distribution.c",logstring); @@ -949,7 +978,9 @@ void *sctp_CommunicationUpNotif( unsigned int sctp_assoc_id, if (sua_assoc_id != 0) { /* send ASP-UP to remote to start activating local & remote ASP */ - result = sua_send_ASPUP( sua_assoc_id + result = sua_send_ASPUP( sua_assoc_id, + false, + 0 ); } #endif @@ -998,10 +1029,17 @@ void sctp_RestartNotif( unsigned int sctp_assoc_id, /* restart association: ASP state should be set to down */ sua.AssocDB.down(sua_assoc_id,0); + sua.remote_sua.Activate_dests(sua_assoc_id); +#ifdef DEBUG + cout << "All destination(s) activated for SUA association " << sua_assoc_id << "\n"; +#endif + /* if we found the sua assoc then we restart the ASP bringup sequence */ /* as the sctp association has come back online */ /* send ASP-UP to remote to start activating local & remote ASP */ - result = sua_send_ASPUP( sua_assoc_id + result = sua_send_ASPUP( sua_assoc_id, + false, + 0 ); } #endif @@ -1009,18 +1047,68 @@ void sctp_RestartNotif( unsigned int sctp_assoc_id, } /***********************************************************************/ -/* sctp_ShutDownCompleteNotif */ +/* sctp_ShutDownCompleteNotif */ /***********************************************************************/ -void sctp_ShutDownCompleteNotif( unsigned int assoc_id, +void sctp_ShutDownCompleteNotif( unsigned int sctp_assoc_id, void * ulp_data_ptr ) { + unsigned int sua_assoc_id,local_sua_id, remote_sua_id; + + #ifdef DEBUG - cout << "Received shutdown indication for association " << assoc_id << "\n"; + cout << "Received shutdown indication for association " << sctp_assoc_id << "\n"; #endif + +#ifdef SUA_MANAGEMENT + 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 */ + sua.AssocDB.down(sua_assoc_id, 0); +#ifdef DEBUG + cout << "ASP down for SUA association " << sua_assoc_id << "\n"; +#endif + sua.remote_sua.Deactivate_dests(sua_assoc_id); +#ifdef DEBUG + cout << "All destination(s) blocked for SUA association " << sua_assoc_id << "\n"; +#endif + + } +#endif + + } +/***********************************************************************/ +/* sctp_queueStatusChangeNotif */ +/***********************************************************************/ +void sctp_queueStatusChangeNotif (unsigned int assoc_id, + int queue_type, + int queue_id, + int queue_length, + void* ulp_data_ptr + ) +{ +#ifdef DEBUG + cout << "Received a queuestatus change indication for association " << assoc_id << "\n"; +#endif +} +/***********************************************************************/ +/* sctp_asconfStatusNotif */ +/***********************************************************************/ +void sctp_asconfStatusNotif( unsigned int assoc_id, + unsigned int correlation_id, + int result, + void* temp, + void* ulp_data_ptr + ) +{ +#ifdef DEBUG + cout << "Received SCTP configuration indication for association " << assoc_id << "\n"; +#endif +} /***********************************************************************/ /* Send_sua_primitive */ diff --git a/sualibrary/sua/sua_distribution.h b/sualibrary/sua/sua_distribution.h index f33b531..eac8e1c 100644 --- a/sualibrary/sua/sua_distribution.h +++ b/sualibrary/sua/sua_distribution.h @@ -15,7 +15,7 @@ * * ***************************************************************************/ /* - * $Id: sua_distribution.h,v 1.1 2003/01/14 14:15:37 p82609 Exp $ + * $Id: sua_distribution.h,v 1.2 2003/08/21 10:33:13 p82609 Exp $ * * SUA implementation according to SUA draft issue 6. * @@ -166,6 +166,28 @@ void sctp_ShutDownCompleteNotif( unsigned int assoc_id, void * ulp_data_ptr ); + +/***********************************************************************/ +/* sctp_queueStatusChangeNotif */ +/***********************************************************************/ +void sctp_queueStatusChangeNotif (unsigned int assoc_id, + int queue_type, + int queue_id, + int queue_length, + void* ulp_data_ptr + ); + +/***********************************************************************/ +/* sctp_asconfStatusNotif */ +/***********************************************************************/ +void sctp_asconfStatusNotif( unsigned int assoc_id, + unsigned int correlation_id, + int result, + void* temp, + void* ulp_data_ptr + ); + + #endif // SUA_DISTRIBUTION_H // end of module sua_distribution.h diff --git a/sualibrary/sua/sua_file.cpp b/sualibrary/sua/sua_file.cpp index 5573810..f9ca43d 100644 --- a/sualibrary/sua/sua_file.cpp +++ b/sualibrary/sua/sua_file.cpp @@ -15,7 +15,7 @@ * * ***************************************************************************/ /* - * $Id: sua_file.cpp,v 1.6 2003/01/31 11:36:39 p82609 Exp $ + * $Id: sua_file.cpp,v 1.7 2003/09/09 08:43:25 p82609 Exp $ * * SUA implementation according to SUA draft issue 13. * @@ -762,6 +762,38 @@ void sua_cr_route_name( string route_parm_str, } /***********************************************************************/ +/* create routing context parameter handling */ +/***********************************************************************/ +void sua_cr_routing_context( string rc_parm_str, + db_Sua_DatabaseList& sua + ) +{ + int rc_id; + short cpy_start, cpy_len; + + /* get pc id from param string, use as index remote_sua table */ + if (rc_parm_str.find("rc_id=") != rc_parm_str.npos) + { + cpy_start = (rc_parm_str.find("rc_id=")+8); + cpy_len = (rc_parm_str.find(",pc")) - cpy_start ; + string rc_id_str( rc_parm_str, cpy_start, cpy_len); +#ifdef DEBUG + cout << "Routing Context id = " << rc_id_str << "\n"; +#endif + rc_id = atoi(rc_id_str.c_str()); + } + else + return; + + /* get destination pointcode from param string */ + + + return; + +} + + +/***********************************************************************/ /* read sua configuration file */ /***********************************************************************/ int read_sua_conf_file( string filename, @@ -863,6 +895,13 @@ int read_sua_conf_file( string filename, sua.AssocDB ); } + else if (cmdline.find("cr rc:rc_id") != cmdline.npos) + { + string parm_str( cmdline, (cmdline.find("cr rc:")+9),cmdline.length()); + sua_cr_routing_context( parm_str, + sua + ); + } else if (cmdline.find("cr xxxx:") != cmdline.npos) { ; diff --git a/sualibrary/sua/sua_snm_mgnt.cpp b/sualibrary/sua/sua_snm_mgnt.cpp index f4c20b0..0eb5950 100644 --- a/sualibrary/sua/sua_snm_mgnt.cpp +++ b/sualibrary/sua/sua_snm_mgnt.cpp @@ -5,7 +5,6 @@ copyright : (C) 2002 by Lode Coene email : lode.coene@siemens.atea.be ***************************************************************************/ - /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * @@ -15,7 +14,7 @@ * * ***************************************************************************/ /* - * $Id: sua_snm_mgnt.cpp,v 1.1 2003/01/14 14:15:37 p82609 Exp $ + * $Id: sua_snm_mgnt.cpp,v 1.6 2003/08/28 09:30:20 p82609 Exp $ * * SUA implementation according to SUA draft issue 14. * @@ -52,7 +51,12 @@ * 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 Unavailable(DUNA) msg + * - Receive/process Destination Available(DAVA) msg * - Receive/process Destination State audit(DAUD) msg + * - Receive/process Network congestion(SCON) msg + * - Receive/process Destination User Part Unavailable(DUPU) msg + * - Receive/process Destination Restricted(DRST) msg */ #include "sua_debug.h" @@ -78,7 +82,8 @@ extern tcb_Sua_msgqueue_pool msg_store; /***********************************************************************/ /* sua_send_DAVA */ /***********************************************************************/ -int sua_send_DAVA( unsigned int Sua_assoc_id +int sua_send_DAVA( unsigned int Sua_assoc_id, + SS7union pc ) { Sua_container msg; @@ -95,8 +100,9 @@ int sua_send_DAVA( unsigned int Sua_assoc_id // 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.ssnm_parm.aff_pc_pres = TRUE; + msg.sua_prim.ssnm_parm.aff_pc.num_aff_pc = 1; + msg.sua_prim.ssnm_parm.aff_pc.pc[0] = pc.ITU24.pc; msg.sua_prim.info_pres = FALSE; // encode the SUA DAVA message @@ -149,31 +155,359 @@ int sua_send_DAVA( unsigned int Sua_assoc_id /***********************************************************************/ +/* sua_send_DUNA */ +/***********************************************************************/ +int sua_send_DUNA( unsigned int Sua_assoc_id, + SS7union pc + ) +{ + 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_duna; + msg.sua_prim.ssnm_parm.aff_pc_pres = TRUE; + msg.sua_prim.ssnm_parm.aff_pc.num_aff_pc = 1; + msg.sua_prim.ssnm_parm.aff_pc.pc[0] = pc.ITU24.pc; + 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 DUNA sctp send = "<< result << "\n"; +#endif + } + + return(error_value); +} + + +/***********************************************************************/ +/* sua_send_DAUD */ +/***********************************************************************/ +unsigned int sua_send_daud() +{ + Sua_container msg; + Sua_syntax_error_struct error; + int i, error_value = 0; + int string_size, datalen; + signed int sctp_assoc_id, Sua_assoc_id; + short stream_id = 0; + int delivery_type, result; + SS7union pc; + + + i = 1; + + while ( i <= sua.remote_sua.num_of_instance) + { + /* get pointcode from sua remote list */ + pc = sua.remote_sua.instance[i].Dest.pc; + // 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_daud; + msg.sua_prim.ssnm_parm.aff_pc_pres = TRUE; + msg.sua_prim.ssnm_parm.aff_pc.num_aff_pc = 1; + msg.sua_prim.ssnm_parm.aff_pc.pc[0] = pc.ITU24.pc; + msg.sua_prim.info_pres = FALSE; + + // encode the SUA DAUD message + error = msg.sua_encode(); + string_size = msg.sua_msg.size(); + + delivery_type = SCTP_UNORDERED_DELIVERY; + + Sua_assoc_id = sua.remote_sua.instance[i].SUA_assoc_id; + 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 = error_value + result; + delete databuf; +#ifdef DEBUG + cout << "sua_asp_mgnt.c:result DAUD sctp send = "<< result << "\n"; +#endif + } + /* go to next remote destination (if possible) */ + i++; + + } + + return(error_value); +} + + + +/***********************************************************************/ /* Receiving SUA Signalling Network Management msg */ /***********************************************************************/ /***********************************************************************/ -/* sua_process_ASPUP_msg */ +/* sua_process_DUNA_msg */ +/***********************************************************************/ +int process_DUNA_msg ( unsigned int sua_assoc_id, + int local_sua_id, + int remote_sua_id, + Sua_container sua_ssnm_msg + ) +{ + + int error_value = 0; + SS7union rec_pc; + int num_rec_pc; + + rec_pc.ITU14.family = ITU14bit; + num_rec_pc = sua_ssnm_msg.sua_prim.ssnm_parm.aff_pc.num_aff_pc; + + for ( int k = 0; k < num_rec_pc; k++) + { + rec_pc.ITU14.pc = sua_ssnm_msg.sua_prim.ssnm_parm.aff_pc.pc[k]; + sua.remote_sua.Dest_Unavailable(rec_pc); + } + +#ifdef DEBUG + cout << "sua_snm_mgnt.c:DUNA received, mark internal : no traffic to this destination.\n"; +#endif + + + + + return(error_value); +} + +/***********************************************************************/ +/* sua_process_DAVA_msg */ +/***********************************************************************/ +int process_DAVA_msg ( unsigned int sua_assoc_id, + int local_sua_id, + int remote_sua_id, + Sua_container sua_ssnm_msg + ) +{ + int error_value = 0; + SS7union rec_pc; + int num_rec_pc; + + rec_pc.ITU14.family = ITU14bit; + num_rec_pc = sua_ssnm_msg.sua_prim.ssnm_parm.aff_pc.num_aff_pc; + + for ( int k = 0; k < num_rec_pc; k++) + { + rec_pc.ITU14.pc = sua_ssnm_msg.sua_prim.ssnm_parm.aff_pc.pc[k]; + sua.remote_sua.Dest_Available(rec_pc); + } + +#ifdef DEBUG + cout << "sua_snm_mgnt.c:DAVA received, mark internal: traffic can be send to this destination.\n"; +#endif + + return(error_value); +} + + + +/***********************************************************************/ +/* sua_process_DAUD_msg */ /***********************************************************************/ int process_DAUD_msg ( unsigned int sua_assoc_id, int local_sua_id, int remote_sua_id, - Sua_container sua_asp_msg + Sua_container sua_ssnm_msg ) { - int error_value; + int error_value = 0; + SS7union rec_pc; + int num_rec_pc; #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);*/ + rec_pc.ITU14.family = ITU14bit; + num_rec_pc = sua_ssnm_msg.sua_prim.ssnm_parm.aff_pc.num_aff_pc; + + for ( int k = 0; k < num_rec_pc; k++) + { + rec_pc.ITU14.pc = sua_ssnm_msg.sua_prim.ssnm_parm.aff_pc.pc[k]; - error_value = sua_send_DAVA( sua_assoc_id ); - + /* find the local sua with the specific received PC */ + if ( !sua.local_sua.found(rec_pc)) + { + /* if no local found, go through the remote sua's for */ + /* the specific received PC */ + + if (ssnm_available != sua.remote_sua.get_Dest_status(rec_pc)) + { + /* if not found, then pc is not reachable. */ + /* let it be known to the requesting side */ + error_value = sua_send_DUNA( sua_assoc_id , + rec_pc + ); + + } + else + { + /* found the pc and it is accessible/reachable */ + /* let it be known to the requesting side */ + error_value = sua_send_DAVA( sua_assoc_id , + rec_pc + ); + } + } + else + { + /* found the pc and it is accessible/reachable */ + /* let it be known to the requesting side */ + error_value = sua_send_DAVA( sua_assoc_id , + rec_pc + ); + } + + +#ifdef DEBUG + cout << "sua_asp_mgnt.c:result send DUNA/DAVA/DRST = "<< error_value << "\n"; +#endif + } + #ifdef DEBUG - cout << "sua_asp_mgnt.c:result send DUNA/DAVA/DRST = "<< error_value << "\n"; + cout << "sua_asp_mgnt.c:DAUD completely processed: " << num_rec_pc << " pointcodes\n"; #endif + + return(error_value); +} + +/***********************************************************************/ +/* sua_process_SCON_msg */ +/***********************************************************************/ +int process_SCON_msg ( unsigned int sua_assoc_id, + int local_sua_id, + int remote_sua_id, + Sua_container sua_asp_msg + ) +{ + + int error_value = 0; + +#ifdef DEBUG + cout << "sua_snm_mgnt.c:SCON received, ignore.\n"; +#endif + + + return(error_value); +} + +/***********************************************************************/ +/* sua_process_DUPU_msg */ +/***********************************************************************/ +int process_DUPU_msg ( unsigned int sua_assoc_id, + int local_sua_id, + int remote_sua_id, + Sua_container sua_asp_msg + ) +{ + + int error_value = 0; + +#ifdef DEBUG + cout << "sua_snm_mgnt.c:DUPU received.\n"; +#endif + + return(error_value); +} + +/***********************************************************************/ +/* sua_process_DRST_msg */ +/***********************************************************************/ +int process_DRST_msg ( unsigned int sua_assoc_id, + int local_sua_id, + int remote_sua_id, + Sua_container sua_asp_msg + ) +{ + + int error_value = 0; + +#ifdef DEBUG + cout << "sua_snm_mgnt.c:DRST received.\n"; +#endif return(error_value); } @@ -193,3 +527,6 @@ int process_DAUD_msg ( unsigned int sua_assoc_id, + + + diff --git a/sualibrary/sua/sua_snm_mgnt.h b/sualibrary/sua/sua_snm_mgnt.h index d3f67e6..41aaecc 100644 --- a/sualibrary/sua/sua_snm_mgnt.h +++ b/sualibrary/sua/sua_snm_mgnt.h @@ -15,7 +15,7 @@ * * ***************************************************************************/ /* - * $Id: sua_snm_mgnt.h,v 1.1 2003/01/14 14:15:37 p82609 Exp $ + * $Id: sua_snm_mgnt.h,v 1.3 2003/08/28 09:30:20 p82609 Exp $ * * SUA implementation according to SUA draft issue 14. * @@ -56,17 +56,55 @@ #include <string> +typedef enum { ssnm_unavailable, + ssnm_available, + ssnm_reserved +} snm_Sua_pc_state_set ; +int sua_send_DAVA( unsigned int Sua_assoc_id, + SS7union pc + ); -int sua_send_DAVA( unsigned int Sua_assoc_id +int sua_send_DUNA( unsigned int Sua_assoc_id, + SS7union pc ); +int process_DUNA_msg ( unsigned int sua_assoc_id, + int local_sua_id, + int remote_sua_id, + Sua_container sua_asp_msg + ); + +int process_DAVA_msg ( unsigned int sua_assoc_id, + int local_sua_id, + int remote_sua_id, + Sua_container sua_asp_msg + ); + int process_DAUD_msg ( unsigned int sua_assoc_id, int local_sua_id, int remote_sua_id, Sua_container sua_asp_msg ); +int process_SCON_msg ( unsigned int sua_assoc_id, + int local_sua_id, + int remote_sua_id, + Sua_container sua_asp_msg + ); + +int process_DUPU_msg ( unsigned int sua_assoc_id, + int local_sua_id, + int remote_sua_id, + Sua_container sua_asp_msg + ); + +int process_DRST_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_syntax.cpp b/sualibrary/sua/sua_syntax.cpp index feb331a..bc21799 100644 --- a/sualibrary/sua/sua_syntax.cpp +++ b/sualibrary/sua/sua_syntax.cpp @@ -15,7 +15,7 @@ * * ***************************************************************************/ /* - * $Id: sua_syntax.cpp,v 1.5 2003/02/17 14:38:08 p82609 Exp $ + * $Id: sua_syntax.cpp,v 1.10 2003/08/26 11:43:57 p82609 Exp $ * * SUA implementation according to SUA draft issue 8. * @@ -97,9 +97,11 @@ void Sua_container::sua_init () { sua_prim.traf_mode_pres = FALSE; sua_prim.err_code_pres = FALSE; sua_prim.status_pres = FALSE; - sua_prim.cong_lvl_pres = FALSE; + sua_prim.ssnm_parm.cong_lvl_pres = FALSE; sua_prim.ASP_id_pres = FALSE; - sua_prim.aff_pc_pres = FALSE; + sua_prim.ssnm_parm.aff_pc_pres = FALSE; + sua_prim.ssnm_parm.SSN_pres = FALSE; + sua_prim.ssnm_parm.SMI_pres = FALSE; sua_prim.hop_count_pres = FALSE; sua_prim.source_addr_pres = FALSE; sua_prim.dest_addr_pres = FALSE; @@ -426,6 +428,42 @@ boolean encode_error_code (string& msg, Sua_error_code_type err_code) { } } +boolean encode_aff_pc (string& msg, Sua_affected_pc_struct& affected_pc) { + /* Reserve 8 bytes for affected pointcode type */ + int pdu_index = msg.size(); + if ((affected_pc.num_aff_pc <= 0) || + (affected_pc.num_aff_pc > 10)) + { + /* Signal error : parameter out of range */ + SYNTAX_ERR.msg_index = pdu_index; + SYNTAX_ERR.error_text = "Encoding : num_aff_pc out of range( <> 1..10) "; + return FALSE; + } + msg.resize(pdu_index + 4 + (affected_pc.num_aff_pc * 4)); + /* Encode tag */ + OVERLAY.dw[0] = htons(0x0012); + msg[pdu_index] = OVERLAY.db[0]; + pdu_index++; + msg[pdu_index] = OVERLAY.db[1]; + pdu_index++; + /* Encode length */ + OVERLAY.dw[1] = htons(4 + (affected_pc.num_aff_pc * 4)); + msg[pdu_index] = OVERLAY.db[2]; + pdu_index++; + msg[pdu_index] = OVERLAY.db[3]; + pdu_index++; + for (int k = 0; k < affected_pc.num_aff_pc; k++) + { + /* Encode value pointcode */ + OVERLAY.dq = htonl(uint32_t(affected_pc.pc[k])); + for (int i = 0; i < 4; i++) + msg[pdu_index + i] = OVERLAY.db[i]; + } + return TRUE; + +} + + /* 1.1.2 SUA specific parameters */ boolean encode_hop_count (string& msg, uint8_t hop_count) { @@ -1161,6 +1199,101 @@ boolean encode_DRN_label (string& msg, Sua_label_struct DRN_label) { /* 1.2 Message encoding procedures */ +/* 1.2.3 Signalling network management messages */ + +boolean encode_ssnm_duna_msg (Sua_primitive_struct& prim, string& msg) { + /* Following parameters are mandatory : + - affected pointcode(single) (list of aff. PC's is not supported yet) + Following parameters are optional : + - routing context + - subsystem number (SSN) + - (SMI) + - cause / user + - Info string + */ + boolean no_error = TRUE; + if (prim.rout_con_pres) + no_error = encode_rout_con (msg, prim.rout_con); + if (prim.ssnm_parm.aff_pc_pres && no_error) + no_error = encode_aff_pc (msg, prim.ssnm_parm.aff_pc); + else { + /* Signal error : mandatory parameter missing */ + SYNTAX_ERR.error_text = "Encoding : DUNA :affected pointcode missing"; + return FALSE; + } + /* no support yet for SSN in msg */ + /*if (prim.ssnm_parm.ssn_pres && no_error) + no_error = encode_ssn (msg, prim.ssnm_parm.ssn);*/ + /* no support yet for Cause/user */ + /*if (prim.ssnm_parm._pres && no_error) + no_error = encode_affected_pc (msg, prim.aff_pc);*/ + if (prim.info_pres && no_error) + no_error = encode_info (msg, prim.info_string); + return no_error; +} + +boolean encode_ssnm_dava_msg (Sua_primitive_struct& prim, string& msg) { + /* Following parameters are mandatory : + - affected pointcode(single) (list of aff. PC's is not supported yet) + Following parameters are optional : + - routing context + - subsystem number (SSN) + - (SMI) + - cause / user + - Info string + */ + boolean no_error = TRUE; + if (prim.rout_con_pres) + no_error = encode_rout_con (msg, prim.rout_con); + if (prim.ssnm_parm.aff_pc_pres && no_error) + no_error = encode_aff_pc (msg, prim.ssnm_parm.aff_pc); + else { + /* Signal error : mandatory parameter missing */ + SYNTAX_ERR.error_text = "Encoding : DAVA :affected pointcode missing"; + return FALSE; + } + /* no support yet for SSN in msg */ + /*if (prim.ssnm_parm.ssn_pres && no_error) + no_error = encode_ssn (msg, prim.ssnm_parm.ssn);*/ + /* no support yet for Cause/user */ + if (prim.info_pres && no_error) + no_error = encode_info (msg, prim.info_string); + return no_error; +} + + + +boolean encode_ssnm_daud_msg (Sua_primitive_struct& prim, string& msg) { + /* Following parameters are mandatory : + - affected pointcode(single) (list of aff. PC's is not supported yet) + Following parameters are optional : + - routing context + - subsystem number (SSN) + - cause / user + - Info string + */ + boolean no_error = TRUE; + if (prim.rout_con_pres) + no_error = encode_rout_con (msg, prim.rout_con); + if (prim.ssnm_parm.aff_pc_pres && no_error) + no_error = encode_aff_pc (msg, prim.ssnm_parm.aff_pc); + else { + /* Signal error : mandatory parameter missing */ + SYNTAX_ERR.error_text = "Encoding : DAUD :affected pointcode missing"; + return FALSE; + } + /* no support yet for SSN in msg */ + /*if (prim.ssnm_parm.ssn_pres && no_error) + no_error = encode_ssn (msg, prim.ssnm_parm.ssn);*/ + /* no support yet for Cause/user */ + /*if (prim.ssnm_parm._pres && no_error) + no_error = encode_affected_pc (msg, prim.aff_pc);*/ + if (prim.info_pres && no_error) + no_error = encode_info (msg, prim.info_string); + return no_error; +} + + /* 1.2.3 ASP Server Management messages */ boolean encode_ASP_up_msg (Sua_primitive_struct& prim, string& msg) { @@ -1171,7 +1304,7 @@ boolean encode_ASP_up_msg (Sua_primitive_struct& prim, string& msg) { boolean no_error = TRUE; if (prim.ASP_id_pres) no_error = encode_ASP_id (msg, prim.ASP_id); - if (prim.info_pres) + if (prim.info_pres && no_error) no_error = encode_info (msg, prim.info_string); return no_error; } @@ -1897,6 +2030,10 @@ Sua_syntax_error_struct Sua_container::sua_encode () { /* Encode message type according to class */ switch (sua_prim.hdr_msg_class) { + case sua_ssnm : + sua_msg[pdu_index] = uint8_t(sua_prim.hdr_msg_type.ssnm); + pdu_index++; + break; case sua_aspsm : sua_msg[pdu_index] = uint8_t(sua_prim.hdr_msg_type.aspsm); pdu_index++; @@ -1925,6 +2062,34 @@ Sua_syntax_error_struct Sua_container::sua_encode () { /* The message length field is encoded at the end, pdu_index is kept at this position */ /* Start encoding of message parameters : double switch ! */ switch (sua_prim.hdr_msg_class) { + case sua_ssnm : + switch (sua_prim.hdr_msg_type.ssnm) { + case ssnm_duna : + no_error = encode_ssnm_duna_msg (sua_prim, sua_msg); + break; + case ssnm_dava : + no_error = encode_ssnm_dava_msg (sua_prim, sua_msg); + break; + case ssnm_daud : + no_error = encode_ssnm_daud_msg (sua_prim, sua_msg); + break; + case ssnm_scon : + ; + break; + case ssnm_dupu : + ; + break; + case ssnm_drst : + ; + break; + default : { + /* Signal error : invalid message type */ + SYNTAX_ERR.msg_index = 3; + SYNTAX_ERR.error_text = "Encoding : Invalid sua_ssnm message type"; + no_error = FALSE; + } + } // End switch ssnm msg type + break; case sua_aspsm : switch (sua_prim.hdr_msg_type.aspsm) { case aspsm_up : @@ -2258,6 +2423,38 @@ boolean decode_error_code (Sua_primitive_struct& prim, string& msg, unsigned int } } +boolean decode_aff_pc (Sua_primitive_struct& prim, string& msg, unsigned int& pdu_index) { + /* The parameter length should be 8 bytes */ + OVERLAY.db[0] = msg[pdu_index + 2]; + OVERLAY.db[1] = msg[pdu_index + 3]; + uint16_t par_len = ntohs(OVERLAY.dw[0]); + if ((par_len > 4)|| (par_len <= 44)) { + /* Decode affected pointcode */ + prim.ssnm_parm.aff_pc_pres = TRUE; + prim.ssnm_parm.aff_pc.num_aff_pc = ((par_len - 4) / 4); + + pdu_index += 4; + + for ( int k = 0; k < prim.ssnm_parm.aff_pc.num_aff_pc; k++) + { + for (int i = 0; i < 4; i++) { + OVERLAY.db[i] = msg[pdu_index + i]; + } + prim.ssnm_parm.aff_pc.pc[k] = ntohl(OVERLAY.dq); + + pdu_index += 4; // Next aff_pc value(if more than 1) or next tag + } + return TRUE; + } + else { + /* Signal error : invalid parameter length */ + SYNTAX_ERR.msg_index = pdu_index + 2; + SYNTAX_ERR.error_text = "Decoding : Invalid affected pointcode length"; + return FALSE; + } +} + + /* 2.1.2 SUA specific parameters */ boolean decode_hop_count (Sua_primitive_struct& prim, string& msg, unsigned int& pdu_index) { @@ -2929,8 +3126,603 @@ boolean decode_DRN_label (Sua_primitive_struct& prim, string& msg, unsigned int& } } +boolean decode_SSN (Sua_primitive_struct& prim, string& msg, unsigned int& pdu_index) { + /* The parameter length should be 8 bytes */ + OVERLAY.db[0] = msg[pdu_index + 2]; + OVERLAY.db[1] = msg[pdu_index + 3]; + uint16_t par_len = ntohs(OVERLAY.dw[0]); + if (par_len == 8) { + /* Decode SSN */ + prim.ssnm_parm.SSN_pres = TRUE; + pdu_index += 4; + for (int i = 0; i < 4; i++) { + OVERLAY.db[i] = msg[pdu_index + i]; + } + prim.ssnm_parm.SSN = ntohl(OVERLAY.db[3]); + pdu_index += 4; // Next tag + return TRUE; + } + else { + /* Signal error : invalid parameter length */ + SYNTAX_ERR.msg_index = pdu_index + 2; + SYNTAX_ERR.error_text = "Decoding : Invalid SSN length"; + return FALSE; + } +} + +boolean decode_SMI (Sua_primitive_struct& prim, string& msg, unsigned int& pdu_index) { + /* The parameter length should be 8 bytes */ + OVERLAY.db[0] = msg[pdu_index + 2]; + OVERLAY.db[1] = msg[pdu_index + 3]; + uint16_t par_len = ntohs(OVERLAY.dw[0]); + if (par_len == 8) { + /* Decode SMI */ + prim.ssnm_parm.SMI_pres = TRUE; + pdu_index += 4; + for (int i = 0; i < 4; i++) { + OVERLAY.db[i] = msg[pdu_index + i]; + } + prim.ssnm_parm.SMI = ntohl(OVERLAY.db[3]); + pdu_index += 4; // Next tag + return TRUE; + } + else { + /* Signal error : invalid parameter length */ + SYNTAX_ERR.msg_index = pdu_index + 2; + SYNTAX_ERR.error_text = "Decoding : Invalid SMI length"; + return FALSE; + } +} + + +boolean decode_cong_lvl (Sua_primitive_struct& prim, string& msg, unsigned int& pdu_index) { + /* The parameter length should be 8 bytes */ + OVERLAY.db[0] = msg[pdu_index + 2]; + OVERLAY.db[1] = msg[pdu_index + 3]; + uint16_t par_len = ntohs(OVERLAY.dw[0]); + if (par_len == 8) { + /* Decode congestion level */ + prim.ssnm_parm.cong_lvl_pres = TRUE; + pdu_index += 4; + for (int i = 0; i < 4; i++) { + OVERLAY.db[i] = msg[pdu_index + i]; + } + prim.ssnm_parm.cong_lvl = ntohl(OVERLAY.db[3]); + pdu_index += 4; // Next tag + return TRUE; + } + else { + /* Signal error : invalid parameter length */ + SYNTAX_ERR.msg_index = pdu_index + 2; + SYNTAX_ERR.error_text = "Decoding : Invalid congestion level length"; + return FALSE; + } +} + + + /* 2.2 Message decoding procedures */ +/* 2.2.2 Signalling Network Management messages */ +boolean decode_ssnm_duna_msg (Sua_primitive_struct& prim, string& msg) { + boolean no_error = TRUE; + uint32_t msg_len = ntohl(OVERLAY.dq); + unsigned int pdu_index = 8; + /* Check whether further parameters are present, at least tag & length fields must be there */ + uint16_t par_tag, par_len; + while ((msg_len >= (pdu_index + 3)) && no_error) { + /* Evaluate parameter length */ + OVERLAY.db[2] = msg[pdu_index + 2]; + OVERLAY.db[3] = msg[pdu_index + 3]; + par_len = ntohs(OVERLAY.dw[1]); + if ((pdu_index + par_len) <= msg_len) { + /* Evaluate parameter tag and call corresponding decoding routine or jump over it */ + OVERLAY.db[0] = msg[pdu_index]; + OVERLAY.db[1] = msg[pdu_index + 1]; + par_tag = ntohs(OVERLAY.dw[0]); + switch (par_tag) { + case 0x0006 : + if (!prim.rout_con_pres) + no_error = decode_rout_con (prim, msg, pdu_index); + else { + /* Signal error : duplicate parameter */ + SYNTAX_ERR.msg_index = pdu_index; + SYNTAX_ERR.error_text = "Decoding : Duplicate Routing context parameter"; + return FALSE; + } + break; + case 0x0012 : + if (!prim.ssnm_parm.aff_pc_pres) + no_error = decode_aff_pc (prim, msg, pdu_index); + else { + /* Signal error : duplicate parameter */ + SYNTAX_ERR.msg_index = pdu_index; + SYNTAX_ERR.error_text = "Decoding : Duplicate affected pointcode parameter"; + return FALSE; + } + break; + case 0x8003: + if (!prim.ssnm_parm.SSN_pres) + no_error = decode_SSN (prim, msg, pdu_index); + else { + /* Signal error : duplicate parameter */ + SYNTAX_ERR.msg_index = pdu_index; + SYNTAX_ERR.error_text = "Decoding : Duplicate SSN parameter"; + return FALSE; + } + break; + case 0x010c: + if (!prim.SCCP_cause_pres) + no_error = decode_SCCP_cause (prim, msg, pdu_index); + else { + /* Signal error : duplicate parameter */ + SYNTAX_ERR.msg_index = pdu_index; + SYNTAX_ERR.error_text = "Decoding : Duplicate SCCP cause parameter"; + return FALSE; + } + case 0x0004 : + if (!prim.info_pres) + no_error = decode_info (prim, msg, pdu_index); + else { + /* Signal error : duplicate parameter */ + SYNTAX_ERR.msg_index = pdu_index; + SYNTAX_ERR.error_text = "Decoding : Duplicate Info parameter"; + return FALSE; + } + break; + default : { + /* Jump over this totally uninteresting parameter to next double word position */ + par_len += (4 - (par_len % 4)) % 4; + pdu_index += par_len; + } + } // End switch parameter tag + } + else { + /* Signal error : invalid parameter length */ + SYNTAX_ERR.msg_index = pdu_index + 2; + SYNTAX_ERR.error_text = "Decoding : Parameter length overflow"; + return FALSE; + } // End parameter length check + } // End while parameters present + + /* No checks for mandatory parameters are needed */ + return no_error; +} + +boolean decode_ssnm_dava_msg (Sua_primitive_struct& prim, string& msg) { + boolean no_error = TRUE; + uint32_t msg_len = ntohl(OVERLAY.dq); + unsigned int pdu_index = 8; + /* Check whether further parameters are present, at least tag & length fields must be there */ + uint16_t par_tag, par_len; + while ((msg_len >= (pdu_index + 3)) && no_error) { + /* Evaluate parameter length */ + OVERLAY.db[2] = msg[pdu_index + 2]; + OVERLAY.db[3] = msg[pdu_index + 3]; + par_len = ntohs(OVERLAY.dw[1]); + if ((pdu_index + par_len) <= msg_len) { + /* Evaluate parameter tag and call corresponding decoding routine or jump over it */ + OVERLAY.db[0] = msg[pdu_index]; + OVERLAY.db[1] = msg[pdu_index + 1]; + par_tag = ntohs(OVERLAY.dw[0]); + switch (par_tag) { + case 0x0006 : + if (!prim.rout_con_pres) + no_error = decode_rout_con (prim, msg, pdu_index); + else { + /* Signal error : duplicate parameter */ + SYNTAX_ERR.msg_index = pdu_index; + SYNTAX_ERR.error_text = "Decoding : Duplicate Routing context parameter"; + return FALSE; + } + break; + case 0x0012 : + if (!prim.ssnm_parm.aff_pc_pres) + no_error = decode_aff_pc (prim, msg, pdu_index); + else { + /* Signal error : duplicate parameter */ + SYNTAX_ERR.msg_index = pdu_index; + SYNTAX_ERR.error_text = "Decoding : Duplicate affected pointcode parameter"; + return FALSE; + } + break; + case 0x8003: + if (!prim.ssnm_parm.SSN_pres) + no_error = decode_SSN (prim, msg, pdu_index); + else { + /* Signal error : duplicate parameter */ + SYNTAX_ERR.msg_index = pdu_index; + SYNTAX_ERR.error_text = "Decoding : Duplicate SSN parameter"; + return FALSE; + } + break; + case 0x010c: + if (!prim.SCCP_cause_pres) + no_error = decode_SCCP_cause (prim, msg, pdu_index); + else { + /* Signal error : duplicate parameter */ + SYNTAX_ERR.msg_index = pdu_index; + SYNTAX_ERR.error_text = "Decoding : Duplicate SCCP cause parameter"; + return FALSE; + } + case 0x0004 : + if (!prim.info_pres) + no_error = decode_info (prim, msg, pdu_index); + else { + /* Signal error : duplicate parameter */ + SYNTAX_ERR.msg_index = pdu_index; + SYNTAX_ERR.error_text = "Decoding : Duplicate Info parameter"; + return FALSE; + } + break; + default : { + /* Jump over this totally uninteresting parameter to next double word position */ + par_len += (4 - (par_len % 4)) % 4; + pdu_index += par_len; + } + } // End switch parameter tag + } + else { + /* Signal error : invalid parameter length */ + SYNTAX_ERR.msg_index = pdu_index + 2; + SYNTAX_ERR.error_text = "Decoding : Parameter length overflow"; + return FALSE; + } // End parameter length check + } // End while parameters present + + /* No checks for mandatory parameters are needed */ + return no_error; +} + + +boolean decode_ssnm_daud_msg (Sua_primitive_struct& prim, string& msg) { + boolean no_error = TRUE; + uint32_t msg_len = ntohl(OVERLAY.dq); + unsigned int pdu_index = 8; + /* Check whether further parameters are present, at least tag & length fields must be there */ + uint16_t par_tag, par_len; + while ((msg_len >= (pdu_index + 3)) && no_error) { + /* Evaluate parameter length */ + OVERLAY.db[2] = msg[pdu_index + 2]; + OVERLAY.db[3] = msg[pdu_index + 3]; + par_len = ntohs(OVERLAY.dw[1]); + if ((pdu_index + par_len) <= msg_len) { + /* Evaluate parameter tag and call corresponding decoding routine or jump over it */ + OVERLAY.db[0] = msg[pdu_index]; + OVERLAY.db[1] = msg[pdu_index + 1]; + par_tag = ntohs(OVERLAY.dw[0]); + switch (par_tag) { + case 0x0006 : + if (!prim.rout_con_pres) + no_error = decode_rout_con (prim, msg, pdu_index); + else { + /* Signal error : duplicate parameter */ + SYNTAX_ERR.msg_index = pdu_index; + SYNTAX_ERR.error_text = "Decoding : Duplicate Routing context parameter"; + return FALSE; + } + break; + case 0x0012 : + if (!prim.ssnm_parm.aff_pc_pres) + no_error = decode_aff_pc (prim, msg, pdu_index); + else { + /* Signal error : duplicate parameter */ + SYNTAX_ERR.msg_index = pdu_index; + SYNTAX_ERR.error_text = "Decoding : Duplicate affected pointcode parameter"; + return FALSE; + } + break; + case 0x8003: + if (!prim.ssnm_parm.SSN_pres) + no_error = decode_SSN (prim, msg, pdu_index); + else { + /* Signal error : duplicate parameter */ + SYNTAX_ERR.msg_index = pdu_index; + SYNTAX_ERR.error_text = "Decoding : Duplicate SSN parameter"; + return FALSE; + } + break; + case 0x010c: + if (!prim.SCCP_cause_pres) + no_error = decode_SCCP_cause (prim, msg, pdu_index); + else { + /* Signal error : duplicate parameter */ + SYNTAX_ERR.msg_index = pdu_index; + SYNTAX_ERR.error_text = "Decoding : Duplicate SCCP cause parameter"; + return FALSE; + } + break; + case 0x0004 : + if (!prim.info_pres) + no_error = decode_info (prim, msg, pdu_index); + else { + /* Signal error : duplicate parameter */ + SYNTAX_ERR.msg_index = pdu_index; + SYNTAX_ERR.error_text = "Decoding : Duplicate Info parameter"; + return FALSE; + } + break; + default : { + /* Jump over this totally uninteresting parameter to next double word position */ + par_len += (4 - (par_len % 4)) % 4; + pdu_index += par_len; + } + } // End switch parameter tag + } + else { + /* Signal error : invalid parameter length */ + SYNTAX_ERR.msg_index = pdu_index + 2; + SYNTAX_ERR.error_text = "Decoding : Parameter length overflow"; + return FALSE; + } // End parameter length check + } // End while parameters present + + /* No checks for mandatory parameters are needed */ + return no_error; +} + + +boolean decode_ssnm_scon_msg (Sua_primitive_struct& prim, string& msg) { + boolean no_error = TRUE; + uint32_t msg_len = ntohl(OVERLAY.dq); + unsigned int pdu_index = 8; + /* Check whether further parameters are present, at least tag & length fields must be there */ + uint16_t par_tag, par_len; + while ((msg_len >= (pdu_index + 3)) && no_error) { + /* Evaluate parameter length */ + OVERLAY.db[2] = msg[pdu_index + 2]; + OVERLAY.db[3] = msg[pdu_index + 3]; + par_len = ntohs(OVERLAY.dw[1]); + if ((pdu_index + par_len) <= msg_len) { + /* Evaluate parameter tag and call corresponding decoding routine or jump over it */ + OVERLAY.db[0] = msg[pdu_index]; + OVERLAY.db[1] = msg[pdu_index + 1]; + par_tag = ntohs(OVERLAY.dw[0]); + switch (par_tag) { + case 0x0006 : + if (!prim.rout_con_pres) + no_error = decode_rout_con (prim, msg, pdu_index); + else { + /* Signal error : duplicate parameter */ + SYNTAX_ERR.msg_index = pdu_index; + SYNTAX_ERR.error_text = "Decoding : Duplicate Routing context parameter"; + return FALSE; + } + break; + case 0x0012 : + if (!prim.ssnm_parm.aff_pc_pres) + no_error = decode_aff_pc (prim, msg, pdu_index); + else { + /* Signal error : duplicate parameter */ + SYNTAX_ERR.msg_index = pdu_index; + SYNTAX_ERR.error_text = "Decoding : Duplicate affected pointcode parameter"; + return FALSE; + } + break; + case 0x8003: + if (!prim.ssnm_parm.SSN_pres) + no_error = decode_SSN (prim, msg, pdu_index); + else { + /* Signal error : duplicate parameter */ + SYNTAX_ERR.msg_index = pdu_index; + SYNTAX_ERR.error_text = "Decoding : Duplicate SSN parameter"; + return FALSE; + } + break; + case 0x0118: + if (!prim.ssnm_parm.cong_lvl_pres) + no_error = decode_cong_lvl (prim, msg, pdu_index); + else { + /* Signal error : duplicate parameter */ + SYNTAX_ERR.msg_index = pdu_index; + SYNTAX_ERR.error_text = "Decoding : Duplicate SCCP cause parameter"; + return FALSE; + } + break; + case 0x0112: + if (!prim.ssnm_parm.SMI_pres) + no_error = decode_SMI (prim, msg, pdu_index); + else { + /* Signal error : duplicate parameter */ + SYNTAX_ERR.msg_index = pdu_index; + SYNTAX_ERR.error_text = "Decoding : Duplicate SCCP cause parameter"; + return FALSE; + } + break; + case 0x0004 : + if (!prim.info_pres) + no_error = decode_info (prim, msg, pdu_index); + else { + /* Signal error : duplicate parameter */ + SYNTAX_ERR.msg_index = pdu_index; + SYNTAX_ERR.error_text = "Decoding : Duplicate Info parameter"; + return FALSE; + } + break; + default : { + /* Jump over this totally uninteresting parameter to next double word position */ + par_len += (4 - (par_len % 4)) % 4; + pdu_index += par_len; + } + } // End switch parameter tag + } + else { + /* Signal error : invalid parameter length */ + SYNTAX_ERR.msg_index = pdu_index + 2; + SYNTAX_ERR.error_text = "Decoding : Parameter length overflow"; + return FALSE; + } // End parameter length check + } // End while parameters present + + /* No checks for mandatory parameters are needed */ + return no_error; +} + + +boolean decode_ssnm_dupu_msg (Sua_primitive_struct& prim, string& msg) { + boolean no_error = TRUE; + uint32_t msg_len = ntohl(OVERLAY.dq); + unsigned int pdu_index = 8; + /* Check whether further parameters are present, at least tag & length fields must be there */ + uint16_t par_tag, par_len; + while ((msg_len >= (pdu_index + 3)) && no_error) { + /* Evaluate parameter length */ + OVERLAY.db[2] = msg[pdu_index + 2]; + OVERLAY.db[3] = msg[pdu_index + 3]; + par_len = ntohs(OVERLAY.dw[1]); + if ((pdu_index + par_len) <= msg_len) { + /* Evaluate parameter tag and call corresponding decoding routine or jump over it */ + OVERLAY.db[0] = msg[pdu_index]; + OVERLAY.db[1] = msg[pdu_index + 1]; + par_tag = ntohs(OVERLAY.dw[0]); + switch (par_tag) { + case 0x0006 : + if (!prim.rout_con_pres) + no_error = decode_rout_con (prim, msg, pdu_index); + else { + /* Signal error : duplicate parameter */ + SYNTAX_ERR.msg_index = pdu_index; + SYNTAX_ERR.error_text = "Decoding : Duplicate Routing context parameter"; + return FALSE; + } + break; + case 0x0012 : + if (!prim.ssnm_parm.aff_pc_pres) + no_error = decode_aff_pc (prim, msg, pdu_index); + else { + /* Signal error : duplicate parameter */ + SYNTAX_ERR.msg_index = pdu_index; + SYNTAX_ERR.error_text = "Decoding : Duplicate affected pointcode parameter"; + return FALSE; + } + break; + case 0x010c: + if (!prim.SCCP_cause_pres) + no_error = decode_SCCP_cause (prim, msg, pdu_index); + else { + /* Signal error : duplicate parameter */ + SYNTAX_ERR.msg_index = pdu_index; + SYNTAX_ERR.error_text = "Decoding : Duplicate SCCP cause parameter"; + return FALSE; + } + break; + case 0x0004 : + if (!prim.info_pres) + no_error = decode_info (prim, msg, pdu_index); + else { + /* Signal error : duplicate parameter */ + SYNTAX_ERR.msg_index = pdu_index; + SYNTAX_ERR.error_text = "Decoding : Duplicate Info parameter"; + return FALSE; + } + break; + default : { + /* Jump over this totally uninteresting parameter to next double word position */ + par_len += (4 - (par_len % 4)) % 4; + pdu_index += par_len; + } + } // End switch parameter tag + } + else { + /* Signal error : invalid parameter length */ + SYNTAX_ERR.msg_index = pdu_index + 2; + SYNTAX_ERR.error_text = "Decoding : Parameter length overflow"; + return FALSE; + } // End parameter length check + } // End while parameters present + + /* No checks for mandatory parameters are needed */ + return no_error; +} + + +boolean decode_ssnm_drst_msg (Sua_primitive_struct& prim, string& msg) { + boolean no_error = TRUE; + uint32_t msg_len = ntohl(OVERLAY.dq); + unsigned int pdu_index = 8; + /* Check whether further parameters are present, at least tag & length fields must be there */ + uint16_t par_tag, par_len; + while ((msg_len >= (pdu_index + 3)) && no_error) { + /* Evaluate parameter length */ + OVERLAY.db[2] = msg[pdu_index + 2]; + OVERLAY.db[3] = msg[pdu_index + 3]; + par_len = ntohs(OVERLAY.dw[1]); + if ((pdu_index + par_len) <= msg_len) { + /* Evaluate parameter tag and call corresponding decoding routine or jump over it */ + OVERLAY.db[0] = msg[pdu_index]; + OVERLAY.db[1] = msg[pdu_index + 1]; + par_tag = ntohs(OVERLAY.dw[0]); + switch (par_tag) { + case 0x0006 : + if (!prim.rout_con_pres) + no_error = decode_rout_con (prim, msg, pdu_index); + else { + /* Signal error : duplicate parameter */ + SYNTAX_ERR.msg_index = pdu_index; + SYNTAX_ERR.error_text = "Decoding : Duplicate Routing context parameter"; + return FALSE; + } + break; + case 0x0012 : + if (!prim.ssnm_parm.aff_pc_pres) + no_error = decode_aff_pc (prim, msg, pdu_index); + else { + /* Signal error : duplicate parameter */ + SYNTAX_ERR.msg_index = pdu_index; + SYNTAX_ERR.error_text = "Decoding : Duplicate affected pointcode parameter"; + return FALSE; + } + break; + case 0x8003: + if (!prim.ssnm_parm.SSN_pres) + no_error = decode_SSN (prim, msg, pdu_index); + else { + /* Signal error : duplicate parameter */ + SYNTAX_ERR.msg_index = pdu_index; + SYNTAX_ERR.error_text = "Decoding : Duplicate SSN parameter"; + return FALSE; + } + break; + case 0x0112: + if (!prim.ssnm_parm.SMI_pres) + no_error = decode_SMI (prim, msg, pdu_index); + else { + /* Signal error : duplicate parameter */ + SYNTAX_ERR.msg_index = pdu_index; + SYNTAX_ERR.error_text = "Decoding : Duplicate SMI parameter"; + return FALSE; + } + break; + case 0x0004 : + if (!prim.info_pres) + no_error = decode_info (prim, msg, pdu_index); + else { + /* Signal error : duplicate parameter */ + SYNTAX_ERR.msg_index = pdu_index; + SYNTAX_ERR.error_text = "Decoding : Duplicate Info parameter"; + return FALSE; + } + break; + default : { + /* Jump over this totally uninteresting parameter to next double word position */ + par_len += (4 - (par_len % 4)) % 4; + pdu_index += par_len; + } + } // End switch parameter tag + } + else { + /* Signal error : invalid parameter length */ + SYNTAX_ERR.msg_index = pdu_index + 2; + SYNTAX_ERR.error_text = "Decoding : Parameter length overflow"; + return FALSE; + } // End parameter length check + } // End while parameters present + + /* No checks for mandatory parameters are needed */ + return no_error; +} + + /* 2.2.3 ASP Server Management messages */ boolean decode_ASP_up_msg (Sua_primitive_struct& prim, string& msg) { @@ -4717,6 +5509,44 @@ Sua_syntax_error_struct Sua_container::sua_decode () { /* Check message class and type, with call to corresponding msg decoding procedure */ pdu_byte = uint8_t(sua_msg[2]); switch (pdu_byte) { + case uint8_t(sua_ssnm) : + sua_prim.hdr_msg_class = sua_ssnm; + /* Check signalling network management msg type */ + pdu_byte = uint8_t(sua_msg[3]); + switch (pdu_byte) { + case uint8_t(ssnm_duna) : + sua_prim.hdr_msg_type.ssnm = ssnm_duna; + no_error = decode_ssnm_duna_msg (sua_prim, sua_msg); + break; + case uint8_t(ssnm_dava) : + sua_prim.hdr_msg_type.ssnm = ssnm_dava; + no_error = decode_ssnm_dava_msg (sua_prim, sua_msg); + break; + case uint8_t(ssnm_daud) : + sua_prim.hdr_msg_type.ssnm = ssnm_daud; + no_error = decode_ssnm_daud_msg (sua_prim, sua_msg); + break; + case uint8_t(ssnm_scon) : + sua_prim.hdr_msg_type.ssnm = ssnm_scon; + no_error = decode_ssnm_scon_msg (sua_prim, sua_msg); + break; + case uint8_t(ssnm_dupu) : + sua_prim.hdr_msg_type.ssnm = ssnm_dupu; + no_error = decode_ssnm_dupu_msg (sua_prim, sua_msg); + break; + case uint8_t(ssnm_drst) : + sua_prim.hdr_msg_type.ssnm = ssnm_drst; + no_error = decode_ssnm_drst_msg (sua_prim, sua_msg); + break; + default : { + sua_prim.hdr_msg_type.ssnm = ssnm_reserved0; + /* Signal error : invalid message type */ + SYNTAX_ERR.msg_index = 3; + SYNTAX_ERR.error_text = "Decoding : Invalid Signalling Network Management message type"; + no_error = FALSE; + } + } // End switch ssnm msg + break; case uint8_t(sua_aspsm) : sua_prim.hdr_msg_class = sua_aspsm; /* Check ASP server management msg type */ diff --git a/sualibrary/sua/sua_syntax.h b/sualibrary/sua/sua_syntax.h index f1890fb..983e3d2 100644 --- a/sualibrary/sua/sua_syntax.h +++ b/sualibrary/sua/sua_syntax.h @@ -15,7 +15,7 @@ * * ***************************************************************************/ /* - * $Id: sua_syntax.h,v 1.1 2003/01/14 14:15:37 p82609 Exp $ + * $Id: sua_syntax.h,v 1.3 2003/08/26 11:43:57 p82609 Exp $ * * SUA implementation according to SUA draft issue 5. * @@ -354,6 +354,26 @@ typedef struct { uint16_t label_value; } Sua_label_struct; +/* the affected Pointcode contains: + - number of aff_pc in msg(max 10 ) + - pointcodes (0..n-1) +*/ +typedef struct { + uint8_t num_aff_pc; + uint32_t pc[10]; +} Sua_affected_pc_struct; + +typedef struct { + boolean aff_pc_pres; + boolean SSN_pres; + boolean SMI_pres; + boolean cong_lvl_pres; + Sua_affected_pc_struct aff_pc; + uint8_t SSN; + uint32_t SMI; + uint8_t cong_lvl; +} Sua_ssnm_struct; + /* And now, we present to you the SUA container, mother of all interfaces */ typedef struct { @@ -370,9 +390,7 @@ typedef struct { boolean traf_mode_pres; boolean err_code_pres; boolean status_pres; - boolean cong_lvl_pres; boolean ASP_id_pres; - boolean aff_pc_pres; /* 1. Common parameter part */ string data_string; string info_string; @@ -382,9 +400,8 @@ typedef struct { Sua_traffic_mode_type traf_mode; Sua_error_code_type err_code; Sua_status_struct status; - uint8_t cong_lvl; + Sua_ssnm_struct ssnm_parm; uint32_t ASP_id; - uint32_t aff_pc; /* 2. SUA specific parameter part presence */ boolean netw_app_pres; boolean hop_count_pres; |