Thread: [Javanetsim-cvs] IceScan/icesockets crawsocket.h, 1.10, 1.11 csocket.h, 1.16, 1.17 iceregex.h, 1.9,
Status: Beta
Brought to you by:
darkkey
Update of /cvsroot/javanetsim/IceScan/icesockets In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv12835/icesockets Modified Files: crawsocket.h csocket.h iceregex.h sock_arp.h sock_name.h sock_pcap.h sock_time.h sock_types.h sock_win.h Log Message: Index: sock_arp.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icesockets/sock_arp.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** sock_arp.h 15 Dec 2006 15:27:57 -0000 1.3 --- sock_arp.h 16 Dec 2006 20:44:18 -0000 1.4 *************** *** 13,17 **** icestring get_arp_from_cache(icestring &ip) { ! #ifdef __CYGWIN__ return ""; #else --- 13,17 ---- icestring get_arp_from_cache(icestring &ip) { ! #if (__CYGWIN__ || WIN32) return ""; #else Index: sock_types.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icesockets/sock_types.h,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** sock_types.h 16 Dec 2006 17:29:16 -0000 1.15 --- sock_types.h 16 Dec 2006 20:44:19 -0000 1.16 *************** *** 12,28 **** #include <time.h> #include <sys/timeb.h> #include <errno.h> ! #include <sys/socket.h> ! #include <arpa/inet.h> ! #ifndef __CYGWIN__ ! #include <net/if_arp.h> #endif ! #include <netinet/in.h> ! #include <netinet/ip.h> ! #include <netdb.h> #include <cstdio> --- 12,54 ---- #include <time.h> #include <sys/timeb.h> + #include <signal.h> + #include <pcap.h> + #include <errno.h> ! #ifdef WIN32 ! #define __WIN32__ ! #define __NO_LIBPCRE__ ! #else ! #include <netinet/if_ether.h> ! #include <sys/socket.h> ! #include <arpa/inet.h> ! ! #ifndef __CYGWIN__ ! #include <net/if_arp.h> ! #endif ! ! #include <netinet/in.h> ! #include <netinet/ip.h> ! #include <netdb.h> ! ! #include <sys/ioctl.h> ! ! #include <netinet/ip.h> ! #include <netinet/ip_icmp.h> ! #define __FAVOR_BSD ! #include <netinet/tcp.h> ! #undef __FAVOR_BSD ! #ifndef __CYGWIN__ ! #undef __FAVOR_BSD ! #include <netinet/udp.h> ! #endif ! ! #include <pthread.h> #endif ! #include <cstdio> *************** *** 30,45 **** #include <fcntl.h> - #include <sys/ioctl.h> - - #include <netinet/ip.h> - #include <netinet/ip_icmp.h> - #define __FAVOR_BSD - #include <netinet/tcp.h> - #undef __FAVOR_BSD - - #ifndef __CYGWIN__ - #undef __FAVOR_BSD - #include <netinet/udp.h> - #endif --- 56,59 ---- *************** *** 50,65 **** typedef int SOCKET; #endif ! #define my_uint16_t uint16_t ! #define my_uint32_t uint32_t ! #define my_uint8_t uint8_t struct pseudo_header { ! my_uint32_t s_addr; ! my_uint32_t d_addr; ! my_uint8_t zero; ! my_uint8_t protocol; ! my_uint16_t length; }; --- 64,97 ---- typedef int SOCKET; + #define Bzero(a,b) bzero(a, b) + #else + #define Bzero(a,b) memset(a,0,b); + + typedef UINT16 uint16_t; + typedef UINT32 uint32_t; + typedef UINT8 uint8_t; + + typedef UINT16 my_uint16_t; + typedef UINT32 my_uint32_t; + typedef UINT8 my_uint8_t; + + typedef UINT16 u_int16_t; //UGLY + typedef UINT8 u_int8_t; + + typedef UINT16 n_short; + typedef UINT32 n_long; + + typedef long n_time; //UGLY, need to check... + #endif ! struct pseudo_header { ! uint32_t src_addr; ! uint32_t dst_addr; ! uint8_t zero; ! uint8_t protocol; ! uint16_t length; }; *************** *** 73,81 **** --- 105,208 ---- // Structure and constants for icmp packets + #ifdef __CYGWIN__ #include <sys/param.h> #include <sys/file.h> #include <netinet/in_systm.h> + #endif + + #ifdef WIN32 + //#define _CRT_SECURE_NO_DEPRECATE + #define EWOULDBLOCK WSAEWOULDBLOCK + #define EINPROGRESS WSAEINPROGRESS + #define EALREADY WSAEALREADY + #define ENOTSOCK WSAENOTSOCK + #define EDESTADDRREQ WSAEDESTADDRREQ + #define EMSGSIZE WSAEMSGSIZE + #define EPROTOTYPE WSAEPROTOTYPE + #define ENOPROTOOPT WSAENOPROTOOPT + #define EPROTONOSUPPORT WSAEPROTONOSUPPORT + #define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT + #define EOPNOTSUPP WSAEOPNOTSUPP + #define EPFNOSUPPORT WSAEPFNOSUPPORT + #define EAFNOSUPPORT WSAEAFNOSUPPORT + #define EADDRINUSE WSAEADDRINUSE + #define EADDRNOTAVAIL WSAEADDRNOTAVAIL + #define ENETDOWN WSAENETDOWN + #define ENETUNREACH WSAENETUNREACH + #define ENETRESET WSAENETRESET + #define ECONNABORTED WSAECONNABORTED + #define ECONNRESET WSAECONNRESET + #define ENOBUFS WSAENOBUFS + #define EISCONN WSAEISCONN + #define ENOTCONN WSAENOTCONN + #define ESHUTDOWN WSAESHUTDOWN + #define ETOOMANYREFS WSAETOOMANYREFS + #define ETIMEDOUT WSAETIMEDOUT + #define ECONNREFUSED WSAECONNREFUSED + #define ELOOP WSAELOOP + #define EHOSTDOWN WSAEHOSTDOWN + #define EHOSTUNREACH WSAEHOSTUNREACH + #define EPROCLIM WSAEPROCLIM + #define EUSERS WSAEUSERS + #define EDQUOT WSAEDQUOT + #define ESTALE WSAESTALE + #define EREMOTE WSAEREMOTE + + #define tcp_seq unsigned int + + #define TH_FIN 0x01 + #define TH_SYN 0x02 + #define TH_RST 0x04 + #define TH_PUSH 0x08 + #define TH_ACK 0x10 + #define TH_URG 0x20 + + //UGLY, Copy from linux!!! + struct ip{ + u_int8_t ip_hv; /* header and version */ + u_int8_t ip_tos; /* type of service */ + u_short ip_len; /* total length */ + u_short ip_id; /* identification */ + u_short ip_off; /* fragment offset field */ + u_int8_t ip_ttl; /* time to live */ + u_int8_t ip_p; /* protocol */ + u_short ip_sum; /* checksum */ + struct in_addr ip_src,ip_dst; /* source and dest address */ + }; + + #define ip_hl ip_hv&0x0f + #define ip_v ip_hv>>4 + + struct tcphdr { + u_short th_sport; /* source port */ + u_short th_dport; /* destination port */ + tcp_seq th_seq; /* sequence number */ + tcp_seq th_ack; /* acknowledgement number */ + #if BYTE_ORDER == LITTLE_ENDIAN + u_int th_x2:4, /* (unused) */ + th_off:4; /* data offset */ + #else if BYTE_ORDER == BIG_ENDIAN + u_int th_off:4, /* data offset */ + th_x2:4; /* (unused) */ + #endif + u_char th_flags; + #define TH_FIN 0x01 + #define TH_SYN 0x02 + #define TH_RST 0x04 + #define TH_PUSH 0x08 + #define TH_ACK 0x10 + #define TH_URG 0x20 + #define TH_FLAGS (TH_FIN|TH_SYN|TH_RST|TH_ACK|TH_URG) + + u_short th_win; /* window */ + u_short th_sum; /* checksum */ + u_short th_urp; /* urgent pointer */ + }; + + #endif + + #if (__CYGWIN__ || WIN32) /* * Structure of an icmp header. Index: sock_name.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icesockets/sock_name.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** sock_name.h 15 Dec 2006 15:27:57 -0000 1.9 --- sock_name.h 16 Dec 2006 20:44:18 -0000 1.10 *************** *** 79,83 **** strncpy(hname, nisname, len); ! bzero(&hints, sizeof(hints)); hints.ai_flags = AI_CANONNAME; hints.ai_family = AF_INET; hints.ai_socktype = SOCK_STREAM; --- 79,83 ---- strncpy(hname, nisname, len); ! Bzero(&hints, sizeof(hints)); hints.ai_flags = AI_CANONNAME; hints.ai_family = AF_INET; hints.ai_socktype = SOCK_STREAM; Index: sock_time.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icesockets/sock_time.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** sock_time.h 16 Dec 2006 17:18:28 -0000 1.8 --- sock_time.h 16 Dec 2006 20:44:19 -0000 1.9 *************** *** 6,9 **** --- 6,45 ---- #define SUB_TIMEVALS(a,b) (((a).tv_sec - (b).tv_sec) * 1000000 + (a).tv_usec - (b).tv_usec) + #ifdef WIN32 + #define usleep(t) Sleep((t) / 1000) + + #if defined(_MSC_VER) || defined(_MSC_EXTENSIONS) || defined(__WATCOMC__) + #define DELTA_EPOCH_IN_USEC 11644473600000000Ui64 + #else + #define DELTA_EPOCH_IN_USEC 11644473600000000ULL + #endif + + static u_int64_t filetime_to_unix_epoch (const FILETIME *ft) + { + u_int64_t res = (u_int64_t) ft->dwHighDateTime << 32; + + res |= ft->dwLowDateTime; + res /= 10; + res -= DELTA_EPOCH_IN_USEC; + return (res); + } + + int gettimeofday (struct timeval *tv, void *tz_U_) + { + FILETIME ft; + u_int64_t tim; + + if (!tv) { + errno = EINVAL; + return (-1); + } + GetSystemTimeAsFileTime (&ft); + tim = filetime_to_unix_epoch (&ft); + tv->tv_sec = (long) (tim / 1000000L); + tv->tv_usec = (long) (tim % 1000000L); + return (0); + } + #endif + void iceusleep(unsigned long usec){ usleep(usec); *************** *** 11,20 **** void icesleep(int secs, int nsecs = 0){ ! struct timespec ts; ts.tv_sec = secs; ts.tv_nsec = nsecs; nanosleep (&ts, NULL); ! } --- 47,59 ---- void icesleep(int secs, int nsecs = 0){ ! #ifndef WIN32 ! struct timespec ts; ts.tv_sec = secs; ts.tv_nsec = nsecs; nanosleep (&ts, NULL); ! #else ! usleep(secs + nsecs * 1000); ! #endif } Index: crawsocket.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icesockets/crawsocket.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** crawsocket.h 16 Dec 2006 14:42:42 -0000 1.10 --- crawsocket.h 16 Dec 2006 20:44:18 -0000 1.11 *************** *** 81,85 **** int rc = 0; ! if( rc = ::setsockopt(sid, level, opname, optval, optlen) > 0 ) sockerror("setsockopt"); --- 81,85 ---- int rc = 0; ! if( rc = ::setsockopt(sid, level, opname, (sockbuf_type) optval, optlen) > 0 ) sockerror("setsockopt"); *************** *** 88,101 **** int sendto(const char *hostname, const void *msg, int len, unsigned int flags){ ! return csocket::sendto(hostname, 0, msg, len, flags); } int recvfrom(void *buf, int len, unsigned int flags, char *srchostname){ ! return csocket::recvfrom(buf, len, flags, srchostname, NULL); } ! void nonblock(bool lck){ ! csocket::nonblock(lck); ! } bool state(){ --- 88,101 ---- int sendto(const char *hostname, const void *msg, int len, unsigned int flags){ ! return csocket::sendto(hostname, 0, (sockbuf_type) msg, len, flags); } int recvfrom(void *buf, int len, unsigned int flags, char *srchostname){ ! return csocket::recvfrom((sockbuf_type) buf, len, flags, srchostname, NULL); } ! void nonblock(bool lck){ ! csocket::nonblock(lck); ! } bool state(){ *************** *** 103,107 **** } ! int get_socketid(){ return sid; } --- 103,107 ---- } ! SOCKET get_socketid(){ return sid; } *************** *** 127,230 **** } ! int send_tcp_raw( icestring source, icestring destination, unsigned short sport, unsigned short dport, unsigned long seq, ! unsigned long ack, unsigned char flags, unsigned short window, char *data, unsigned short datalen) ! { ! ! ! char packet[sizeof(struct iphdr) + sizeof(struct tcphdr) + datalen]; ! struct iphdr *ip = (struct iphdr *) packet; ! struct tcphdr *tcp = (struct tcphdr *) (packet + sizeof(struct iphdr)); ! struct pseudo_header *pseudo = (struct pseudo_header *) (packet + sizeof(struct iphdr) - sizeof(struct pseudo_header)); ! int res; ! char myname[ICEMAXHOSTNAME + 1]; ! struct sockaddr_in saddress, daddress; ! int slen, dlen; ! slen == make_sockname(saddress, source.c_str(), 0, domain); ! dlen == make_sockname(daddress, destination.c_str(), 0, domain); ! bzero(packet, sizeof(iphdr) + sizeof(tcphdr)); ! pseudo->s_addr = saddress.sin_addr.s_addr; ! pseudo->d_addr = daddress.sin_addr.s_addr; ! pseudo->protocol = IPPROTO_TCP; ! pseudo->length = htons(sizeof(struct tcphdr) + datalen); ! tcp->th_sport = htons(sport); ! tcp->th_dport = htons(dport); ! if (seq) ! tcp->th_seq = htonl(seq); ! else tcp->th_seq = rand() + rand(); ! if (flags & TH_ACK && ack) ! tcp->th_ack = htonl(seq); ! else if (flags & TH_ACK) ! tcp->th_ack = rand() + rand(); ! tcp->th_off = 5; ! tcp->th_flags = flags; ! unsigned short ttl = 121; ! ! if (window) ! tcp->th_win = window; ! else tcp->th_win = htons(1024 * (ttl % 4 + 1)); ! tcp->th_sum = in_chksum((unsigned short *)pseudo, sizeof(struct tcphdr) + ! sizeof(struct pseudo_header) + datalen); ! bzero(packet, sizeof(struct iphdr)); ! ip->version = 4; ! ip->ihl = 5; ! ip->tot_len = htons(sizeof(struct iphdr) + sizeof(struct tcphdr) + datalen); ! ip->id = rand(); ! ip->ttl = ttl; ! ip->protocol = IPPROTO_TCP; ! ip->saddr = saddress.sin_addr.s_addr; ! ip->daddr = daddress.sin_addr.s_addr; ! ip->check = in_chksum((unsigned short *)ip, sizeof(struct iphdr)); ! //print_tcppacket(packet,ntohs(ip->tot_len)); ! if ((res = sendto(destination.c_str(), packet, ntohs(ip->tot_len), 0)) == -1) ! { ! perror("sendto in send_tcp_raw"); ! return -1; ! } ! return res; } - - int send_icmp_packet(icestring Hostname, int Icmp_type, int Icmp_code, int Icmp_id, - int Icmp_seq, int Icmp_checksum, void* Icmp_data, int Icmp_data_len){ - - char buftosend[1500]; ! const char *hostname = Hostname.c_str(); ! bzero(buftosend, 1500); ! struct icmp *icmp = (struct icmp *) buftosend; ! icmp->icmp_type = Icmp_type; ! icmp->icmp_code = Icmp_code; ! icmp->icmp_id = Icmp_id; ! memcpy(icmp->icmp_data, Icmp_data, Icmp_data_len); ! icmp->icmp_seq = Icmp_seq; ! int len = 8 + 56; // icmp header + icmp data ! if(!Icmp_checksum) ! icmp->icmp_cksum = crawsocket::in_chksum( (unsigned short * ) icmp, len); ! else ! icmp->icmp_cksum = Icmp_checksum; ! return sendto(hostname, buftosend, len, 0); ! } // from Fyodor's "The Art of Port Scanning" ! static int print_tcppacket(char *packet, int readdata) { struct iphdr *ip = (struct iphdr *) packet; struct tcphdr *tcp = (struct tcphdr *) (packet + sizeof(struct iphdr)); --- 127,235 ---- } ! int send_tcp_raw( icestring source, icestring destination, unsigned short sport, unsigned short dport, unsigned long seq, ! unsigned long ack, unsigned char flags, unsigned short window, char *data, const unsigned short datalen) ! { ! #ifdef WIN32 ! char *packet = (char *) malloc(sizeof(struct iphdr) + sizeof(struct tcphdr) + datalen); ! #else ! char packet[sizeof(struct iphdr) + sizeof(struct tcphdr) + datalen]; ! #endif ! struct iphdr *ip = (struct iphdr *) packet; ! struct tcphdr *tcp = (struct tcphdr *) (packet + sizeof(struct iphdr)); ! struct pseudo_header *pseudo = (struct pseudo_header *) (packet + sizeof(struct iphdr) - sizeof(struct pseudo_header)); ! int res; ! char myname[ICEMAXHOSTNAME + 1]; ! struct sockaddr_in saddress, daddress; ! int slen, dlen; ! slen == make_sockname(saddress, source.c_str(), 0, domain); ! dlen == make_sockname(daddress, destination.c_str(), 0, domain); ! Bzero(packet, sizeof(iphdr) + sizeof(tcphdr)); ! pseudo->src_addr = saddress.sin_addr.s_addr; ! pseudo->dst_addr = daddress.sin_addr.s_addr; ! pseudo->protocol = IPPROTO_TCP; ! pseudo->length = htons(sizeof(struct tcphdr) + datalen); ! tcp->th_sport = htons(sport); ! tcp->th_dport = htons(dport); ! if (seq) ! tcp->th_seq = htonl(seq); ! else tcp->th_seq = rand() + rand(); ! if (flags & TH_ACK && ack) ! tcp->th_ack = htonl(seq); ! else if (flags & TH_ACK) ! tcp->th_ack = rand() + rand(); ! tcp->th_off = 5; ! tcp->th_flags = flags; ! unsigned short ttl = 121; ! ! if (window) ! tcp->th_win = window; ! else tcp->th_win = htons(1024 * (ttl % 4 + 1)); ! tcp->th_sum = in_chksum((unsigned short *)pseudo, sizeof(struct tcphdr) + ! sizeof(struct pseudo_header) + datalen); ! Bzero(packet, sizeof(struct iphdr)); ! ip->version = 4; ! ip->ihl = 5; ! ip->tot_len = htons(sizeof(struct iphdr) + sizeof(struct tcphdr) + datalen); ! ip->id = rand(); ! ip->ttl = ttl; ! ip->protocol = IPPROTO_TCP; ! ip->saddr = saddress.sin_addr.s_addr; ! ip->daddr = daddress.sin_addr.s_addr; ! ip->check = in_chksum((unsigned short *)ip, sizeof(struct iphdr)); ! //print_tcppacket(packet,ntohs(ip->tot_len)); ! if ((res = sendto(destination.c_str(), packet, ntohs(ip->tot_len), 0)) == -1) ! { ! perror("sendto in send_tcp_raw"); ! free(packet); ! return -1; } ! free(packet); ! return res; ! } ! ! int send_icmp_packet(icestring Hostname, int Icmp_type, int Icmp_code, int Icmp_id, ! int Icmp_seq, int Icmp_checksum, void* Icmp_data, int Icmp_data_len){ ! ! char buftosend[1500]; ! const char *hostname = Hostname.c_str(); ! Bzero(buftosend, 1500); ! struct icmp *icmp = (struct icmp *) buftosend; ! icmp->icmp_type = Icmp_type; ! icmp->icmp_code = Icmp_code; ! icmp->icmp_id = Icmp_id; ! memcpy(icmp->icmp_data, Icmp_data, Icmp_data_len); ! icmp->icmp_seq = Icmp_seq; ! int len = 8 + 56; // icmp header + icmp data ! if(!Icmp_checksum) ! icmp->icmp_cksum = crawsocket::in_chksum( (unsigned short * ) icmp, len); ! else ! icmp->icmp_cksum = Icmp_checksum; ! ! return sendto(hostname, buftosend, len, 0); ! } // from Fyodor's "The Art of Port Scanning" ! /*static int print_tcppacket(char *packet, int readdata) { struct iphdr *ip = (struct iphdr *) packet; struct tcphdr *tcp = (struct tcphdr *) (packet + sizeof(struct iphdr)); *************** *** 274,278 **** return 0; ! } }; --- 279,283 ---- return 0; ! } */ }; Index: csocket.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icesockets/csocket.h,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** csocket.h 16 Dec 2006 20:25:13 -0000 1.16 --- csocket.h 16 Dec 2006 20:44:18 -0000 1.17 *************** *** 9,12 **** --- 9,18 ---- #include "sock_arp.h" + #ifdef WIN32 + typedef char* sockbuf_type; + #else + typedef void* sockbuf_type; + #endif + #define MIN_MAGIC_PORT 20000 #define MAX_MAGIC_PORT 65535 *************** *** 82,86 **** void close(){ ! ::close(sid); } --- 88,96 ---- void close(){ ! #ifndef WIN32 ! ::close(sid); ! #else ! ::closesocket(sid); ! #endif } *************** *** 119,123 **** tv.tv_usec = 0; ! int ndfs = sid + 1; #ifdef WIN32 --- 129,133 ---- tv.tv_usec = 0; ! SOCKET ndfs = sid + 1; #ifdef WIN32 *************** *** 169,173 **** struct sockaddr_in sraddress; socklen_t size = sizeof(sraddress); ! int resultid = ::accept( sid, (struct sockaddr *) &sraddress, &size); if(resultid > -1){ if (remotehost) strcpy(remotehost, iptohost(sraddress.sin_addr)); --- 179,183 ---- struct sockaddr_in sraddress; socklen_t size = sizeof(sraddress); ! SOCKET resultid = ::accept( sid, (struct sockaddr *) &sraddress, &size); if(resultid > -1){ if (remotehost) strcpy(remotehost, iptohost(sraddress.sin_addr)); *************** *** 180,184 **** int rc = 0; ! if( rc = ::getsockopt(sid, level, opname, optval, optlen) > 0 ) sockerror("getsockopt"); --- 190,194 ---- int rc = 0; ! if( rc = ::getsockopt(sid, level, opname, (sockbuf_type) optval, optlen) > 0 ) sockerror("getsockopt"); *************** *** 186,190 **** } ! int recvfrom(void *buf, int len, int flags, char *srchostname, int *srchostport){ int rsize; struct sockaddr_in from; --- 196,200 ---- } ! int recvfrom(sockbuf_type buf, int len, int flags, char *srchostname, int *srchostport){ int rsize; struct sockaddr_in from; *************** *** 201,225 **** } ! int sendto(const char *hostname, int port, const void *msg, int len, unsigned int flags){ ! ! // struct addrinfo hints, *res; ! // int salen; ! // char cportbuf[8]; ! // char *cport = cportbuf; ! // ! // if(port == 0) cport = NULL; ! // else sprintf(cport, "%d", port); ! // ! // bzero(&hints, sizeof(struct addrinfo)); ! // ! // hints.ai_flags = AI_CANONNAME; ! // hints.ai_family = domain; ! // hints.ai_socktype = type; ! ! // if( getaddrinfo(hostname, cport, &hints, &res) != 0 ) ! // return sockerror("getaddrinfo"); ! ! // return ::sendto(sid, msg, len, flags, (const sockaddr *) res->ai_addr, res->ai_addrlen); ! struct sockaddr_in saddress; int slen; --- 211,215 ---- } ! int sendto(const char *hostname, int port, const sockbuf_type msg, int len, unsigned int flags){ struct sockaddr_in saddress; int slen; *************** *** 239,243 **** } ! int get_socketid(){ return sid; } --- 229,233 ---- } ! SOCKET get_socketid(){ return sid; } *************** *** 252,255 **** --- 242,246 ---- void nonblock(bool lck){ + #ifndef WIN32 int arg = fcntl(sid, F_GETFL, NULL); *************** *** 265,268 **** --- 256,272 ---- if( fcntl(sid, F_SETFL, arg) < 0 ){ perror("Error in fcntl(.., F_GETFL, ...)."); throw "Error in fcntl(.., F_SETFL, ...)."; } + #else + ULONG NonBlock; + if(lck) + NonBlock = 1; + else + NonBlock = 0; + + if (ioctlsocket(sid, FIONBIO, &NonBlock) == SOCKET_ERROR) + { + perror("ioctlsocket() failed"); + exit(-1); + } + #endif } Index: sock_win.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icesockets/sock_win.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** sock_win.h 16 Dec 2006 17:29:16 -0000 1.1 --- sock_win.h 16 Dec 2006 20:44:19 -0000 1.2 *************** *** 15,23 **** #pragma comment(lib, "ws2_32.lib") ! #include <winsock2.h> ! WSA_DATA start_sockets(){ ! WSA_DATA wsa; if(WSAStartup(MAKEWORD(2,0), &wsa) != 0x0){ --- 15,26 ---- #pragma comment(lib, "ws2_32.lib") ! #pragma comment(lib, "wpcap.lib") ! #include <winsock2.h> + #include <ws2tcpip.h> + #include <process.h> ! WSADATA start_sockets(){ ! WSADATA wsa; if(WSAStartup(MAKEWORD(2,0), &wsa) != 0x0){ *************** *** 30,34 **** void stop_sockets(){} ! #else --- 33,44 ---- void stop_sockets(){} ! ! int getpid(){ ! return _getpid(); ! } ! ! int getuid(){ ! return 1; //UGLY, FIXIT! ! } #else Index: sock_pcap.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icesockets/sock_pcap.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** sock_pcap.h 16 Dec 2006 20:25:13 -0000 1.3 --- sock_pcap.h 16 Dec 2006 20:44:19 -0000 1.4 *************** *** 10,15 **** #ifdef __CYGWIN__ ! //typedef int pcap_t ! #define pcap_t int pcap_t* init_pcap(){ return NULL; --- 10,15 ---- #ifdef __CYGWIN__ ! typedef int pcap_t; ! pcap_t* init_pcap(){ return NULL; *************** *** 26,31 **** #else /* __CYGWIN__ */ - #include <pcap.h> - #include <netinet/if_ether.h> #include "sock_types.h" --- 26,29 ---- *************** *** 152,155 **** --- 150,155 ---- if (rcvd_time) { #if defined(WIN32) + struct timeval tv_end; + gettimeofday(&tv_end, NULL); *rcvd_time = tv_end; Index: iceregex.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icesockets/iceregex.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** iceregex.h 15 Dec 2006 15:27:57 -0000 1.9 --- iceregex.h 16 Dec 2006 20:44:18 -0000 1.10 *************** *** 9,16 **** #define _ICEREGEX_H - #include <pcre.h> - #include "sock_types.h" class IceRegex { public: --- 9,79 ---- #define _ICEREGEX_H #include "sock_types.h" + #ifdef __NO_LIBPCRE__ + + class IceRegex { + public: + IceRegex (const icestring pattern){ + + } + + IceRegex (const char pattern[]){ + + } + + ~IceRegex(){ + + } + + void init_regex(){ + + } + + bool match(icestring const& s, std::vector<icestring> &v){ + return false; + } + + bool match(icestring const& s){ + return false; + } + + bool match(const char s[]){ + return false; + } + + bool findNext(){ + return false; + } + + bool findNextMin(){ + return false; + } + + void findReset(){ + } + + int groups(){ + return 0; + } + + bool group(int i, char *str, int strsize){ + return false; + } + + bool group(int i, icestring &str){ + return false; + } + + private: + bool find(icestring const& s, std::vector<icestring> &v, int start){ + return false; + } + }; + + #else + + #include <pcre.h> + class IceRegex { public: *************** *** 184,187 **** --- 247,252 ---- }; + #endif /* WIN32 */ + #endif /* _ICEREGEX_H */ |