//int Connect(e){ // return sockfd int Connect(char* tgt_ip_addr, int portNum){ destPort = portNum; srand((unsigned)time(NULL)); srcPort = 1000 + rand()%63535; sock2send = createRaw(IPPROTO_RAW); sock2recv = createRaw(IPPROTO_TCP); char **pptr = NULL; unsigned int OPTION_SIZE = 20; memset(datagram,0,4096); iph = (struct iphdr *) datagram; tcph = (struct TCP_header *) (datagram + sizeof(struct ip)); struct hostent *host = NULL; buf = malloc(1024); send_addr.sin_family = AF_INET; send_addr.sin_port = htons(destPort); send_addr.sin_addr.s_addr = inet_addr(tgt_ip_addr); look_for_local_ip(srcaddr); printf("Local IP Address:\t%s\n",srcaddr); // ip headG iph->ihl = 5; iph->version = 4; iph->tos = 0; iph->tot_len = sizeof(struct iphdr) + sizeof(struct TCP_header); iph->id = htonl(54321); iph->frag_off = 0; iph->ttl = 60; iph->protocol = IPPROTO_TCP; iph->check = 0; iph->saddr = inet_addr(srcaddr); iph->daddr = send_addr.sin_addr.s_addr; iph->check = csum((unsigned short*)datagram, iph->tot_len); three_hand_shake(sock2send,sock2recv,datagram,send_addr); return sock2recv; }
/* Creational method @return fully constructed MDHistoDimension instance wrapped in a boost shared pointer. */ IMDDimension_sptr MDHistoDimensionBuilder::create() { return IMDDimension_sptr(createRaw()); }