int tcp_listen(struct tcb *ptcb, struct tcp_hdr* mbuf) { printf("tcp_listen called\n"); struct tcb *new_ptcb = NULL; new_ptcb = alloc_tcb(); if(new_ptcb == NULL) { printf("Null tcb'\n"); return 0; } // memcpy(new_ptcb, ptcb, sizeof(struct tcb)); new_ptcb->state = SYN_RECV; new_ptcb->dport = ptcb->dport; new_ptcb->sport = mbuf->src_port; new_ptcb->ipv4_dst = ptcb->ipv4_dst; new_ptcb->ipv4_src = ptcb->ipv4_src; // set src port; // set ips. ptcb->newpTcbOnAccept = new_ptcb; pthread_mutex_lock(&(ptcb->mutex)); pthread_cond_signal(&(ptcb->condAccept)); pthread_mutex_unlock(&(ptcb->mutex)); //printf("sending ack\n"); //sendack(new_ptcb); sendsynack(new_ptcb); //sendsynack(ptcb); return 0; }
int socket_open(STREAM_TYPE stream) { struct tcb *ptcb; ptcb = alloc_tcb(); return ptcb->identifier; }
int socket_open(STREAM_TYPE stream) { struct tcb *ptcb; (void) stream; // future set this as default instead of 2000. ptcb = alloc_tcb(2000, 2000); printf("socket open allocated tcb %p\n", ptcb); return ptcb->identifier; }