Thread: [Javanetsim-cvs] IceScan icediscover.h, 1.7, 1.8 csubtarget.h, 1.16, 1.17
Status: Beta
Brought to you by:
darkkey
From: Alexander B. <da...@us...> - 2006-12-14 05:21:46
|
Update of /cvsroot/javanetsim/IceScan In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv16556 Modified Files: icediscover.h csubtarget.h Log Message: no message Index: csubtarget.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/csubtarget.h,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** csubtarget.h 13 Dec 2006 20:06:32 -0000 1.16 --- csubtarget.h 14 Dec 2006 05:21:42 -0000 1.17 *************** *** 383,387 **** int j = initiate_connect(scanning_ports); //DBGOUTPUT(j); ! while( ! do_select_round_connect(scanning_ports, subtarget_ports) ) usleep(1000); show_ports(); --- 383,387 ---- int j = initiate_connect(scanning_ports); //DBGOUTPUT(j); ! while( ! do_select_round_connect(scanning_ports, subtarget_ports) ) usleep(1000); show_ports(); *************** *** 506,530 **** } ! int make_connect(csocket *c, icestring &hostname, int port){ ! int rc; ! ! rc = c->connect(hostname.c_str(), port, 0); ! ! switch(rc){ ! case EINPROGRESS: ! case EAGAIN: ! break; ! case ECONNREFUSED: ! DBGOUTPUT("Connection refused."); ! perror("Strange error"); ! exit(0); ! break; ! default: ! perror("Strange error"); ! exit(0); ! break; ! } ! ! return rc; } --- 506,517 ---- } ! int get_max_fd(){ ! int max = -1; ! ! for(int f = 0; f < sockets_size; f++) ! if(scan_sockets[f].sid > max) ! max = scan_sockets[f].sid; ! ! return max; } *************** *** 615,618 **** --- 602,607 ---- int res; bool done = true; + + maxfd = get_max_fd(); fd_rtmp = fd_r; fd_wtmp = fd_w; fd_xtmp = fd_x; Index: icediscover.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icediscover.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** icediscover.h 13 Dec 2006 14:56:11 -0000 1.7 --- icediscover.h 14 Dec 2006 05:21:42 -0000 1.8 *************** *** 77,83 **** } ! bool icmp_echo_ping(const char *hostname, iceparams *par, iceoutput *out){ ! char *t_hostname = (char *) malloc(strlen(hostname) + 1); ! strcpy(t_hostname, hostname); #ifndef __CYGWIN__ --- 77,81 ---- } ! bool icmp_echo_ping(const char *hostname, iceparams *par, iceoutput *out){ #ifndef __CYGWIN__ *************** *** 87,90 **** --- 85,91 ---- #endif //we're root, so can work with raw sockets + + char *t_hostname = (char *) malloc(strlen(hostname) + 1); + strcpy(t_hostname, hostname); if(par->verbose>0) *************** *** 93,96 **** --- 94,98 ---- crawsocket r(AF_INET, SOCK_RAW, IPPROTO_ICMP); + int size = 60 * 1024; int attempts = 0; *************** *** 107,112 **** pthread_t send_thread; pthread_create(&send_thread, NULL, send_icmp_echo, (void *) &dtp); ! while(attempts++ < ECHO_ATTEMPTS){ char hostname[1024]; --- 109,120 ---- pthread_t send_thread; + r.nonblock(true); + pthread_create(&send_thread, NULL, send_icmp_echo, (void *) &dtp); ! ! pthread_join(send_thread, NULL); ! ! return true; ! while(attempts++ < ECHO_ATTEMPTS){ char hostname[1024]; *************** *** 114,118 **** int len = recvfrom(r.get_socketid(), buf, sizeof(buf), 0, NULL, NULL); ! struct ip *ip = (struct ip *) buf; int hdrlen = ip->ip_hl << 2; --- 122,127 ---- int len = recvfrom(r.get_socketid(), buf, sizeof(buf), 0, NULL, NULL); ! ! struct ip *ip = (struct ip *) buf; int hdrlen = ip->ip_hl << 2; *************** *** 121,141 **** int icmplen = len - hdrlen; ! if(icmp -> icmp_type == ICMP_ECHOREPLY && icmp->icmp_id == getpid() && icmplen > 16){ if(par->verbose>0) out->line("Recieved icmp ping host discovery reply (echo_reply)..."); ! free(t_hostname); return true; } } ! ! //pthread_join(send_thread, NULL); --- is it needed here? ! }else if(par->verbose>0) out->line("UID isn't 0, so can't create raw socket => no ICMP ping..."); ! ! free(t_hostname); ! return false; } --- 130,156 ---- int icmplen = len - hdrlen; ! if(icmp -> icmp_type == ICMP_ECHOREPLY && icmp->icmp_id == getpid() && icmplen > 16){ if(par->verbose>0) out->line("Recieved icmp ping host discovery reply (echo_reply)..."); ! pthread_join(send_thread, NULL); ! free(t_hostname); ! r.shutdown(); ! r.close(); return true; } } ! ! ! pthread_join(send_thread, NULL); //--- is it needed here? ! ! r.shutdown(); ! r.close(); ! ! free(t_hostname); }else if(par->verbose>0) out->line("UID isn't 0, so can't create raw socket => no ICMP ping..."); ! return false; } |