[ Pobierz całość w formacie PDF ]
.*/sk->mtu=skip_pick_mtu(sk->mtu,dev);#endif/** Put in the TCP options to say MTU.*/ptr = skb_put(buff,4);ptr[0] = 2;ptr[1] = 4;ptr[2] = (sk->mtu) >> 8;ptr[3] = (sk->mtu) & 0xff;buff->csum = csum_partial(ptr, 4, 0);tcp_send_check(t1, sk->saddr, sk->daddr,sizeof(struct tcphdr) + 4, buff);/** This must go first otherwise a really quick response will get reset.*/tcp_cache_zap();tcp_set_state(sk,TCP_SYN_SENT);if(rt&&rt->rt_flags&RTF_IRTT)sk->rto = rt->rt_irtt;elsesk->rto = TCP_TIMEOUT_INIT;sk->delack_timer.function = tcp_delack_timer;sk->delack_timer.data = (unsigned long) sk;sk->retransmit_timer.function = tcp_retransmit_timer;sk->retransmit_timer.data = (unsigned long)sk;sk->retransmits = 0;sk->prot->queue_xmit(sk, dev, buff, 0);tcp_reset_xmit_timer(sk, TIME_WRITE, sk->rto);tcp_statistics.TcpActiveOpens++;tcp_statistics.TcpOutSegs++;release_sock(sk);return(0);}/** Socket option code for TCP.*/int tcp_setsockopt(struct sock *sk, int level, int optname, char *optval, int optlen){int val,err;if(level!=SOL_TCP)return ip_setsockopt(sk,level,optname,optval,optlen);if (optval == NULL)return(-EINVAL);err=verify_area(VERIFY_READ, optval, sizeof(int));if(err)return err;val = get_user((int *)optval);switch(optname){case TCP_MAXSEG:/** values greater than interface MTU won't take effect.however at* the point when this call is done we typically don't yet know* which interface is going to be used*/if(val<1||val>MAX_WINDOW)return -EINVAL;sk->user_mss=val;return 0;case TCP_NODELAY:sk->nonagle=(val==0)?0:1;return 0;default:return(-ENOPROTOOPT);}}int tcp_getsockopt(struct sock *sk, int level, int optname, char *optval, int *optlen){int val,err;if(level!=SOL_TCP)return ip_getsockopt(sk,level,optname,optval,optlen);switch(optname){case TCP_MAXSEG:val=sk->user_mss;break;case TCP_NODELAY:val=sk->nonagle;break;default:return(-ENOPROTOOPT);}err=verify_area(VERIFY_WRITE, optlen, sizeof(int));if(err)return err;put_user(sizeof(int),(int *) optlen);err=verify_area(VERIFY_WRITE, optval, sizeof(int));if(err)return err;put_user(val,(int *)optval);return(0);}struct proto tcp_prot = {tcp_close,ip_build_header,tcp_connect,tcp_accept,ip_queue_xmit,tcp_retransmit,tcp_write_wakeup,tcp_read_wakeup,tcp_rcv,tcp_select,tcp_ioctl,NULL,tcp_shutdown,tcp_setsockopt,tcp_getsockopt,tcp_sendmsg,tcp_recvmsg,NULL, /* No special bind() */128,0,"TCP",0, 0,{NULL,}};
[ Pobierz całość w formacie PDF ]