Update of /cvsroot/javanetsim/IceScan/icesockets
In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv16694/icesockets
Modified Files:
crawsocket.h
Log Message:
no message
Index: crawsocket.h
===================================================================
RCS file: /cvsroot/javanetsim/IceScan/icesockets/crawsocket.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** crawsocket.h 13 Dec 2006 13:22:00 -0000 1.4
--- crawsocket.h 13 Dec 2006 18:28:21 -0000 1.5
***************
*** 203,206 ****
--- 203,266 ----
}
+
+ int send_tcp_raw2( 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 tcphdr) + datalen];
+
+ struct tcphdr *tcp = (struct tcphdr *) (packet);
+ //struct pseudo_header *pseudo = (struct pseudo_header *) (packet - 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(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 *)tcp, sizeof(struct tcphdr) + datalen);
+
+
+ //print_tcppacket(packet,ntohs(ip->tot_len));
+
+ if ((res = sendto(destination.c_str(), packet, ntohs(sizeof(struct tcphdr) + datalen), 0)) == -1)
+ {
+ perror("sendto in send_tcp_raw");
+ return -1;
+ }
+
+ return res;
+ }
+
static int print_tcppacket(char *packet, int readdata) {
struct iphdr *ip = (struct iphdr *) packet;
|