diff options
author | Harald Welte <laforge@gnumonks.org> | 2010-07-09 20:57:43 +0200 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2010-07-09 20:57:43 +0200 |
commit | 3dc72b8cff16ffcc9babab9a9892befda44d8c4e (patch) | |
tree | f58253ec5c8a39d8215dacaf8a31297fbe5811e2 /sualibrary/testup | |
parent | 7e7186ca00b33e9735c809ce200e310636006a22 (diff) |
update to sualibrary-0.1.2 from 2002-11-26
* Contains Relaying functionality using hostnames.
* 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 v13
* requires SCTP implementation sctplib-1.0.0-pre19 from www.sctp.de
Diffstat (limited to 'sualibrary/testup')
-rw-r--r-- | sualibrary/testup/Makefile.am | 7 | ||||
-rw-r--r-- | sualibrary/testup/main.cpp | 22 | ||||
-rw-r--r-- | sualibrary/testup/testuser.cpp | 84 | ||||
-rw-r--r-- | sualibrary/testup/testuser.h | 9 |
4 files changed, 91 insertions, 31 deletions
diff --git a/sualibrary/testup/Makefile.am b/sualibrary/testup/Makefile.am index d535bf8..27b0159 100644 --- a/sualibrary/testup/Makefile.am +++ b/sualibrary/testup/Makefile.am @@ -1,7 +1,4 @@ ####### kdevelop will overwrite this part!!! (begin)########## -noinst_LIBRARIES = libtestup.a - -libtestup_a_SOURCES = testuser.cpp main.cpp EXTRA_DIST = main.cpp testuser.cpp testuser.h @@ -13,8 +10,6 @@ testup_SOURCES = main.cpp testuser.cpp testuser.h #testup_LDADD = -L/usr/local/lib -lsua @glib_LIBS@ @sctp_LIBS@ testup_LDADD = ../sua/libsua.a @glib_LIBS@ @sctp_LIBS@ -INCLUDES = -I/usr/local/include -#the library path search path -#sualib_LDFLAGS = $(all_libraries) +INCLUDES = -I../sua -I/usr/local/include AUTOMAKE_OPTIONS = no-dependencies diff --git a/sualibrary/testup/main.cpp b/sualibrary/testup/main.cpp index c032d62..fbcd983 100644 --- a/sualibrary/testup/main.cpp +++ b/sualibrary/testup/main.cpp @@ -15,7 +15,7 @@ * * ***************************************************************************/ /* - * $Id: main.cpp,v 1.1.1.1 2002/02/04 14:30:42 p82609 Exp $ + * $Id: main.cpp,v 1.2 2002/10/15 14:37:59 p82609 Exp $ * * SUA Test user part implementation. * @@ -73,6 +73,15 @@ #include <arpa/inet.h> #include <sys/utsname.h> +#ifdef HAVE_SYS_POLL_H + #include <sys/poll.h> +#else + #define POLLIN 0x001 + #define POLLPRI 0x002 + #define POLLOUT 0x004 + #define POLLERR 0x008 +#endif + using namespace std; char own_hostname[512]; @@ -290,10 +299,13 @@ int main(int argc, char **argv ) res = sua_associate(); // register sua and its users - sctp_registerUserCallback( fileno(stdin), - &testip_stdin_cb, - NULL - ); + res = sctp_registerUserCallback( fileno(stdin), + &testip_stdin_cb, + NULL, + POLLIN|POLLPRI + ); + + cout << "sctp_registerUserCallback result = "<< res << "\n"; init_testip_stdin(); diff --git a/sualibrary/testup/testuser.cpp b/sualibrary/testup/testuser.cpp index 2a9d69f..0d7facf 100644 --- a/sualibrary/testup/testuser.cpp +++ b/sualibrary/testup/testuser.cpp @@ -15,7 +15,7 @@ * * ***************************************************************************/ /* - * $Id: testuser.cpp,v 1.2 2002/02/15 16:20:29 p82609 Exp $ + * $Id: testuser.cpp,v 1.7 2002/11/14 15:29:24 p82609 Exp $ * * SUA Test user part implementation. * @@ -189,13 +189,17 @@ void init_testip_stdin() /***********************************************************************/ /* Test User Part : testip_stdin_cb */ /***********************************************************************/ -void testip_stdin_cb( int fd, - short int revents, - void *dummy +void testip_stdin_cb( int fd, + short int revents, + short int *gotevents, + void *dummy ) { int i,length; + unsigned int k, outstr_len; char readBuffer[256]; + char output_str[INET6_ADDRSTRLEN]; + const char *ptr; unsigned int xsxx; sccp_QOS_str udt_QOS, co_QOS; @@ -237,6 +241,12 @@ void testip_stdin_cb( int fd, /* exit program */ exit(0); } + else if (cmdline.find("term") != cmdline.npos) + { + /* add some cleanups */ + sua_shutdown(); + cout << "Closing down the SCTP & SUA associations\n"; + } else if ((cmdline.find("rep:") != cmdline.npos)) { cout << "Repeat sending CL/CO data to remote end every " << rep_timer << " sec\n"; @@ -254,15 +264,57 @@ void testip_stdin_cb( int fd, else if (cmdline.find("disp mngt") != cmdline.npos) { /* Display the management status of all SUA instances */ - cout << "| Association | SUA management status |\n"; - cout << "+-------------+-----------------------+\n"; + 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 << " |\n"; + 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 << "|-------+--------+--------------------+--------------------+-----|\n"; cout << "ASP status values: see sua_asp_mgnt.h\n"; } else if (cmdline.find("term") != cmdline.npos) @@ -333,7 +385,7 @@ void testip_stdin_cb( int fd, 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.ssn = calling_pty_addr.ssn; called_pty_addr.routing_ind = route_on_name_gt; cout << "DNS/SUA dest hostname = " << addr_str << "\n"; @@ -345,7 +397,7 @@ void testip_stdin_cb( int fd, 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.ssn = 5; calling_pty_addr.routing_ind = route_on_name_gt; cout << "DNS/SUA source hostname = " << addr2_str << "\n"; @@ -364,10 +416,10 @@ void testip_stdin_cb( int fd, 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.ssn = calling_pty_addr.ssn; called_pty_addr.routing_ind = route_on_ssn; - calling_pty_addr.ssn = 255; + calling_pty_addr.ssn = 5; calling_pty_addr.routing_ind = route_on_ssn; cout << "Address of remote end stored. Msg will be sent to this one\n"; @@ -448,8 +500,6 @@ void testip_stdin_cb( int fd, 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; @@ -503,7 +553,8 @@ void timer_expired(unsigned int tID, sendcnt++; cout << "Send a PING\n"; doPingPong(Sua_ConnId); - timerID = sctp_startTimer( 10000, + timerID = sctp_startTimer( 10, /* seconds */ + 0, /* microseconds */ &timer_expired, NULL, NULL @@ -728,7 +779,8 @@ void ulp_ConnConfIndNotif( unsigned int local_sua_Id, // 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, + timerID = sctp_startTimer( 15, /* seconds */ + 0, /* microseconds */ &timer_expired, NULL, NULL diff --git a/sualibrary/testup/testuser.h b/sualibrary/testup/testuser.h index 3b9a7b8..105b018 100644 --- a/sualibrary/testup/testuser.h +++ b/sualibrary/testup/testuser.h @@ -15,7 +15,7 @@ * * ***************************************************************************/ /* - * $Id: testuser.h,v 1.1.1.1 2002/02/04 14:30:42 p82609 Exp $ + * $Id: testuser.h,v 1.2 2002/10/22 13:45:11 p82609 Exp $ * * SUA Test user part implementation. * @@ -77,9 +77,10 @@ using namespace std; void init_testip_stdin(void ); -void testip_stdin_cb( int fd, - short int revents, - void *dummy +void testip_stdin_cb( int fd, + short int revents, + short int *gotevents, + void *dummy ); |