Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:manfred999
synack
02-fix_prototypes.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 02-fix_prototypes.patch of Package synack
--- synack-1.0/synack.c.orig 2015-04-13 14:55:35.992917465 +0200 +++ synack-1.0/synack.c 2015-04-13 15:18:16.059235688 +0200 @@ -68,31 +68,6 @@ struct hostent *myadr, *hisadr; struct in_addr inaddr; struct addrinfo *webadr; -time_t tvsub(); -char * tvprint(); -void err(); -void record_stats(); -void statistics(); -void print_stats(); -void printstats(); -void callstats(); -double xsqrt(); -int isnumeric(); -void rterror(); -void err_print(); -void sock_init(); -void sock_close(); -struct timeval* get_time(); -int connect_start(); -int select_start(); -int select_condition(); -void connection_tcp(); -void *call_connection(); -int max_threads(); -void finish(); -void exit_interrupt(); -void interval_between_synacks(); - int percent1 = 25; /* 1st percentile */ int percent2 = 75; /* 2nd percentile */ int hisport = 22; /* port number of server */ @@ -148,236 +123,6 @@ Common options:\n\ -s ## Timeout in millisecs \n\ "; -int -main(argc,argv) -int argc; -char **argv; -{ - -/* ********************************************************************** */ - - int sin_size,c; - int nconnect,nselect,nselectval,nread,nweb,nset; - int iscount = FALSE; - long int count = 1; - long int i,j; - int sig = 0; - int time = 0; - unsigned long gw=0; - - - char myip[] = MYIP; - char *hisip ; - char *wmaddr = "wmatthews=home-1.stanford.edu"; - char *wmport = "80"; - char line[MAXLINE +1]; - - struct timeval *sendtime; - struct timeval *recvtime; - struct timeval tv1; - struct timeval tv2; - struct timeval tval; - - timer interval; - - time_t rtt = 0; - - - /* Command line options */ - - long int length = 0; /* default value */ - int interval_sec = 0; /* time interval between connections in secs */ - int interval_usec = 0; /* time interval between connections in microsecs */ - - -/* **************************************************************************** */ - - - if (argc < 1) goto usage; - - while ((c = getopt(argc, argv, "p:k:i:u:z:Z:s:S:")) != -1) { - switch (c) { - - case 'p': - hisport = atoi(optarg); - break; - - case 'k': - length = atoi(optarg); - break; - - case 'i': - interval_sec = atoi(optarg); - break; - - case 'u': - interval_usec = atoi(optarg); - break; - - case 'z': - percent1 = atoi(optarg); - break; - - case 'Z': - percent2 = atoi(optarg); - break; - - case 'S': - secs = atoi(optarg); - break; - - case 's': - millisecs = atoi(optarg); - break; - - default: - goto usage; - } - } - - if ( (interval_sec == 0) && (interval_usec == 0) ) { - interval.sec = 1; - interval.usec = 0; - } - else { - interval.sec = interval_sec; - interval.usec = interval_usec; - } - - if ( (interval_sec == 0) && (interval_usec < 20000) ) - interval.usec = 20000; - - if (length > 0) - iscount = TRUE; - - if (secs == 0 && millisecs == 0) - secs = 10; - - tvalfresh.tv_sec = secs; - tvalfresh.tv_usec = millisecs * 1000; - - if (optind == argc) - goto usage; - hisip = argv[optind]; - - myadr = gethostbyname(myip); - hisadr = gethostbyname(hisip); - - my_addr.sin_family = AF_INET; - my_addr.sin_port = htons(MYPORT); - my_addr.sin_addr.s_addr = htonl(INADDR_ANY); - myadr = gethostbyaddr((char *) &my_addr.sin_addr.s_addr, sizeof(struct in_addr*), AF_INET); - bzero(&(my_addr.sin_zero), 8); - - if(!hisadr) { - rterror("Unknown host %s", hisip); - exit(EX_NOHOST); - } - - - his_addr.sin_family = AF_INET; - his_addr.sin_port = htons(hisport); - his_addr.sin_addr.s_addr = inet_addr(inet_ntoa(*((struct in_addr*)hisadr->h_addr))); - - if (isnumeric(hisip)) { - hisadr->h_name = NULL; - hisadr = gethostbyaddr((char *) &his_addr.sin_addr.s_addr, sizeof(struct in_addr*), AF_INET); - } - - bzero(&(his_addr.sin_zero), 8); - - if (isnumeric(hisip) && !hisadr) { - printf("\nAddress Information of Server not listed in Domain\n"); - hisadr = gethostbyname(hisip); - } - - if (!isnumeric(hisadr->h_name)) - ipname = hisadr->h_name; - else - ipname = NULL; - - ipnum = (char *)inet_ntoa(*((struct in_addr *)hisadr->h_addr)); - - if (iscount) - if (ipname != NULL) - printf("\nSYN-ACK to %s (%s), %d Packets\n\n", ipname, ipnum, length); - else - printf("\nSYN-ACK to %s , %d Packets\n\n", ipnum, length); - else - if (ipname != NULL) - printf("\nSYN-ACK to %s (%s)\n\n", ipname, ipnum); - else - printf("\nSYN-ACK to %s \n\n", ipnum); - - -/* -** BEGINNNING OF CONNECT LOOP -** ----------------------------- -*/ - - while ( (!sig) && (((iscount) && (count <= length)) || (!iscount)) ) { - - - threads = max_threads(secs,interval); - - i = pthread_create(&tid[counter], NULL, call_connection, NULL); - - j = pthread_detach(tid[counter]); - - if (i == EAGAIN) { - printf("\n\nOOPS....LIMIT REACHED ON MAX. NO OF THREADS :( \n\n"); - goto out_of_loop; - } - - if (counter == threads) - counter = 0; - else - counter++; - - interval_between_synacks(interval); - - count++; - - synack.seq_no++; - - signal(SIGINT, exit_interrupt); - - if (key == 1) { - finish(); - } - - } - -/* -** END OF CONNECT LOOP -** ------------------- -*/ - - out_of_loop: - - printf("\nWaiting for outstanding packets (if any)..........\n\n"); - - for (i=0; i <= threads; i++) - pthread_join(tid[i], NULL); - - sleep(1); - - print_stats(&synack); - exit(0); - - usage: - fprintf(stderr,Usage); - exit(1); - -} - - -/* -** END OF MAIN() -** ------------- -*/ - - /* @@ -563,6 +308,30 @@ int percent1,percent2; /* +** XSQRT -- Square root +** -------------------- +*/ + +double +xsqrt(y) +double y; +{ + double t, x; + + if (y <= 0) + return(0); + + x = (y < 1.0) ? 1.0 : y; + do { + t = x; + x = (t + (y/t))/2.0; + } while (0 < x && x < t); + + return(x); +} + + +/* ** PRINT_STATS -- Prints RTT Statistics ** ------------------------------------ */ @@ -611,30 +380,6 @@ stats *sp; } -/* -** XSQRT -- Square root -** -------------------- -*/ - -double -xsqrt(y) -double y; -{ - double t, x; - - if (y <= 0) - return(0); - - x = (y < 1.0) ? 1.0 : y; - do { - t = x; - x = (t + (y/t))/2.0; - } while (0 < x && x < t); - - return(x); -} - - /* ** PRINTSTATS -- PRINTS RTT STATISTICS ** ----------------------------------- @@ -1020,3 +765,232 @@ void interval_between_synacks ( timer in usleep(time); } + +int +main(argc,argv) +int argc; +char **argv; +{ + +/* ********************************************************************** */ + + int sin_size,c; + int nconnect,nselect,nselectval,nread,nweb,nset; + int iscount = FALSE; + long int count = 1; + long int i,j; + int sig = 0; + int time = 0; + unsigned long gw=0; + + + char myip[] = MYIP; + char *hisip ; + char *wmaddr = "wmatthews=home-1.stanford.edu"; + char *wmport = "80"; + char line[MAXLINE +1]; + + struct timeval *sendtime; + struct timeval *recvtime; + struct timeval tv1; + struct timeval tv2; + struct timeval tval; + + timer interval; + + time_t rtt = 0; + + + /* Command line options */ + + long int length = 0; /* default value */ + int interval_sec = 0; /* time interval between connections in secs */ + int interval_usec = 0; /* time interval between connections in microsecs */ + + +/* **************************************************************************** */ + + + if (argc < 1) goto usage; + + while ((c = getopt(argc, argv, "p:k:i:u:z:Z:s:S:")) != -1) { + switch (c) { + + case 'p': + hisport = atoi(optarg); + break; + + case 'k': + length = atoi(optarg); + break; + + case 'i': + interval_sec = atoi(optarg); + break; + + case 'u': + interval_usec = atoi(optarg); + break; + + case 'z': + percent1 = atoi(optarg); + break; + + case 'Z': + percent2 = atoi(optarg); + break; + + case 'S': + secs = atoi(optarg); + break; + + case 's': + millisecs = atoi(optarg); + break; + + default: + goto usage; + } + } + + if ( (interval_sec == 0) && (interval_usec == 0) ) { + interval.sec = 1; + interval.usec = 0; + } + else { + interval.sec = interval_sec; + interval.usec = interval_usec; + } + + if ( (interval_sec == 0) && (interval_usec < 20000) ) + interval.usec = 20000; + + if (length > 0) + iscount = TRUE; + + if (secs == 0 && millisecs == 0) + secs = 10; + + tvalfresh.tv_sec = secs; + tvalfresh.tv_usec = millisecs * 1000; + + if (optind == argc) + goto usage; + hisip = argv[optind]; + + myadr = gethostbyname(myip); + hisadr = gethostbyname(hisip); + + my_addr.sin_family = AF_INET; + my_addr.sin_port = htons(MYPORT); + my_addr.sin_addr.s_addr = htonl(INADDR_ANY); + myadr = gethostbyaddr((char *) &my_addr.sin_addr.s_addr, sizeof(struct in_addr*), AF_INET); + bzero(&(my_addr.sin_zero), 8); + + if(!hisadr) { + rterror("Unknown host %s", hisip); + exit(EX_NOHOST); + } + + + his_addr.sin_family = AF_INET; + his_addr.sin_port = htons(hisport); + his_addr.sin_addr.s_addr = inet_addr(inet_ntoa(*((struct in_addr*)hisadr->h_addr))); + + if (isnumeric(hisip)) { + hisadr->h_name = NULL; + hisadr = gethostbyaddr((char *) &his_addr.sin_addr.s_addr, sizeof(struct in_addr*), AF_INET); + } + + bzero(&(his_addr.sin_zero), 8); + + if (isnumeric(hisip) && !hisadr) { + printf("\nAddress Information of Server not listed in Domain\n"); + hisadr = gethostbyname(hisip); + } + + if (!isnumeric(hisadr->h_name)) + ipname = hisadr->h_name; + else + ipname = NULL; + + ipnum = (char *)inet_ntoa(*((struct in_addr *)hisadr->h_addr)); + + if (iscount) + if (ipname != NULL) + printf("\nSYN-ACK to %s (%s), %d Packets\n\n", ipname, ipnum, length); + else + printf("\nSYN-ACK to %s , %d Packets\n\n", ipnum, length); + else + if (ipname != NULL) + printf("\nSYN-ACK to %s (%s)\n\n", ipname, ipnum); + else + printf("\nSYN-ACK to %s \n\n", ipnum); + + +/* +** BEGINNNING OF CONNECT LOOP +** ----------------------------- +*/ + + while ( (!sig) && (((iscount) && (count <= length)) || (!iscount)) ) { + + + threads = max_threads(secs,interval); + + i = pthread_create(&tid[counter], NULL, call_connection, NULL); + + j = pthread_detach(tid[counter]); + + if (i == EAGAIN) { + printf("\n\nOOPS....LIMIT REACHED ON MAX. NO OF THREADS :( \n\n"); + goto out_of_loop; + } + + if (counter == threads) + counter = 0; + else + counter++; + + interval_between_synacks(interval); + + count++; + + synack.seq_no++; + + signal(SIGINT, exit_interrupt); + + if (key == 1) { + finish(); + } + + } + +/* +** END OF CONNECT LOOP +** ------------------- +*/ + + out_of_loop: + + printf("\nWaiting for outstanding packets (if any)..........\n\n"); + + for (i=0; i <= threads; i++) + pthread_join(tid[i], NULL); + + sleep(1); + + print_stats(&synack); + exit(0); + + usage: + fprintf(stderr,Usage); + exit(1); + +} + + +/* +** END OF MAIN() +** ------------- +*/
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor