888 lines
28 KiB
C++
888 lines
28 KiB
C++
/***************************************************************************
|
|
testuser.cpp - description
|
|
-------------------
|
|
begin : Tue Jan 8 2002
|
|
copyright : (C) 2002 by Lode Coene
|
|
email : lode.coene@siemens.atea.be
|
|
***************************************************************************/
|
|
|
|
/***************************************************************************
|
|
* *
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
* it under the terms of the GNU General Public License as published by *
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
* (at your option) any later version. *
|
|
* *
|
|
***************************************************************************/
|
|
/*
|
|
* $Id: testuser.cpp,v 1.2 2002/02/15 16:20:29 p82609 Exp $
|
|
*
|
|
* SUA Test user part implementation.
|
|
*
|
|
* Author(s): Lode Coene
|
|
*
|
|
*
|
|
* Copyright (C) 2001 by Siemens Atea, Herentals, Belgium.
|
|
*
|
|
* Realized in co-operation between Siemens Atea and
|
|
* Siemens AG, Munich, Germany.
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License
|
|
* as published by the Free Software Foundation; either version 2
|
|
* of the License, or (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
*
|
|
* Contact: gery.verwimp@siemens.atea.be
|
|
* lode.coene@siemens.atea.be
|
|
*
|
|
* Purpose: This code-file defines the SUA Test User Part application and
|
|
* has definitions for:
|
|
* - Do pingpong with remote TESTUP
|
|
* - Handle pong
|
|
* - initialise the Test User part application
|
|
* - Test User Part STDIN function -> reading keyboard and
|
|
* sending the info to SUA
|
|
* - Handle TESTUP expired timers
|
|
* - TESTUP Connectionless Data Ind Notification(from SUA)
|
|
* - TESTUP CO Connection Ind Notification(from SUA)
|
|
* - TESTUP CO Connection Confirmation Ind Notification(from SUA)
|
|
* - TESTUP CO Data Ind Notification(from SUA)
|
|
* - TESTUP CO DisConnection Ind Notification(from SUA)
|
|
*/
|
|
|
|
#include "sctp.h"
|
|
#include "sua.h"
|
|
|
|
#ifdef LINUX
|
|
#include <unistd.h>
|
|
#endif
|
|
|
|
#include <iostream>
|
|
#include <string>
|
|
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
#include <sys/time.h>
|
|
#define MAX_DATA_LENGTH 2000
|
|
#define MAX_DATACHUNK_PDU_LENGTH 251
|
|
|
|
extern char own_hostname[512];
|
|
|
|
//global variable for ULP instance(one connection only)
|
|
unsigned int timerID = 0;
|
|
unsigned int refID = 0;
|
|
unsigned int sendNo = 10;
|
|
unsigned int sendcnt = 0;
|
|
unsigned int timeoutval= 1000;
|
|
unsigned int rep_timer = 0;
|
|
|
|
sua_Path_str pathinfo;
|
|
sccp_addr_str calling_pty_addr,called_pty_addr;
|
|
short network_app = 0;
|
|
short seq_control_num = 0;
|
|
boolean return_option = FALSE;
|
|
|
|
/***********************************************************************/
|
|
/* Test User Part : doPingPong */
|
|
/***********************************************************************/
|
|
int doPingPong(unsigned int Sua_ConnId )
|
|
{
|
|
int length;
|
|
sccp_addr_str co_clg, co_cld;
|
|
sccp_QOS_str co_QOS;
|
|
unsigned int xsxx;
|
|
string cmdline= "ping";
|
|
|
|
co_QOS.prot_class = class2;
|
|
co_QOS.in_sequence = false;
|
|
co_QOS.sequence_number = 0;
|
|
co_QOS.return_msg_on_error = 0;
|
|
co_QOS.importance = 0;
|
|
|
|
co_clg.address_fields_present.pc = no_pc_present;
|
|
co_clg.address_fields_present.name_gt = no_name_present;
|
|
co_clg.address_fields_present.ssn_port = no_sap_present;
|
|
co_clg.address_fields_present.field_in_header = include_nothing;
|
|
|
|
co_cld.address_fields_present.pc = no_pc_present;
|
|
co_cld.address_fields_present.name_gt = no_name_present;
|
|
co_cld.address_fields_present.ssn_port = no_sap_present;
|
|
co_cld.address_fields_present.field_in_header = include_nothing;
|
|
|
|
|
|
char *databuffer = new char[cmdline.length()];
|
|
cmdline.copy(databuffer, cmdline.length());
|
|
length = cmdline.length();
|
|
|
|
xsxx = Send_sua_primitive(N_DATA_REQ,
|
|
Sua_ConnId,
|
|
co_QOS,
|
|
co_cld,
|
|
co_clg,
|
|
databuffer,
|
|
length
|
|
);
|
|
|
|
#ifdef DEBUG
|
|
cout << "testuser.c++: Returned "<< xsxx <<" from the send (1==association error, 0==success, -1==could not send)\n";
|
|
#endif
|
|
|
|
delete databuffer;
|
|
return(xsxx);
|
|
}
|
|
|
|
/***********************************************************************/
|
|
/* Test User Part : handle_Pong */
|
|
/***********************************************************************/
|
|
int handlePong()
|
|
{
|
|
|
|
|
|
return(0);
|
|
}
|
|
/***********************************************************************/
|
|
/* Test User Part : init_testip_stdin */
|
|
/***********************************************************************/
|
|
void init_testip_stdin()
|
|
{
|
|
unsigned int xsxx;
|
|
|
|
xsxx= sua_getPath( 1,
|
|
pathinfo
|
|
);
|
|
|
|
/*cout << "result getpath = " << xsxx << "\n"; */
|
|
|
|
calling_pty_addr.address_fields_present.pc = ipvx_pc_present;
|
|
calling_pty_addr.address_fields_present.name_gt = no_name_present;
|
|
calling_pty_addr.address_fields_present.ssn_port = ssn_present;
|
|
calling_pty_addr.address_fields_present.field_in_header = include_nothing;
|
|
calling_pty_addr.pc.ipvx = pathinfo.local_addr.pc.ipvx;
|
|
calling_pty_addr.pc.ss7 = pathinfo.local_addr.pc.ss7;
|
|
calling_pty_addr.ssn = pathinfo.local_addr.ssn;
|
|
calling_pty_addr.routing_ind = route_on_ssn;
|
|
calling_pty_addr.network_apperance = network_app;
|
|
|
|
called_pty_addr.address_fields_present.pc = ipvx_pc_present;
|
|
called_pty_addr.address_fields_present.name_gt = no_name_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.pc.ipvx = pathinfo.remote_addr.pc.ipvx;
|
|
called_pty_addr.pc.ss7 = pathinfo.remote_addr.pc.ss7;
|
|
called_pty_addr.ssn = pathinfo.remote_addr.ssn;
|
|
called_pty_addr.routing_ind = route_on_ssn;
|
|
called_pty_addr.network_apperance = network_app;
|
|
}
|
|
|
|
/***********************************************************************/
|
|
/* Test User Part : testip_stdin_cb */
|
|
/***********************************************************************/
|
|
void testip_stdin_cb( int fd,
|
|
short int revents,
|
|
void *dummy
|
|
)
|
|
{
|
|
int i,length;
|
|
char readBuffer[256];
|
|
unsigned int xsxx;
|
|
|
|
sccp_QOS_str udt_QOS, co_QOS;
|
|
unsigned int Sua_ConnId=0;
|
|
|
|
cin.getline(readBuffer,256,'\n');
|
|
string cmdline(readBuffer,strlen(readBuffer));
|
|
|
|
if (cmdline.length() == 0)
|
|
{
|
|
cout << ">>";
|
|
cout << flush;
|
|
|
|
return;
|
|
}
|
|
else if (cmdline.find("help") != cmdline.npos)
|
|
{
|
|
cout << "Available commands are:\n";
|
|
cout << " help - display this page\n";
|
|
cout << " quit/exit - exit the program\n";
|
|
cout << " destaddr6: - set destination ipv6 address \n";
|
|
cout << " destaddr4: - set destination ipv4 address \n";
|
|
cout << " destname: - set destination hostname\n";
|
|
cout << " destpc: - set destination SS7 pointcode(decimal)\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 << " 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 << " restart - restart all the present associations(SCTP & SUA)\n";
|
|
}
|
|
else if ((cmdline.find("quit") != cmdline.npos) ||
|
|
(cmdline.find("exit") != cmdline.npos))
|
|
{
|
|
/* add some cleanups */
|
|
sua_terminate();
|
|
cout << "exiting the Test User program\n";
|
|
/* exit program */
|
|
exit(0);
|
|
}
|
|
else if ((cmdline.find("rep:") != cmdline.npos))
|
|
{
|
|
cout << "Repeat sending CL/CO data to remote end every " << rep_timer << " sec\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)
|
|
{
|
|
/* lock up all SUA instances for ASP management */
|
|
cout << "SUA mgnt administratived locked\n";
|
|
}
|
|
else if (cmdline.find("disp mngt") != cmdline.npos)
|
|
{
|
|
/* Display the management status of all SUA instances */
|
|
cout << "| Association | SUA management status |\n";
|
|
cout << "+-------------+-----------------------+\n";
|
|
i = 1;
|
|
while ( SUA_PATH_NO_ERROR == sua_getPath(i,pathinfo) )
|
|
{
|
|
cout << "| " << i <<" | "<< pathinfo.ASP_status << " |\n";
|
|
i++;
|
|
}
|
|
cout << "+-------------+-----------------------+\n";
|
|
cout << "ASP status values: see sua_asp_mgnt.h\n";
|
|
}
|
|
else if (cmdline.find("term") != cmdline.npos)
|
|
{
|
|
/* Terminate the following associations */
|
|
cout << "| Association | SUA management status |\n";
|
|
|
|
}
|
|
else if (cmdline.find("destaddr6:") != cmdline.npos)
|
|
{
|
|
/* get destination address, convert it and store in cld */
|
|
string addr_str(cmdline, (cmdline.find("destaddr6:")+10),cmdline.length());
|
|
cout << "dest address = " << addr_str << "\n";
|
|
char *addr_char = new char [addr_str.length()+1];
|
|
addr_str.copy(addr_char, addr_str.length());
|
|
addr_char[addr_str.length()] = '\0';
|
|
called_pty_addr.address_fields_present.pc = ipvx_pc_present;
|
|
called_pty_addr.address_fields_present.name_gt = no_name_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.pc.ipvx.sa.sa_family = AF_INET6;
|
|
called_pty_addr.pc.ipvx.sin6.sin6_port = SUA_PORT;
|
|
inet_pton( AF_INET6,
|
|
addr_char,
|
|
&called_pty_addr.pc.ipvx.sin6.sin6_addr
|
|
);
|
|
called_pty_addr.ssn = 255;
|
|
called_pty_addr.routing_ind = route_on_ssn;
|
|
|
|
calling_pty_addr.ssn = 255;
|
|
calling_pty_addr.routing_ind = route_on_ssn;
|
|
|
|
cout << "Address of remote end stored. Msg will be sent to this one\n";
|
|
}
|
|
else if (cmdline.find("destaddr4:") != cmdline.npos)
|
|
{
|
|
/* get destination address, convert it and store in cld */
|
|
string addr_str( cmdline, (cmdline.find("destaddr4:")+10),cmdline.length());
|
|
cout << "dest address " << addr_str << "\n";
|
|
char *addr_char = new char [addr_str.length()+1];
|
|
addr_str.copy(addr_char, addr_str.length());
|
|
addr_char[addr_str.length()] = '\0';
|
|
called_pty_addr.address_fields_present.pc = ipvx_pc_present;
|
|
called_pty_addr.address_fields_present.name_gt = no_name_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.pc.ipvx.sa.sa_family = AF_INET;
|
|
called_pty_addr.pc.ipvx.sin.sin_port = SUA_PORT;
|
|
inet_pton( AF_INET,
|
|
addr_char,
|
|
&called_pty_addr.pc.ipvx.sin.sin_addr
|
|
);
|
|
called_pty_addr.ssn = 255;
|
|
called_pty_addr.routing_ind = route_on_ssn;
|
|
|
|
calling_pty_addr.ssn = 255;
|
|
calling_pty_addr.routing_ind = route_on_ssn;
|
|
|
|
cout << "Address of remote end stored. Msg will be sent to this one\n";
|
|
}
|
|
else if (cmdline.find("destname:") != cmdline.npos)
|
|
{
|
|
/* get destination hostname, convert it and store in cld */
|
|
string addr_str(cmdline, (cmdline.find("destname:")+9),cmdline.length());
|
|
|
|
called_pty_addr.address_fields_present.pc = no_pc_present;
|
|
called_pty_addr.address_fields_present.name_gt = hostname_present;
|
|
called_pty_addr.address_fields_present.ssn_port = ssn_present;
|
|
called_pty_addr.address_fields_present.field_in_header = include_nothing;
|
|
strcpy(called_pty_addr.name.HostName,addr_str.c_str());
|
|
called_pty_addr.ssn = 255;
|
|
called_pty_addr.routing_ind = route_on_name_gt;
|
|
|
|
cout << "DNS/SUA dest hostname = " << addr_str << "\n";
|
|
cout << "Address of remote end stored. Msg will be sent to this one\n";
|
|
|
|
string addr2_str = own_hostname;
|
|
/*char *name2_char = new char [addr2_str.length()+1]; */
|
|
/*name2_char = shost_to_suaname ( addr2_str ); */
|
|
|
|
calling_pty_addr.address_fields_present.name_gt = hostname_present;
|
|
strcpy(calling_pty_addr.name.HostName, own_hostname);
|
|
calling_pty_addr.ssn = 255;
|
|
calling_pty_addr.routing_ind = route_on_name_gt;
|
|
cout << "DNS/SUA source hostname = " << addr2_str << "\n";
|
|
|
|
}
|
|
else if (cmdline.find("destpc:") != cmdline.npos)
|
|
{
|
|
/* get destination address, convert it and store in cld */
|
|
string addr_str(cmdline, (cmdline.find("destpc:")+7),cmdline.length());
|
|
cout << "dest address = " << addr_str << "\n";
|
|
char *addr_char = new char [addr_str.length()+1];
|
|
addr_str.copy(addr_char, addr_str.length());
|
|
addr_char[addr_str.length()] = '\0';
|
|
called_pty_addr.address_fields_present.pc = ss7_pc_present;
|
|
called_pty_addr.address_fields_present.name_gt = no_name_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.pc.ss7.ITU24.family = ITU24bit;
|
|
called_pty_addr.pc.ss7.ITU24.pc = atoi(addr_char);
|
|
called_pty_addr.ssn = 255;
|
|
called_pty_addr.routing_ind = route_on_ssn;
|
|
|
|
calling_pty_addr.ssn = 255;
|
|
calling_pty_addr.routing_ind = route_on_ssn;
|
|
|
|
cout << "Address of remote end stored. Msg will be sent to this one\n";
|
|
}
|
|
else if (cmdline.find("co:") != cmdline.npos)
|
|
{
|
|
|
|
co_QOS.prot_class = class2;
|
|
co_QOS.in_sequence = false;
|
|
co_QOS.sequence_number = 0;
|
|
co_QOS.return_msg_on_error = return_option;
|
|
co_QOS.importance = 0;
|
|
|
|
xsxx= sua_getPath( 1,
|
|
pathinfo
|
|
);
|
|
|
|
//cout << "result getpath = " << xsxx << "\n";
|
|
|
|
calling_pty_addr.address_fields_present.pc = called_pty_addr.address_fields_present.pc;
|
|
calling_pty_addr.address_fields_present.name_gt = called_pty_addr.address_fields_present.name_gt;
|
|
calling_pty_addr.routing_ind = called_pty_addr.routing_ind;
|
|
calling_pty_addr.address_fields_present.ssn_port = called_pty_addr.address_fields_present.ssn_port;
|
|
calling_pty_addr.address_fields_present.field_in_header = called_pty_addr.address_fields_present.field_in_header ;
|
|
|
|
string addr3_str = own_hostname;
|
|
/*char *name3_char = new char [addr3_str.length()+1];*/
|
|
/*name3_char = shost_to_suaname ( addr3_str );*/
|
|
strcpy(calling_pty_addr.name.HostName, own_hostname);
|
|
|
|
|
|
calling_pty_addr.pc.ipvx = pathinfo.local_addr.pc.ipvx;
|
|
calling_pty_addr.ssn = pathinfo.local_addr.ssn;
|
|
calling_pty_addr.pc.ss7 = pathinfo.local_addr.pc.ss7 ;
|
|
|
|
char *databuffer = new char[cmdline.length()];
|
|
cmdline.copy(databuffer, cmdline.length());
|
|
length = cmdline.length();
|
|
|
|
xsxx = Send_sua_primitive(N_CONNECT_REQ,
|
|
Sua_ConnId,
|
|
co_QOS,
|
|
called_pty_addr,
|
|
calling_pty_addr,
|
|
databuffer,
|
|
length
|
|
);
|
|
|
|
refID = Sua_ConnId;
|
|
|
|
#ifdef DEBUG
|
|
cout << "testuser.c++: Returned "<< xsxx <<" from the send (1==association error, 0==success, -1==could not send)\n";
|
|
#endif
|
|
|
|
delete databuffer;
|
|
}
|
|
else
|
|
{
|
|
|
|
udt_QOS.prot_class = class0;
|
|
udt_QOS.in_sequence = false;
|
|
udt_QOS.sequence_number = seq_control_num++;
|
|
udt_QOS.return_msg_on_error = return_option;
|
|
udt_QOS.importance = 0;
|
|
|
|
xsxx= sua_getPath( 1,
|
|
pathinfo
|
|
);
|
|
|
|
#ifdef DEBUG
|
|
cout << "Sequence control parameter = " << udt_QOS.sequence_number << "\n";
|
|
#endif
|
|
|
|
calling_pty_addr.address_fields_present.pc = called_pty_addr.address_fields_present.pc;
|
|
calling_pty_addr.address_fields_present.name_gt = called_pty_addr.address_fields_present.name_gt;
|
|
calling_pty_addr.routing_ind = called_pty_addr.routing_ind;
|
|
calling_pty_addr.address_fields_present.ssn_port = called_pty_addr.address_fields_present.ssn_port;
|
|
calling_pty_addr.address_fields_present.field_in_header = called_pty_addr.address_fields_present.field_in_header;
|
|
|
|
string addr4_str = own_hostname;
|
|
/*char *name4_char = new char [addr4_str.length()+1]; */
|
|
/*name4_char = shost_to_suaname ( addr4_str ); */
|
|
strcpy(calling_pty_addr.name.HostName, own_hostname);
|
|
|
|
calling_pty_addr.pc.ipvx = pathinfo.local_addr.pc.ipvx;
|
|
calling_pty_addr.ssn = pathinfo.local_addr.ssn;
|
|
calling_pty_addr.pc.ss7 = pathinfo.local_addr.pc.ss7 ;
|
|
|
|
char *databuffer = new char[cmdline.length()];
|
|
cmdline.copy(databuffer, cmdline.length());
|
|
length = cmdline.length();
|
|
|
|
xsxx = Send_sua_primitive(N_UNITDATA,
|
|
Sua_ConnId,
|
|
udt_QOS,
|
|
called_pty_addr,
|
|
calling_pty_addr,
|
|
databuffer,
|
|
length
|
|
);
|
|
|
|
#ifdef DEBUG
|
|
cout << "testuser.c++: Returned "<< xsxx <<" from the send (1==association error, 0==success, -1==could not send)\n";
|
|
#endif
|
|
|
|
delete databuffer;
|
|
}
|
|
cout << ">";
|
|
cout << flush;
|
|
|
|
}
|
|
|
|
|
|
#define SEND_EVENTS_WHEN_TIMER_EXPIRES 1
|
|
/***********************************************************************/
|
|
/* Test user part : timer_expired */
|
|
/***********************************************************************/
|
|
void timer_expired(unsigned int tID,
|
|
void *associationIDvoid,
|
|
void *unused
|
|
)
|
|
{
|
|
int length;
|
|
sccp_addr_str co_clg, co_cld;
|
|
sccp_QOS_str co_QOS;
|
|
string cmdline= "ping";
|
|
|
|
unsigned int Sua_ConnId=refID;
|
|
|
|
cout << "************************************************************\n";
|
|
cout << "** Timer expired **\n";
|
|
if (sendcnt < sendNo) {
|
|
sendcnt++;
|
|
cout << "Send a PING\n";
|
|
doPingPong(Sua_ConnId);
|
|
timerID = sctp_startTimer( 10000,
|
|
&timer_expired,
|
|
NULL,
|
|
NULL
|
|
);
|
|
}
|
|
else
|
|
{
|
|
cout << "Terminate the SUA connection\n";
|
|
unsigned int xsxx;
|
|
|
|
co_QOS.prot_class = class2;
|
|
co_QOS.in_sequence = false;
|
|
co_QOS.sequence_number = 0;
|
|
co_QOS.return_msg_on_error = 0;
|
|
co_QOS.importance = 0;
|
|
|
|
|
|
char *databuffer = new char[cmdline.length()];
|
|
cmdline.copy(databuffer, cmdline.length());
|
|
length = cmdline.length();
|
|
|
|
xsxx = Send_sua_primitive( N_RELEASE_REQ,
|
|
Sua_ConnId,
|
|
co_QOS,
|
|
co_cld,
|
|
co_clg,
|
|
databuffer,
|
|
length
|
|
);
|
|
|
|
#ifdef DEBUG
|
|
cout << "testuser.c++: Returned "<< xsxx <<" from the send (1==association error, 0==success, -1==could not send)\n";
|
|
#endif
|
|
|
|
delete databuffer;
|
|
}
|
|
}
|
|
|
|
/***********************************************************************/
|
|
/* Test user part: ulp_ClDataIndNotif */
|
|
/***********************************************************************/
|
|
void ulp_ClDataIndNotif( unsigned int local_sua_Id,
|
|
unsigned int primitive,
|
|
unsigned int datalen
|
|
)
|
|
{
|
|
int length=datalen;
|
|
int index;
|
|
unsigned int Sua_ConnId;
|
|
char databuffer[MAX_DATA_LENGTH];
|
|
sccp_QOS_str QOS;
|
|
sccp_addr_str clg,cld;
|
|
|
|
Receive_sua_primitive ( primitive,
|
|
Sua_ConnId,
|
|
QOS,
|
|
cld,
|
|
clg,
|
|
databuffer,
|
|
length
|
|
);
|
|
|
|
index = 0;
|
|
|
|
cout << "testuser.c++: Hey, we received ClDataIndNotif \n";
|
|
|
|
//check for primitive, receive only unitdata's up till know
|
|
switch (primitive)
|
|
{
|
|
case (N_UNITDATA):
|
|
called_pty_addr = clg;
|
|
cout << "************************************************************\n";
|
|
cout << "** UNITDATA message received **\n";
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
|
|
string disp_output(databuffer,index, (length - index));
|
|
cout << "************************************************************\n";
|
|
cout << disp_output << "\n";
|
|
cout << "************************************************************\n";
|
|
cout << ">";
|
|
cout << flush;
|
|
|
|
}
|
|
|
|
|
|
/***********************************************************************/
|
|
/* Test user part: ulp_ConnIndNotif */
|
|
/***********************************************************************/
|
|
void ulp_ConnIndNotif( unsigned int local_sua_Id,
|
|
unsigned int ConnId,
|
|
unsigned int datalen
|
|
)
|
|
{
|
|
int length=datalen;
|
|
int index;
|
|
unsigned int Sua_ConnId, primitive;
|
|
char databuffer[MAX_DATA_LENGTH];
|
|
sccp_QOS_str QOS;
|
|
sccp_addr_str clg,cld;
|
|
|
|
Receive_sua_primitive ( primitive,
|
|
Sua_ConnId,
|
|
QOS,
|
|
cld,
|
|
clg,
|
|
databuffer,
|
|
length
|
|
);
|
|
|
|
index = 0;
|
|
|
|
string cmdline(databuffer,index, (length - index));
|
|
|
|
cout << "testuser.c++: Hey, we received ConnIndNotif \n";
|
|
|
|
//check for primitive
|
|
switch (primitive)
|
|
{
|
|
case (N_CONNECT_IND):
|
|
called_pty_addr = clg;
|
|
cld = called_pty_addr;
|
|
clg = calling_pty_addr;
|
|
cout << "************************************************************\n";
|
|
cout << "** CONNECT REQ IND message received **\n";
|
|
// send Connect confirm back
|
|
// this is the responding side of the connection
|
|
|
|
sccp_QOS_str co_QOS;
|
|
unsigned int xsxx;
|
|
|
|
co_QOS.prot_class = class2;
|
|
co_QOS.in_sequence = false;
|
|
co_QOS.sequence_number = 0;
|
|
co_QOS.return_msg_on_error = 0;
|
|
co_QOS.importance = 0;
|
|
|
|
if (cmdline.find("refused") != cmdline.npos)
|
|
{
|
|
// mirror received data back to initiator
|
|
cout << "length = " << length << "\n";
|
|
|
|
xsxx = Send_sua_primitive(N_CONNECT_REFUSED,
|
|
Sua_ConnId,
|
|
QOS,
|
|
cld,
|
|
clg,
|
|
databuffer,
|
|
length
|
|
);
|
|
}
|
|
else
|
|
{
|
|
xsxx = Send_sua_primitive(N_CONNECT_RESP,
|
|
Sua_ConnId,
|
|
QOS,
|
|
cld,
|
|
clg,
|
|
databuffer,
|
|
length
|
|
);
|
|
}
|
|
|
|
cout << "testuser.c++: Returned "<< xsxx <<" from the send (1==association error, 0==success, -1==could not send)\n";
|
|
|
|
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
|
|
string disp_output(databuffer,index, (length - index));
|
|
cout << "************************************************************\n";
|
|
cout << disp_output << "\n";
|
|
cout << "************************************************************\n";
|
|
cout << ">";
|
|
cout << flush;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************/
|
|
/* Test user part: ulp_ConnConfIndNotif */
|
|
/***********************************************************************/
|
|
void ulp_ConnConfIndNotif( unsigned int local_sua_Id,
|
|
unsigned int ConnId,
|
|
unsigned int datalen
|
|
)
|
|
{
|
|
int length=datalen;
|
|
int index;
|
|
unsigned int Sua_ConnId, primitive;
|
|
char databuffer[MAX_DATA_LENGTH];
|
|
sccp_QOS_str QOS;
|
|
sccp_addr_str clg,cld;
|
|
|
|
Receive_sua_primitive ( primitive,
|
|
Sua_ConnId,
|
|
QOS,
|
|
cld,
|
|
clg,
|
|
databuffer,
|
|
length
|
|
);
|
|
|
|
index = 0;
|
|
|
|
cout << "testuser.c++: Hey, we received ConnConfIndNotif\n";
|
|
|
|
//check for primitive, receive only unitdata's up till know
|
|
switch (primitive)
|
|
{
|
|
case (N_CONNECT_CONF):
|
|
|
|
cout << "************************************************************\n";
|
|
cout << "** CONNECT CONFIRM IND message received **\n";
|
|
// received the connection confirmed msg
|
|
// this is the initiator of the connection
|
|
// start a timer for sending the data to the responder
|
|
timerID = sctp_startTimer( 5000,
|
|
&timer_expired,
|
|
NULL,
|
|
NULL
|
|
);
|
|
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
|
|
string disp_output(databuffer,index, (length - index));
|
|
cout << "************************************************************\n";
|
|
cout << disp_output << "\n";
|
|
cout << "************************************************************\n";
|
|
cout << ">";
|
|
cout << flush;
|
|
|
|
}
|
|
|
|
|
|
/***********************************************************************/
|
|
/* Test user part: ulp_ConnDataIndNotif */
|
|
/***********************************************************************/
|
|
void ulp_ConnDataIndNotif( unsigned int local_sua_Id,
|
|
unsigned int ConnId,
|
|
unsigned int datalen
|
|
)
|
|
{
|
|
int length=datalen;
|
|
int index;
|
|
unsigned int Sua_ConnId, primitive;
|
|
char databuffer[MAX_DATA_LENGTH];
|
|
sccp_QOS_str QOS;
|
|
sccp_addr_str clg,cld;
|
|
|
|
Receive_sua_primitive ( primitive,
|
|
Sua_ConnId,
|
|
QOS,
|
|
cld,
|
|
clg,
|
|
databuffer,
|
|
length
|
|
);
|
|
|
|
index = 0;
|
|
string cmdline(databuffer,length);
|
|
|
|
cout << "testuser.c++: Hey, we received ConnDataIndNotif \n";
|
|
|
|
//check for primitive, receive only unitdata's up till know
|
|
switch (primitive)
|
|
{
|
|
case (N_DATA_IND):
|
|
|
|
cout << "************************************************************\n";
|
|
cout << "** CO DATA message received **\n";
|
|
// received a connection oriented data
|
|
// if it is a ping send back a pong
|
|
// if it is a pong, start timer for the next data or disconnect
|
|
|
|
if (cmdline.find("ping") != cmdline.npos)
|
|
{}
|
|
else if (cmdline.find("pong") != cmdline.npos)
|
|
{
|
|
cout << "End: pong received\n";
|
|
}
|
|
else
|
|
cout << "Not in ping-pong mode\n";
|
|
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
|
|
string disp_output(databuffer,index, (length - index));
|
|
cout << "************************************************************\n";
|
|
cout << disp_output << "\n";
|
|
cout << "************************************************************\n";
|
|
cout << ">";
|
|
cout << flush;
|
|
|
|
}
|
|
|
|
|
|
/***********************************************************************/
|
|
/* Test user part: ulp_DisconnIndNotif */
|
|
/***********************************************************************/
|
|
void ulp_DisConnIndNotif( unsigned int local_sua_Id,
|
|
unsigned int ConnId,
|
|
unsigned int cause,
|
|
unsigned int datalen
|
|
)
|
|
{
|
|
int length=datalen;
|
|
int index;
|
|
unsigned int Sua_ConnId, primitive;
|
|
char databuffer[MAX_DATA_LENGTH];
|
|
sccp_QOS_str QOS;
|
|
sccp_addr_str clg,cld;
|
|
|
|
Receive_sua_primitive ( primitive,
|
|
Sua_ConnId,
|
|
QOS,
|
|
cld,
|
|
clg,
|
|
databuffer,
|
|
length
|
|
);
|
|
|
|
index = 0;
|
|
|
|
cout << "testuser.c++: Hey, we received DisConnIndNotif\n";
|
|
|
|
//check for primitive, receive only unitdata's up till know
|
|
switch (primitive)
|
|
{
|
|
case (N_RELEASE_REQ):
|
|
|
|
cout << "************************************************************\n";
|
|
cout << "** RELEASE REQUEST:DISCONNECT IND message received **\n";
|
|
break;
|
|
case (N_RELEASE_CONF):
|
|
|
|
cout << "************************************************************\n";
|
|
cout << "** RELEASE CONFIRM:DISCONNECT IND message received **\n";
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
|
|
string disp_output(databuffer,index, (length - index));
|
|
cout << "************************************************************\n";
|
|
cout << disp_output << "\n";
|
|
cout << "************************************************************\n";
|
|
cout << ">";
|
|
cout << flush;
|
|
|
|
}
|
|
|
|
// end of module testuser.c++
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|