inittcpctl()

inittcpctl()

概要

引数

実装

  783: void
  784: inittcpctl(Conv *s, int mode)
  785: {
  786:         Tcpctl *tcb;
  787:         Tcp4hdr* h4;
  788:         Tcp6hdr* h6;
  789:         int mss;
  790: 
  791:         tcb = (Tcpctl*)s->ptcl;
  792: 
  793:         memset(tcb, 0, sizeof(Tcpctl));
  794: 
  795:         tcb->ssthresh = 65535;
  796:         tcb->srtt = tcp_irtt<<LOGAGAIN;
  797:         tcb->mdev = 0;
  798: 
  799:         /* setup timers */
  800:         tcb->timer.start = tcp_irtt / MSPTICK;
  801:         tcb->timer.func = tcptimeout;
  • 詳細はtcptimeout()?を参照
  802:         tcb->timer.arg = s;
  803:         tcb->rtt_timer.start = MAX_TIME;
  804:         tcb->acktimer.start = TCP_ACK / MSPTICK;
  805:         tcb->acktimer.func = tcpacktimer;
  • 詳細はtcpacktimer()?を参照
  806:         tcb->acktimer.arg = s;
  807:         tcb->katimer.start = DEF_KAT / MSPTICK;
  808:         tcb->katimer.func = tcpkeepalive;
  • 詳細はtcpkeepalive?を参照
  809:         tcb->katimer.arg = s;
  810: 
  811:         mss = DEF_MSS;
  812: 
  813:         /* create a prototype(pseudo) header */
  814:         if(mode != TCP_LISTEN){
  815:                 if(ipcmp(s->laddr, IPnoaddr) == 0)
  816:                         findlocalip(s->p->f, s->laddr, s->raddr);
  • 詳細はfindlocalip()?を参照
  817: 
  818:                 switch(s->ipversion){
  819:                 case V4:
  820:                         h4 = &tcb->protohdr.tcp4hdr;
  821:                         memset(h4, 0, sizeof(*h4));
  822:                         h4->proto = IP_TCPPROTO;
  823:                         hnputs(h4->tcpsport, s->lport);
  824:                         hnputs(h4->tcpdport, s->rport);
  825:                         v6tov4(h4->tcpsrc, s->laddr);
  826:                         v6tov4(h4->tcpdst, s->raddr);
  • 詳細はv6tov4()?を参照
  827:                         break;
  828:                 case V6:
  829:                         h6 = &tcb->protohdr.tcp6hdr;
  830:                         memset(h6, 0, sizeof(*h6));
  831:                         h6->proto = IP_TCPPROTO;
  832:                         hnputs(h6->tcpsport, s->lport);
  833:                         hnputs(h6->tcpdport, s->rport);
  834:                         ipmove(h6->tcpsrc, s->laddr);
  835:                         ipmove(h6->tcpdst, s->raddr);
  836:                         mss = DEF_MSS6;
  837:                         break;
  838:                 default:
  839:                         panic("inittcpctl: version %d", s->ipversion);
  840:                 }
  841:         }
  842: 
  843:         tcb->mss = tcb->cwind = mss;
  844: 
  845:         /* default is no window scaling */
  846:         tcb->window = QMAX;
  847:         tcb->rcv.wnd = QMAX;
  848:         tcb->rcv.scale = 0;
  849:         tcb->snd.scale = 0;
  850:         qsetlimit(s->rq, QMAX);
  • 詳細はqsetlimit()?を参照
  851: }