diff options
Diffstat (limited to 'sualibrary/testup/testuser.cpp')
-rw-r--r-- | sualibrary/testup/testuser.cpp | 407 |
1 files changed, 339 insertions, 68 deletions
diff --git a/sualibrary/testup/testuser.cpp b/sualibrary/testup/testuser.cpp index 7e3a45e..48452de 100644 --- a/sualibrary/testup/testuser.cpp +++ b/sualibrary/testup/testuser.cpp @@ -15,7 +15,7 @@ * * ***************************************************************************/ /* - * $Id: testuser.cpp,v 1.3 2003/05/27 14:12:34 p82609 Exp $ + * $Id: testuser.cpp,v 1.7 2003/09/09 08:44:40 p82609 Exp $ * * SUA Test user part implementation. * @@ -87,6 +87,7 @@ unsigned int sendNo = 10; unsigned int sendcnt = 0; unsigned int timeoutval= 1000; unsigned int rep_timer = 0; +boolean mirror = FALSE; sua_Path_str pathinfo; sccp_addr_str calling_pty_addr,called_pty_addr; @@ -94,6 +95,10 @@ short network_app = 0; short seq_control_num = 0; boolean return_option = FALSE; +string disp_ASP_stat[6]; +string disp_PC_stat[2]; + + /***********************************************************************/ /* Test User Part : doPingPong */ /***********************************************************************/ @@ -159,6 +164,16 @@ void init_testip_stdin() { unsigned int xsxx; + disp_ASP_stat[0] = "ASPIDL"; + disp_ASP_stat[1] = "ASPDOW"; + disp_ASP_stat[2] = "ASPDHD"; + disp_ASP_stat[3] = "ASPIAC"; + disp_ASP_stat[4] = "ASPIHD"; + disp_ASP_stat[5] = "ASPACT"; + + disp_PC_stat[0] = "UNAVAI"; + disp_PC_stat[1] = "AVAILA"; + xsxx= sua_getPath( 1, pathinfo ); @@ -188,6 +203,258 @@ void init_testip_stdin() } /***********************************************************************/ +/* Test User Part : testip_disp_assoc_mngt */ +/***********************************************************************/ +void testip_disp_assoc_mngt() +{ + int i, res; + char output_str[INET6_ADDRSTRLEN]; + const char *ptr; + pointcode_str local_pc; + + /* Display the management status of all SUA instances */ + /* display the local pointcodes and IP address */ + + res = sua_get_sourcepc_addr(1, local_pc); + cout << "Display SUA administration and Mangagement data of all associations\n"; + cout << "|----------------------------------------|\n"; + cout << "| Local IP addr : "; + if (local_pc.ipvx.sa.sa_family == AF_INET) + { /* ipv4 */ + ptr = inet_ntop( local_pc.ipvx.sa.sa_family, + &local_pc.ipvx.sin.sin_addr, + output_str, + sizeof(output_str) + ); + cout.width(16); + cout.fill(' '); + cout << output_str; + cout << " |"; + } + else + { /* ipv6 */ + ptr = inet_ntop( local_pc.ipvx.sa.sa_family, + &local_pc.ipvx.sin6.sin6_addr, + output_str, + sizeof(output_str) + ); + cout.width(16); + cout.fill(' '); + cout << output_str << " |"; + } + cout <<"\n"; + cout << "| Local SS7 pointcode : "; + cout.width(6); + cout.fill(' '); + cout << local_pc.ss7.ITU14.pc ; + cout << " |\n";; + cout << "|----------------------------------------|\n"; + + /*display the adjacend remote pointcodes and IP addresses */ + cout << "|--------+--------+--------------------+-------+-----|\n"; + cout << "|Assoc-ID| status | Remote IP addr | DPC | SSN |\n"; + cout << "|--------+--------+--------------------+-------+-----|\n"; + i = 1; + while ( SUA_PATH_NO_ERROR == sua_getPath(i,pathinfo) ) + { + cout.width(3); + cout.fill(' '); + cout << "| " << i ; + cout.width(6); + cout.fill(' '); + cout <<" | "<< disp_ASP_stat[pathinfo.ASP_status] << " | "; + if (pathinfo.remote_addr.pc.ipvx.sa.sa_family == AF_INET) + { /* ipv4 */ + ptr = inet_ntop( pathinfo.remote_addr.pc.ipvx.sa.sa_family, + &pathinfo.remote_addr.pc.ipvx.sin.sin_addr, + output_str, + sizeof(output_str) + ); + cout.width(16); + cout.fill(' '); + cout << output_str; + + cout << " |"; + cout.width(6); + cout.fill(' '); + cout << pathinfo.remote_addr.pc.ss7.ITU14.pc << " | "; + cout.width(3); + cout.fill(' '); + cout << pathinfo.remote_addr.ssn << " |\n"; + } + else + { /* ipv6 */ + ptr = inet_ntop( pathinfo.remote_addr.pc.ipvx.sa.sa_family, + &pathinfo.remote_addr.pc.ipvx.sin6.sin6_addr, + output_str, + sizeof(output_str) + ); + cout << "| "; + cout.width(16); + cout.fill(' '); + cout << output_str << " |"; + cout.width(6); + cout.fill(' '); + cout << pathinfo.local_addr.pc.ss7.ITU14.pc << " | "; + cout.width(3); + cout.fill(' '); + cout << pathinfo.remote_addr.ssn << " |\n"; + } + + i++; + } + cout << "|--------+--------+--------------------+-------+-----|\n"; + +} + +/***********************************************************************/ +/* Test User Part : testip_disp_dest_mngt */ +/***********************************************************************/ +void testip_disp_dest_mngt() +{ + int i, res; + unsigned int assoc_id, stat; + char output_str[INET6_ADDRSTRLEN]; + const char *ptr; + pointcode_str local_pc, dest_pc; + + res = sua_get_sourcepc_addr(1, local_pc); + + /* Display the management status of all SUA destinations */ + /* display the local pointcodes and IP address */ + cout << "Display SUA remote destination SS7 and IP pointcodes\n"; + cout << "|----------------------------------------|\n"; + cout << "| Local IP addr : "; + if (local_pc.ipvx.sa.sa_family == AF_INET) + { /* ipv4 */ + ptr = inet_ntop(local_pc.ipvx.sa.sa_family, + &local_pc.ipvx.sin.sin_addr, + output_str, + sizeof(output_str) + ); + cout.width(16); + cout.fill(' '); + cout << output_str; + + cout << " |"; + + } + else + { /* ipv6 */ + ptr = inet_ntop( local_pc.ipvx.sa.sa_family, + &local_pc.ipvx.sin6.sin6_addr, + output_str, + sizeof(output_str) + ); + + cout.width(16); + cout.fill(' '); + cout << output_str << " | "; + } + cout <<"\n"; + cout << "| Local SS7 pointcode : "; + cout.width(6); + cout.fill(' '); + cout << local_pc.ss7.ITU14.pc << " |\n";; + cout << "|----------------------------------------|\n"; + + /*display the adjacend remote pointcodes and IP addresses */ + cout << "|------+--------+--------------------+--------+--------|\n"; + cout << "|Remote| status | Remote IP addr | DPC |Assoc-ID|\n"; + cout << "|------+--------+--------------------+--------+--------|\n"; + i = 1; + while ( SUA_GETPC_NO_ERROR == sua_get_destpc_addr(i, dest_pc, assoc_id, stat) ) + { + cout << "| " ; + cout.width(3); + cout.fill(' '); + cout << i ; + cout <<" | "; + cout.width(6); + cout.fill(' '); + cout << disp_PC_stat[stat]; + cout.width(0); + cout.fill(' '); + cout << " | "; + if (dest_pc.ipvx.sa.sa_family == AF_INET) + { /* ipv4 */ + ptr = inet_ntop( dest_pc.ipvx.sa.sa_family, + &dest_pc.ipvx.sin.sin_addr, + output_str, + sizeof(output_str) + ); + cout.width(18); + cout.fill(' '); + cout << output_str; + + cout << " |"; + } + else + { /* ipv6 */ + ptr = inet_ntop( dest_pc.ipvx.sa.sa_family, + &dest_pc.ipvx.sin6.sin6_addr, + output_str, + sizeof(output_str) + ); + cout.width(18); + cout.fill(' '); + cout << output_str; + cout << " |"; + } + + cout.width(7); + cout.fill(' '); + cout << dest_pc.ss7.ITU14.pc ; + cout.width(0); + cout.fill(' '); + cout << " | "; + cout.width(3); + cout.fill(' '); + cout << assoc_id ; + cout <<" |\n"; + + i++; + } + cout << "|------+--------+--------------------+--------+--------|\n"; + +} + + + +/***********************************************************************/ +/* Test User Part : testip_admin_lock_asp */ +/***********************************************************************/ +void testip_admin_lock_asp(unsigned int sua_assoc_id) +{ + unsigned int res; + + res = sua_DeActivate_assoc( sua_assoc_id ); + cout << "Lock " << sua_assoc_id << " Associations\n"; +} + +/***********************************************************************/ +/* Test User Part : testip_admin_unlock_asp */ +/***********************************************************************/ +void testip_admin_unlock_asp(unsigned int sua_assoc_id) +{ + unsigned int res; + + res = sua_Activate_assoc( sua_assoc_id ); + cout << "Unlock " << sua_assoc_id << " ASP\n"; +} +/***********************************************************************/ +/* Test User Part : testip_admin_snm_daud */ +/***********************************************************************/ +void testip_snm_daud() +{ + int res; + + cout << "Send a Destination AUDIT to all know remote destinations\n"; + + res = sua_send_daud(); +} + +/***********************************************************************/ /* Test User Part : testip_stdin_cb */ /***********************************************************************/ void testip_stdin_cb( int fd, @@ -196,15 +463,11 @@ void testip_stdin_cb( int fd, void *dummy ) { - int i,length; - unsigned int k, outstr_len; + int length; char readBuffer[256]; - char output_str[INET6_ADDRSTRLEN]; - const char *ptr; unsigned int xsxx; - sccp_QOS_str udt_QOS, co_QOS; - unsigned int Sua_ConnId=0; + unsigned int Sua_ConnId=0, sua_assoc_id; cin.getline(readBuffer,256,'\n'); string cmdline(readBuffer,strlen(readBuffer)); @@ -228,10 +491,15 @@ void testip_stdin_cb( int fd, cout << " destGT: - set destination Global Title\n"; cout << " some-other-string - send this Connectionless to destaddrx\n"; cout << " co:some-other-string - send this Connection-oriented\n"; - cout << " disp mngt - display ASP status of remote nodes\n"; + cout << " disp assoc mngt - display status of all associations\n"; + cout << " disp dest mngt - display status of all destinations\n"; + cout << " lock:x - put association x in inactive/down state\n"; + cout << " enable:x - put association x in activequit state\n"; + cout << " mirror:act - activate testup mirror function\n"; + cout << " mirror:dact - deactivate testup mirror function\\n"; cout << " return-option: - change return-option(toggle) on/off\n"; //cout << " rep:x - repeat sending x CLDT/CODT msg to remote\n"; - //cout << " term - terminate all the present associations(SCTP & SUA)\n"; + cout << " term - terminate all the present associations(SCTP & SUA)\n"; //cout << " restart - restart all the present associations(SCTP & SUA)\n"; } else if ((cmdline.find("quit") != cmdline.npos) || @@ -253,71 +521,56 @@ void testip_stdin_cb( int fd, { cout << "Repeat sending CL/CO data to remote end every " << rep_timer << " sec\n"; } + else if ((cmdline.find("mirror:act") != cmdline.npos)) + { + mirror = TRUE; + cout << "Mirror activated!\n"; + } + else if ((cmdline.find("mirror:dact") != cmdline.npos)) + { + mirror = FALSE; + cout << "Mirror dactivated!\n"; + } else if ((cmdline.find("return-option:") != cmdline.npos)) { return_option = !return_option; cout << "Return option = " << return_option << " (0= FALSE, 1= TRUE)\n"; } - else if (cmdline.find("lock") != cmdline.npos) + else if (cmdline.find("lock:") != cmdline.npos) { /* lock up all SUA instances for ASP management */ - cout << "SUA mgnt administratived locked\n"; + /* get association id */ + string associd_str( cmdline, (cmdline.find("lock:")+5),cmdline.length()); + char *associd_char = new char [associd_str.length()+1]; + associd_str.copy(associd_char, associd_str.length()); + associd_char[associd_str.length()] = '\0'; + sua_assoc_id = atoi(associd_char); + testip_admin_lock_asp(sua_assoc_id); + } + else if (cmdline.find("enable:") != cmdline.npos) + { + /* unlock all SUA instances for ASP management */ + string associd_str( cmdline, (cmdline.find("enable:")+7),cmdline.length()); + char *associd_char = new char [associd_str.length()+1]; + associd_str.copy(associd_char, associd_str.length()); + associd_char[associd_str.length()] = '\0'; + sua_assoc_id = atoi(associd_char); + testip_admin_unlock_asp(sua_assoc_id); + } + else if (cmdline.find("snm audit") != cmdline.npos) + { + /* do a DAUD for all destinations */ + testip_snm_daud(); } - else if (cmdline.find("disp mngt") != cmdline.npos) + else if (cmdline.find("disp assoc mngt") != cmdline.npos) { /* Display the management status of all SUA instances */ - cout << "Display SUA administration and Mangagement data of all associations\n"; - cout << "|-------+--------+--------------------+--------------------+-----|\n"; - cout << "| Assoc | status | local IP addr | Remote IP addr | SSN |\n"; - cout << "|-------+--------+--------------------+--------------------+-----|\n"; - i = 1; - while ( SUA_PATH_NO_ERROR == sua_getPath(i,pathinfo) ) - { - cout << "| " << i <<" | "<< pathinfo.ASP_status << " | "; - if (pathinfo.local_addr.pc.ipvx.sa.sa_family == AF_INET) - { /* ipv4 */ - ptr = inet_ntop( pathinfo.local_addr.pc.ipvx.sa.sa_family, - &pathinfo.local_addr.pc.ipvx.sin.sin_addr, - output_str, - sizeof(output_str) - ); - cout << output_str; - outstr_len = strlen(output_str); - for(k=0; k < (20 - 3 - outstr_len); k++) - cout << " "; - cout << "| "; - ptr = inet_ntop( pathinfo.remote_addr.pc.ipvx.sa.sa_family, - &pathinfo.remote_addr.pc.ipvx.sin.sin_addr, - output_str, - sizeof(output_str) - ); - cout << output_str; - for(k=0; k < /*(20 -*/ 3 /*- outstr_len)*/; k++) - cout << " "; - cout << "| "; - cout << pathinfo.remote_addr.ssn << " |\n"; - } - else - { /* ipv6 */ - ptr = inet_ntop( pathinfo.local_addr.pc.ipvx.sa.sa_family, - &pathinfo.local_addr.pc.ipvx.sin6.sin6_addr, - output_str, - sizeof(output_str) - ); - cout << output_str << " | "; - ptr = inet_ntop( pathinfo.remote_addr.pc.ipvx.sa.sa_family, - &pathinfo.remote_addr.pc.ipvx.sin6.sin6_addr, - output_str, - sizeof(output_str) - ); - cout << output_str << " | "; - cout << pathinfo.remote_addr.ssn << " |\n"; - } - - i++; - } - cout << "|-------+--------+--------------------+--------------------+-----|\n"; - cout << "ASP status values: see sua_asp_mgnt.h\n"; + testip_disp_assoc_mngt(); + } + else if (cmdline.find("disp dest mngt") != cmdline.npos) + { + /* Display the management status of all SUA instances */ + testip_disp_dest_mngt(); } else if (cmdline.find("term") != cmdline.npos) { @@ -411,9 +664,9 @@ void testip_stdin_cb( int fd, called_pty_addr.address_fields_present.name_gt = GT_present; called_pty_addr.address_fields_present.ssn_port = ssn_present; called_pty_addr.address_fields_present.field_in_header = include_nothing; - called_pty_addr.name.GT.Translation_Type = 0; - called_pty_addr.name.GT.Numbering_Plan = 0; - called_pty_addr.name.GT.Nature_of_Address = 0; + called_pty_addr.name.GT.Translation_Type = 1; + called_pty_addr.name.GT.Numbering_Plan = 1; + called_pty_addr.name.GT.Nature_of_Address = 3; strcpy(called_pty_addr.name.GT.digits,addr_str.c_str()); called_pty_addr.name.GT.nr_of_digits= addr_str.length(); called_pty_addr.ssn = calling_pty_addr.ssn; @@ -643,6 +896,7 @@ void ulp_ClDataIndNotif( unsigned int local_sua_Id, int length=datalen; int index; unsigned int Sua_ConnId; + unsigned int xsxx; char databuffer[MAX_DATA_LENGTH]; sccp_QOS_str QOS; sccp_addr_str clg,cld; @@ -679,7 +933,24 @@ void ulp_ClDataIndNotif( unsigned int local_sua_Id, cout << "************************************************************\n"; cout << ">"; cout << flush; - + + /* check if mirror is active */ + if (mirror) + { + cout << "UDT msg mirrored\n"; + /* char *databuffer = new char[cmdline.length()]; + cmdline.copy(databuffer, cmdline.length()); + length = cmdline.length();*/ + + xsxx = Send_sua_primitive(N_UNITDATA, + Sua_ConnId, + QOS, + called_pty_addr, + calling_pty_addr, + databuffer, + length + ); + } } |