[Javanetsim-cvs] IceScan/icesockets crawsocket.h, 1.12, 1.13 csocket.h, 1.18, 1.19 sock_err.h, 1.2,
Status: Beta
Brought to you by:
darkkey
From: Alexander B. <da...@us...> - 2006-12-17 09:59:45
|
Update of /cvsroot/javanetsim/IceScan/icesockets In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv19563/icesockets Modified Files: crawsocket.h csocket.h sock_err.h sock_pcap.h sock_types.h sock_win.h Log Message: Index: sock_types.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icesockets/sock_types.h,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** sock_types.h 16 Dec 2006 20:44:19 -0000 1.16 --- sock_types.h 17 Dec 2006 09:59:40 -0000 1.17 *************** *** 14,18 **** #include <signal.h> ! #include <pcap.h> #include <errno.h> --- 14,20 ---- #include <signal.h> ! #ifndef __CYGWIN__ ! #include <pcap.h> ! #endif #include <errno.h> *************** *** 22,26 **** #define __NO_LIBPCRE__ #else ! #include <netinet/if_ether.h> #include <sys/socket.h> --- 24,31 ---- #define __NO_LIBPCRE__ #else ! ! #ifndef __CYGWIN__ ! #include <netinet/if_ether.h> ! #endif #include <sys/socket.h> *************** *** 64,67 **** --- 69,76 ---- typedef int SOCKET; + typedef uint16_t my_uint16_t; + typedef uint32_t my_uint32_t; + typedef uint8_t my_uint8_t; + #define Bzero(a,b) bzero(a, b) #else Index: crawsocket.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icesockets/crawsocket.h,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** crawsocket.h 16 Dec 2006 21:05:28 -0000 1.12 --- crawsocket.h 17 Dec 2006 09:59:40 -0000 1.13 *************** *** 87,92 **** } ! int sendto(const char *hostname, const void *msg, int len, unsigned int flags){ ! return csocket::sendto(hostname, 0, (sockbuf_type) msg, len, flags); } --- 87,92 ---- } ! int sendto(const char *hostname, const char *msg, int len, unsigned int flags){ ! return csocket::sendto(hostname, 0, msg, len, flags); } Index: csocket.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icesockets/csocket.h,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** csocket.h 16 Dec 2006 21:05:28 -0000 1.18 --- csocket.h 17 Dec 2006 09:59:40 -0000 1.19 *************** *** 121,152 **** } }else{ ! fd_set sset; ! struct timeval tv; ! ! nonblock(true); ! ! ::connect(sid, (struct sockaddr *) &saddress, sizeof(struct sockaddr)); ! FD_ZERO(&sset); ! FD_SET(sid, &sset); ! tv.tv_sec = timeout; ! tv.tv_usec = 0; ! SOCKET ndfs = sid + 1; ! ! #ifdef WIN32 ! int res = select(0, NULL, &sset, NULL, &tv); ! #else ! int res = select(ndfs, NULL, &sset, NULL, &tv); ! #endif ! if (res == SOCKET_ERROR && errno != EINTR){ ! nonblock(false); return ICESOCK_ERRNO; ! } else if (res == 0){ ! nonblock(false); return ICESOCK_TIMEOUT; ! } else nonblock(false); } ! return 0; } --- 121,162 ---- } }else{ ! fd_set sset; ! struct timeval tv; ! ! nonblock(true); ! ! ::connect(sid, (struct sockaddr *) &saddress, sizeof(struct sockaddr)); ! FD_ZERO(&sset); ! FD_SET(sid, &sset); ! tv.tv_sec = timeout; ! tv.tv_usec = 0; ! SOCKET ndfs = sid + 1; ! ! #ifdef WIN32 ! int res = select(0, NULL, &sset, NULL, &tv); ! #else ! int res = select(ndfs, NULL, &sset, NULL, &tv); ! #endif ! nonblock(false); ! ! if (res == SOCKET_ERROR && errno != EINTR){ ! return ICESOCK_ERRNO; ! } else if (res == 0){ ! int sopt, soptlen; ! getsockopt(SOL_SOCKET, SO_ERROR, (char *) &sopt, (socklen_t *) &soptlen); ! ! DBGOUTPUT(sopt); ! ! if(sopt == ECONNREFUSED) ! return ICESOCK_CONNREF; ! else ! return ICESOCK_TIMEOUT; ! } } ! return 0; } *************** *** 201,205 **** } ! int recvfrom(sockbuf_type buf, int len, int flags, char *srchostname, int *srchostport){ int rsize; struct sockaddr_in from; --- 211,215 ---- } ! int recvfrom(sockbuf_type buf, int len, int flags, char *srchostname, int *srchostport){ int rsize; struct sockaddr_in from; *************** *** 216,220 **** } ! int sendto(const char *hostname, int port, const sockbuf_type msg, int len, unsigned int flags){ struct sockaddr_in saddress; int slen; --- 226,230 ---- } ! int sendto(const char *hostname, int port, const char* msg, int len, unsigned int flags){ struct sockaddr_in saddress; int slen; Index: sock_err.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icesockets/sock_err.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** sock_err.h 15 Dec 2006 15:27:57 -0000 1.2 --- sock_err.h 17 Dec 2006 09:59:40 -0000 1.3 *************** *** 5,8 **** --- 5,9 ---- #define ICESOCK_TIMEOUT 10 // timeout in when connecting or recieving + #define ICESOCK_CONNREF 15 // connection refused #define ICESOCK_PERROR -1 // socket operation error, see perror() #define ICESOCK_ERRNO -2 // socket operation error, see ERRNO Index: sock_win.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icesockets/sock_win.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** sock_win.h 16 Dec 2006 20:44:19 -0000 1.2 --- sock_win.h 17 Dec 2006 09:59:40 -0000 1.3 *************** *** 32,36 **** } ! void stop_sockets(){} int getpid(){ --- 32,38 ---- } ! void stop_sockets(){ ! WSACleanup(); ! } int getpid(){ *************** *** 43,47 **** #else ! typedef int WSA_DATA; int start_sockets(){ } --- 45,49 ---- #else ! typedef int WSADATA; int start_sockets(){ } Index: sock_pcap.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icesockets/sock_pcap.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** sock_pcap.h 16 Dec 2006 20:44:19 -0000 1.4 --- sock_pcap.h 17 Dec 2006 09:59:40 -0000 1.5 *************** *** 9,18 **** #define _sock_pcap_H ! #ifdef __CYGWIN__ typedef int pcap_t; ! pcap_t* init_pcap(){ return NULL; } char* readip_pcap(pcap_t* pd, unsigned int *len, struct timeval *rcvd_time){ return NULL; --- 9,22 ---- #define _sock_pcap_H ! #ifdef __CYGWIN__ //There's no pcap in Cygwin :( typedef int pcap_t; ! pcap_t* init_pcap(int index = 0){ return NULL; } + + void listdev_pcap(){ + } + char* readip_pcap(pcap_t* pd, unsigned int *len, struct timeval *rcvd_time){ return NULL; *************** *** 28,32 **** #include "sock_types.h" ! pcap_t* init_pcap(){ int i; char *dev; --- 32,36 ---- #include "sock_types.h" ! pcap_t* init_pcap(int index = 0){ int i; char *dev; *************** *** 34,67 **** pcap_t* descr; ! u_char *ptr; /* printing out hardware header info */ ! /* grab a device to peak into... */ ! dev = pcap_lookupdev(errbuf); ! if(dev == NULL) ! { ! return NULL; ! } ! //printf("DEV: %s\n",dev); ! /* open the device for sniffing. ! pcap_t *pcap_open_live(char *device,int snaplen, int prmisc,int to_ms, ! char *ebuf) ! snaplen - maximum size of packets to capture in bytes ! promisc - set card in promiscuous mode? ! to_ms - time to wait for packets in miliseconds before read ! times out ! errbuf - if something happens, place error string here ! Note if you change "prmisc" param to anything other than zero, you will ! get all packets your device sees, whether they are intendeed for you or ! not!! Be sure you know the rules of the network you are running on ! before you set your card in promiscuous mode!! */ ! return pcap_open_live(dev,BUFSIZ,0,-1,errbuf); ! } --- 38,110 ---- pcap_t* descr; ! if(index){ ! pcap_if_t *alldevs; ! pcap_if_t *d; ! int i=0; ! if(pcap_findalldevs(&alldevs, errbuf) == -1) ! { ! printf("Error in pcap_findalldevs: %s\n", errbuf); ! exit(1); ! } ! ! for(d=alldevs; d; d=d->next) ! i++; ! ! if(i==0) ! { ! printf("\nNo interfaces found! Make sure WinPcap is installed.\n"); ! return NULL; ! } ! for(d=alldevs, i=0; i< index-1 ;d=d->next, i++); ! pcap_t *dev = pcap_open_live(d->name,BUFSIZ,0,-1,errbuf); ! pcap_freealldevs(alldevs); ! return dev; ! }else{ ! dev = pcap_lookupdev(errbuf); ! if(dev == NULL) ! { ! return NULL; ! } ! return pcap_open_live(dev,BUFSIZ,0,-1,errbuf); ! } ! return NULL; ! } ! ! void listdev_pcap(){ ! pcap_if_t *alldevs; ! pcap_if_t *d; ! int i=0; ! char errbuf[PCAP_ERRBUF_SIZE]; ! ! if(pcap_findalldevs(&alldevs, errbuf) == -1) ! { ! printf("Error in pcap_findalldevs: %s\n", errbuf); ! exit(1); ! } ! ! for(d=alldevs; d; d=d->next) ! { ! printf("%d. %s", ++i, d->name); ! if (d->description) ! printf(" (%s)\n", d->description); ! else ! printf(" (No description available)\n"); ! } ! ! pcap_freealldevs(alldevs); ! ! if(i==0) ! { ! printf("\nNo interfaces found! Make sure WinPcap is installed.\n"); ! return; ! } } |