Lines Matching refs:dp

191 	struct dccpcb *dp;  in dccp_input()  local
411 dp = intodccpcb(inp); in dccp_input()
412 if (dp == NULL) { in dccp_input()
418 if (dp->state == DCCPS_CLOSED) { in dccp_input()
421 dccp_output(dp, DCCP_TYPE_RESET + 2); in dccp_input()
430 DCCP_DEBUG((LOG_INFO, "so->options & SO_ACCEPTCONN! dp->state = %i\n", dp->state)); in dccp_input()
464 dp = inp->inp_ppcb; in dccp_input()
466 dp->state = DCCPS_LISTEN; in dccp_input()
467 dp->who = DCCP_SERVER; in dccp_input()
468 dp->cslen = ((struct dccpcb *)oinp->inp_ppcb)->cslen; in dccp_input()
469 dp->avgpsize = ((struct dccpcb *)oinp->inp_ppcb)->avgpsize; in dccp_input()
470 dp->scode = ((struct dccpcb *)oinp->inp_ppcb)->scode; in dccp_input()
471 dp->seq_snd = (((u_int64_t)random() << 32) | random()) % 281474976710656LL; in dccp_input()
472 dp->ref_seq.hi = dp->seq_snd >> 24; in dccp_input()
473 dp->ref_seq.lo = (u_int64_t)(dp->seq_snd & 0xffffff); in dccp_input()
475 DCCP_DEBUG((LOG_INFO, "New dp = %u, dp->state = %u!\n", (int)dp, dp->state)); in dccp_input()
487 seqnr = CONVERT_TO_LONGSEQ((ntohl(dh->dh_seq) >> 8), dp->ref_pseq); in dccp_input()
489 ntohl(dh->dh_seq) >> 8, dp->ref_pseq.hi, dp->ref_pseq.lo)); in dccp_input()
492 …OG_INFO, "Received DCCP packet with sequence number = %llu , gsn_rcv %llu\n", seqnr, dp->gsn_rcv)); in dccp_input()
495 dp->ccval = dh->dh_ccval; in dccp_input()
497 if (dp->gsn_rcv == 281474976710656LL) dp->gsn_rcv = seqnr; in dccp_input()
498 if (dp->gsn_rcv > (dp->loss_window / 4)) in dccp_input()
499 low_seqnr = (dp->gsn_rcv - (dp->loss_window / 4)) % 281474976710656LL; in dccp_input()
502 high_seqnr = (dp->gsn_rcv + (dp->loss_window / 4 * 3)) % 281474976710656LL; in dccp_input()
512 if (DCCP_SEQ_GT(seqnr, dp->gsn_rcv)) in dccp_input()
513 dp->gsn_rcv = seqnr; in dccp_input()
524 if (drqh->drqh_scode != dp->scode){ in dccp_input()
525 …((LOG_INFO, "service code in request packet doesn't match! %x %x\n", drqh->drqh_scode, dp->scode)); in dccp_input()
527 dp->state = DCCPS_SERVER_CLOSE; /* So disconnect2 doesn't send CLOSEREQ */ in dccp_input()
528 dccp_disconnect2(dp); in dccp_input()
529 dccp_output(dp, DCCP_TYPE_RESET + 2); in dccp_input()
530 dccp_close(dp); in dccp_input()
537 dp->ref_pseq.hi = seqnr >> 24; in dccp_input()
538 dp->ref_pseq.lo = (u_int64_t)(seqnr & 0xffffff); in dccp_input()
551 if (drqh->drqh_scode != dp->scode){ in dccp_input()
552 …(LOG_INFO, "service code in response packet doesn't match! %x %x\n", drqh->drqh_scode, dp->scode)); in dccp_input()
554 dp->state = DCCPS_CLIENT_CLOSE; /* So disconnect2 doesn't send CLOSEREQ */ in dccp_input()
555 dccp_disconnect2(dp); in dccp_input()
556 dccp_output(dp, DCCP_TYPE_RESET + 2); in dccp_input()
557 dccp_close(dp); in dccp_input()
563 dp->ref_pseq.hi = seqnr >> 24; in dccp_input()
564 dp->ref_pseq.lo = (u_int64_t)(seqnr & 0xffffff); in dccp_input()
577 dp->seq_rcv = seqnr; in dccp_input()
578 dp->ack_rcv = 0; /* Clear it for now */ in dccp_input()
579 dp->type_rcv = dh->dh_type; in dccp_input()
580 dp->len_rcv = m->m_len - data_off - iphlen; /* Correct length ? */ in dccp_input()
602 dccp_parse_options(dp, options, optlen); in dccp_input()
605 …RE state check, Got a %u packet while in %u state, who = %u!\n", dh->dh_type, dp->state, dp->who)); in dccp_input()
607 if (dp->state == DCCPS_LISTEN) { in dccp_input()
612 dp->state = DCCPS_REQUEST; in dccp_input()
613 if (dp->cc_in_use[1] < 0) { in dccp_input()
616 dccp_add_feature(dp, DCCP_OPT_CHANGE_R, DCCP_FEATURE_CC, test, 2); in dccp_input()
620 dccp_add_option(dp, DCCP_OPT_DATA_DISCARD, test, 0); in dccp_input()
622 callout_reset(&dp->connect_timer, DCCP_CONNECT_TIMER, in dccp_input()
623 dccp_connect_t, dp); in dccp_input()
624 dccp_output(dp, 0); in dccp_input()
633 dccp_output(dp, DCCP_TYPE_RESET + 2); in dccp_input()
638 dp->state = DCCPS_TIME_WAIT; in dccp_input()
639 dp = dccp_close(dp); in dccp_input()
645 dccp_output(dp, DCCP_TYPE_RESET + 2); in dccp_input()
647 } else if (dp->state == DCCPS_REQUEST) { in dccp_input()
650 DAHDR_TO_DSEQ(dp->ack_rcv, ((struct dccp_acklhdr*)dalh)->dash); in dccp_input()
651 dp->ack_snd = dp->seq_rcv; in dccp_input()
652 DCCP_DEBUG((LOG_INFO, "Got DCCP REPSONSE %x %llx\n", dp, dp->ack_snd)); in dccp_input()
654 callout_stop(&dp->retrans_timer); in dccp_input()
655 callout_stop(&dp->connect_timer); in dccp_input()
658 if (dp->cc_in_use[0] > 0 && dp->cc_in_use[1] > 0) { in dccp_input()
660 dp->state = DCCPS_ESTAB; in dccp_input()
664 dp->state = DCCPS_RESPOND; in dccp_input()
665 …otiation is not finished, cc_in_use[0] = %u, cc_in_use[1] = %u\n",dp->cc_in_use[0], dp->cc_in_use[… in dccp_input()
668 dccp_output(dp, 0); in dccp_input()
673 dp->state = DCCPS_TIME_WAIT; in dccp_input()
674 dp = dccp_close(dp); in dccp_input()
680 dccp_output(dp, DCCP_TYPE_RESET + 2); in dccp_input()
682 dp = dccp_close(dp); in dccp_input()
685 callout_stop(&dp->retrans_timer); in dccp_input()
686 dp->state = DCCPS_TIME_WAIT; in dccp_input()
689 } else if (dp->state == DCCPS_RESPOND) { in dccp_input()
698 callout_stop(&dp->connect_timer); in dccp_input()
701 DAHDR_TO_DSEQ(dp->ack_rcv, ((struct dccp_acklhdr*)dalh)->dash); in dccp_input()
704 dp->ack_rcv = CONVERT_TO_LONGSEQ((ntohl(dah->dash.dah_ack) >> 8), dp->ref_seq); in dccp_input()
707 if (dp->cc_in_use[0] > 0 && dp->cc_in_use[1] > 0) { in dccp_input()
709 dp->state = DCCPS_ESTAB; in dccp_input()
713 …otiation is not finished, cc_in_use[0] = %u, cc_in_use[1] = %u\n",dp->cc_in_use[0], dp->cc_in_use[… in dccp_input()
715 dp->ack_snd = dp->seq_rcv; in dccp_input()
716 dccp_output(dp, 0); in dccp_input()
719 if (dh->dh_type == DCCP_TYPE_DATAACK && dp->cc_in_use[1] > 0) { in dccp_input()
720 if (!dp->ack_snd) dp->ack_snd = dp->seq_rcv; in dccp_input()
721 DCCP_DEBUG((LOG_INFO, "Calling *cc_sw[%u].cc_recv_packet_recv!\n", dp->cc_in_use[1])); in dccp_input()
722 (*cc_sw[dp->cc_in_use[1]].cc_recv_packet_recv)(dp->cc_state[1], options, optlen); in dccp_input()
727 dccp_output(dp, DCCP_TYPE_CLOSE + 1); in dccp_input()
728 dp = dccp_close(dp); in dccp_input()
732 dp->state = DCCPS_TIME_WAIT; in dccp_input()
733 callout_stop(&dp->retrans_timer); in dccp_input()
739 dccp_output(dp, DCCP_TYPE_RESET + 2); in dccp_input()
741 } else if (dp->state == DCCPS_ESTAB) { in dccp_input()
745 …DCCP_DEBUG((LOG_INFO, "Got DCCP DATA, state = %i, cc_in_use[1] = %u\n", dp->state, dp->cc_in_use[1… in dccp_input()
747 if (dp->cc_in_use[1] > 0) { in dccp_input()
748 if (!dp->ack_snd) dp->ack_snd = dp->seq_rcv; in dccp_input()
749 … *cc_sw[%u].cc_recv_packet_recv! %llx %llx dp=%x\n", dp->cc_in_use[1], dp->ack_snd, dp->seq_rcv, d… in dccp_input()
750 (*cc_sw[dp->cc_in_use[1]].cc_recv_packet_recv)(dp->cc_state[1], options, optlen); in dccp_input()
757 DAHDR_TO_DSEQ(dp->ack_rcv, ((struct dccp_acklhdr*)dalh)->dash); in dccp_input()
760 dp->ack_rcv = CONVERT_TO_LONGSEQ((ntohl(dah->dash.dah_ack) >> 8), dp->ref_seq); in dccp_input()
763 if (dp->cc_in_use[1] > 0) { in dccp_input()
765 if (!dp->ack_snd) dp->ack_snd = dp->seq_rcv; in dccp_input()
766 … "Calling ACK *cc_sw[%u].cc_recv_packet_recv! %llx %llx\n", dp->cc_in_use[1], dp->ack_snd, dp->seq… in dccp_input()
767 (*cc_sw[dp->cc_in_use[1]].cc_recv_packet_recv)(dp->cc_state[1], options, optlen); in dccp_input()
775 DAHDR_TO_DSEQ(dp->ack_rcv, ((struct dccp_acklhdr*)dalh)->dash); in dccp_input()
778 dp->ack_rcv = CONVERT_TO_LONGSEQ((ntohl(dah->dash.dah_ack) >> 8), dp->ref_seq); in dccp_input()
781 if (dp->cc_in_use[1] > 0) { in dccp_input()
782 if (!dp->ack_snd) dp->ack_snd = dp->seq_rcv; in dccp_input()
783 …NFO, "Calling *cc_sw[%u].cc_recv_packet_recv! %llx %llx\n", dp->cc_in_use[1], dp->ack_snd, dp->seq… in dccp_input()
784 (*cc_sw[dp->cc_in_use[1]].cc_recv_packet_recv)(dp->cc_state[1], options, optlen); in dccp_input()
790 if (dp->who == DCCP_CLIENT) { in dccp_input()
791 dccp_disconnect2(dp); in dccp_input()
793 dccp_output(dp, DCCP_TYPE_RESET + 2); in dccp_input()
799 dp->state = DCCPS_SERVER_CLOSE; /* So disconnect2 doesn't send CLOSEREQ */ in dccp_input()
800 dccp_disconnect2(dp); in dccp_input()
801 dccp_output(dp, DCCP_TYPE_RESET + 2); in dccp_input()
802 dccp_close(dp); in dccp_input()
808 dp->state = DCCPS_TIME_WAIT; in dccp_input()
809 callout_stop(&dp->retrans_timer); in dccp_input()
810 callout_reset(&dp->timewait_timer, DCCP_TIMEWAIT_TIMER, in dccp_input()
811 dccp_timewait_t, dp); in dccp_input()
822 } else if (dp->state == DCCPS_SERVER_CLOSE) { in dccp_input()
827 callout_stop(&dp->retrans_timer); in dccp_input()
828 dccp_output(dp, DCCP_TYPE_RESET + 2); in dccp_input()
829 dp = dccp_close(dp); in dccp_input()
834 callout_stop(&dp->retrans_timer); in dccp_input()
835 dccp_output(dp, DCCP_TYPE_RESET + 2); in dccp_input()
836 dp->state = DCCPS_TIME_WAIT; in dccp_input()
842 } else if (dp->state == DCCPS_CLIENT_CLOSE) { in dccp_input()
851 dccp_output(dp, 0); in dccp_input()
855 callout_stop(&dp->retrans_timer); in dccp_input()
856 dp->state = DCCPS_TIME_WAIT; in dccp_input()
857 callout_reset(&dp->timewait_timer, DCCP_TIMEWAIT_TIMER, in dccp_input()
858 dccp_timewait_t, dp); in dccp_input()
865 DCCP_DEBUG((LOG_INFO, "Got a %u packet while in %u state!\n", dh->dh_type, dp->state)); in dccp_input()
869 dccp_output(dp, DCCP_TYPE_RESET + 2); in dccp_input()
876 if (dp->cc_in_use[0] > 0) { in dccp_input()
877 (*cc_sw[dp->cc_in_use[0]].cc_send_packet_recv)(dp->cc_state[0],options, optlen); in dccp_input()
899 if (dp) in dccp_input()
970 dccp_optsset(struct dccpcb *dp, struct sockopt *sopt) in dccp_optsset() argument
980 dp->pref_cc = optval; in dccp_optsset()
990 dp->cslen = optval; in dccp_optsset()
995 if (optval > 0 && optval <= dp->d_maxseg) { in dccp_optsset()
996 dp->d_maxseg = optval; in dccp_optsset()
1003 dp->scode = optval; in dccp_optsset()
1014 dccp_optsget(struct dccpcb *dp, struct sockopt *sopt) in dccp_optsget() argument
1021 optval = dp->pref_cc; in dccp_optsget()
1025 optval = dp->cslen; in dccp_optsget()
1029 optval = dp->d_maxseg; in dccp_optsget()
1033 optval = dp->scode; in dccp_optsget()
1052 struct dccpcb *dp; in dccp_ctloutput() local
1089 dp = intodccpcb(inp); in dccp_ctloutput()
1092 error = dccp_optsset(dp, sopt); in dccp_ctloutput()
1094 error = dccp_optsget(dp, sopt); in dccp_ctloutput()
1109 dccp_output(struct dccpcb *dp, u_int8_t extra) in dccp_output() argument
1137 isipv6 = (dp->inp_vflag & INP_IPV6) != 0; in dccp_output()
1141 KASSERT(mutex_assert(&dp->d_inpcb->inp_mtx, MA_OWNED)); in dccp_output()
1144 inp = dp->d_inpcb; in dccp_output()
1147 if (dp->state != DCCPS_ESTAB && extra == 1) { in dccp_output()
1153 pktlen = dp->pktlen[dp->pktlenidx]; in dccp_output()
1158 if (pktlen && dp->cc_in_use[0] > 0 && dp->state == DCCPS_ESTAB) { in dccp_output()
1159 if (!(*cc_sw[dp->cc_in_use[0]].cc_send_packet)(dp->cc_state[0], pktlen)) { in dccp_output()
1166 dp->pktcnt --; in dccp_output()
1167 dp->pktlenidx = (dp->pktlenidx +1) % DCCP_MAX_PKTS; in dccp_output()
1180 if (pktlen > dp->d_maxseg) { in dccp_output()
1182 DCCP_DEBUG((LOG_INFO, "packet will be fragmented! maxseg %d\n", dp->d_maxseg)); in dccp_output()
1183 len = dp->d_maxseg; in dccp_output()
1190 DCCP_DEBUG((LOG_INFO, "Force sending of DCCP TYPE_RESET! seq=%llu\n", dp->seq_snd)); in dccp_output()
1193 } else if (dp->state <= DCCPS_REQUEST && dp->who == DCCP_CLIENT) { in dccp_output()
1196 dp->state = DCCPS_REQUEST; in dccp_output()
1198 } else if (dp->state == DCCPS_REQUEST && dp->who == DCCP_SERVER) { in dccp_output()
1201 dp->state = DCCPS_RESPOND; in dccp_output()
1203 } else if (dp->state == DCCPS_RESPOND) { in dccp_output()
1206 if (!dp->shortseq) in dccp_output()
1212 } else if (dp->state == DCCPS_ESTAB) { in dccp_output()
1213 if (dp->ack_snd && len) { in dccp_output()
1217 if (!dp->shortseq) in dccp_output()
1223 } else if (dp->ack_snd) { in dccp_output()
1226 if (!dp->shortseq) in dccp_output()
1240 } else if (dp->state == DCCPS_CLIENT_CLOSE) { in dccp_output()
1244 } else if (dp->state == DCCPS_SERVER_CLOSE) { in dccp_output()
1249 DCCP_DEBUG((LOG_INFO, "Hey, we should never get here, state = %u\n", dp->state)); in dccp_output()
1254 if (dp->optlen) { in dccp_output()
1255 DCCP_DEBUG((LOG_INFO, "Copying options from dp->options! %u\n", dp->optlen)); in dccp_output()
1256 memcpy(options, dp->options, dp->optlen); in dccp_output()
1257 optlen = dp->optlen; in dccp_output()
1258 dp->optlen = 0; in dccp_output()
1261 if (dp->featlen && (optlen + dp->featlen < DCCP_MAX_OPTIONS)) { in dccp_output()
1262 DCCP_DEBUG((LOG_INFO, "Copying options from dp->features! %u\n", dp->featlen)); in dccp_output()
1263 memcpy(options + optlen, dp->features, dp->featlen); in dccp_output()
1264 optlen += dp->featlen; in dccp_output()
1298 if (len > (dp->d_maxseg - extrah_len - optlen)) { in dccp_output()
1299 len = dp->d_maxseg - extrah_len - optlen; in dccp_output()
1333 dp->ndp++; in dccp_output()
1372 dh->dh_cscov = dp->cslen; in dccp_output()
1373 dh->dh_ccval = dp->ccval; in dccp_output()
1382 dp->seq_snd = (dp->seq_snd +1) % 281474976710656LL; in dccp_output()
1384 DSEQ_TO_DHDR(dlh, dp->seq_snd); in dccp_output()
1388 dh->dh_seq = htonl(dp->seq_snd) >> 8; in dccp_output()
1393 …INFO, "Sending with seq %x.%x, (dp->seq_snd = %llu)\n\n", dlh->dh_seq, dlh->dh_seq2, dp->seq_snd)); in dccp_output()
1395 DCCP_DEBUG((LOG_INFO, "Sending with seq %x, (dp->seq_snd = %llu)\n\n", dh->dh_seq, dp->seq_snd)); in dccp_output()
1400 drqh->drqh_scode = dp->scode; in dccp_output()
1405 DSEQ_TO_DAHDR(drth->drth_dash, dp->seq_rcv); in dccp_output()
1406 if (dp->state == DCCPS_SERVER_CLOSE) in dccp_output()
1419 if (dp->state == DCCPS_ESTAB) { in dccp_output()
1420 DSEQ_TO_DAHDR(dalh->dash, dp->ack_snd); in dccp_output()
1421 dp->ack_snd = 0; in dccp_output()
1423 DSEQ_TO_DAHDR(dalh->dash, dp->seq_rcv); in dccp_output()
1429 drqh->drqh_scode = dp->scode; in dccp_output()
1437 dah->dash.dah_ack = htonl(dp->seq_rcv) >> 8; in dccp_output()
1489 ip->ip_ttl = dp->inp_ip_ttl; /* XXX */ in dccp_output()
1490 ip->ip_tos = dp->inp_ip_tos; /* XXX */ in dccp_output()
1526 if (dp->cc_in_use[0] > 0 && dp->state == DCCPS_ESTAB) { in dccp_output()
1527 DCCP_DEBUG((LOG_INFO, "Calling *cc_sw[%u].cc_send_packet_sent!\n", dp->cc_in_use[0])); in dccp_output()
1529 (*cc_sw[dp->cc_in_use[0]].cc_send_packet_sent)(dp->cc_state[0], 1,len); in dccp_output()
1532 (*cc_sw[dp->cc_in_use[0]].cc_send_packet_sent)(dp->cc_state[0], 0,len); in dccp_output()
1552 struct dccpcb *dp; in dccp_abort() local
1561 dp = inp->inp_ppcb; in dccp_abort()
1563 dccp_disconnect2(dp); in dccp_abort()
1570 dccp_close(struct dccpcb *dp) in dccp_close() argument
1573 struct inpcb *inp = dp->d_inpcb; in dccp_close()
1574 so = dptosocket(dp); in dccp_close()
1579 callout_stop(&dp->connect_timer); in dccp_close()
1580 callout_stop(&dp->retrans_timer); in dccp_close()
1581 callout_stop(&dp->close_timer); in dccp_close()
1582 callout_stop(&dp->timewait_timer); in dccp_close()
1584 if (dp->cc_in_use[0] > 0) in dccp_close()
1585 (*cc_sw[dp->cc_in_use[0]].cc_send_free)(dp->cc_state[0]); in dccp_close()
1586 if (dp->cc_in_use[1] > 0) in dccp_close()
1587 (*cc_sw[dp->cc_in_use[1]].cc_recv_free)(dp->cc_state[1]); in dccp_close()
1589 pool_put(&dccpcb_pool, dp); in dccp_close()
1604 struct dccpcb *dp; in dccp_attach() local
1625 dp = dccp_newdccpcb(inp->inp_af, inp); in dccp_attach()
1626 if (dp == 0) { in dccp_attach()
1638 dp->inp_vflag |= INP_IPV6; in dccp_attach()
1641 dp->inp_vflag |= INP_IPV4; in dccp_attach()
1642 dp->inp_ip_ttl = ip_defttl; in dccp_attach()
1644 dp->state = DCCPS_CLOSED; in dccp_attach()
1690 struct dccpcb *dp; in dccp_connect() local
1710 dp = (struct dccpcb *)inp->inp_ppcb; in dccp_connect()
1712 if (dp->state == DCCPS_ESTAB) { in dccp_connect()
1716 dp->who = DCCP_CLIENT; in dccp_connect()
1717 dp->seq_snd = (((u_int64_t)random() << 32) | random()) % 281474976710656LL; in dccp_connect()
1718 dp->ref_seq.hi = dp->seq_snd >> 24; in dccp_connect()
1719 dp->ref_seq.lo = (u_int64_t)(dp->seq_snd & 0xffffff); in dccp_connect()
1720 DCCP_DEBUG((LOG_INFO, "dccp_connect seq_snd %llu\n", dp->seq_snd)); in dccp_connect()
1736 callout_reset(&dp->retrans_timer, dp->retrans, dccp_retrans_t, dp); in dccp_connect()
1737 callout_reset(&dp->connect_timer, DCCP_CONNECT_TIMER, dccp_connect_t, dp); in dccp_connect()
1740 test[0] = dp->pref_cc; in dccp_connect()
1741 dccp_add_feature(dp, DCCP_OPT_CHANGE_R, DCCP_FEATURE_CC, test, 1); in dccp_connect()
1744 error = dccp_output(dp, 0); in dccp_connect()
1815 struct dccpcb *dp; in dccp_detach() local
1822 dp = inp->inp_ppcb; in dccp_detach()
1823 if (! dccp_disconnect2(dp)) { in dccp_detach()
1838 struct dccpcb *dp; in dccp_disconnect() local
1855 dp = (struct dccpcb *)inp->inp_ppcb; in dccp_disconnect()
1862 dp = inp->inp_ppcb; in dccp_disconnect()
1864 if (!dccp_disconnect2(dp)) { in dccp_disconnect()
1877 dccp_disconnect2(struct dccpcb *dp) in dccp_disconnect2() argument
1879 struct socket *so = dptosocket(dp); in dccp_disconnect2()
1883 if (dp->state < DCCPS_ESTAB) { in dccp_disconnect2()
1884 dccp_close(dp); in dccp_disconnect2()
1889 if (dp->state == DCCPS_ESTAB) { in dccp_disconnect2()
1890 dp->retrans = 100; in dccp_disconnect2()
1891 callout_reset(&dp->retrans_timer, dp->retrans, in dccp_disconnect2()
1892 dccp_retrans_t, dp); in dccp_disconnect2()
1893 callout_reset(&dp->close_timer, DCCP_CLOSE_TIMER, in dccp_disconnect2()
1894 dccp_close_t, dp); in dccp_disconnect2()
1895 if (dp->who == DCCP_CLIENT) { in dccp_disconnect2()
1896 dp->state = DCCPS_CLIENT_CLOSE; in dccp_disconnect2()
1898 dp->state = DCCPS_SERVER_CLOSE; in dccp_disconnect2()
1900 dccp_output(dp, 0); in dccp_disconnect2()
1911 struct dccpcb *dp; in dccp_send() local
1936 dp = inp->inp_ppcb; in dccp_send()
1938 if (dp->state != DCCPS_ESTAB) { in dccp_send()
1956 if (m->m_pkthdr.len > dp->d_maxseg) { in dccp_send()
1963 if (dp->pktcnt >= DCCP_MAX_PKTS) { in dccp_send()
1970 dp->pktlen[(dp->pktlenidx + dp->pktcnt) % DCCP_MAX_PKTS] = m->m_pkthdr.len; in dccp_send()
1971 dp->pktcnt ++; in dccp_send()
1973 if (addr && dp->state == DCCPS_CLOSED) { in dccp_send()
1979 error = dccp_output(dp, 0); in dccp_send()
2018 struct dccpcb *dp; in dccp_listen() local
2031 dp = (struct dccpcb *)inp->inp_ppcb; in dccp_listen()
2035 dp->state = DCCPS_LISTEN; in dccp_listen()
2036 dp->who = DCCP_LISTENER; in dccp_listen()
2082 struct dccpcb *dp; in dccp_newdccpcb() local
2086 dp = pool_get(&dccpcb_pool, PR_NOWAIT); in dccp_newdccpcb()
2087 if (dp == NULL) in dccp_newdccpcb()
2089 memset((char *) dp, 0, sizeof(struct dccpcb)); in dccp_newdccpcb()
2091 callout_init(&dp->connect_timer, 0); in dccp_newdccpcb()
2092 callout_init(&dp->retrans_timer, 0); in dccp_newdccpcb()
2093 callout_init(&dp->close_timer, 0); in dccp_newdccpcb()
2094 callout_init(&dp->timewait_timer, 0); in dccp_newdccpcb()
2096 dp->ndp = 0; in dccp_newdccpcb()
2097 dp->loss_window = 1000; in dccp_newdccpcb()
2098 dp->cslen = 0; in dccp_newdccpcb()
2099 dp->pref_cc = DEFAULT_CCID; in dccp_newdccpcb()
2100 dp->who = DCCP_UNDEF; in dccp_newdccpcb()
2101 dp->seq_snd = 0; in dccp_newdccpcb()
2102 dp->seq_rcv = 0; in dccp_newdccpcb()
2103 dp->shortseq = 0; in dccp_newdccpcb()
2104 dp->gsn_rcv = 281474976710656LL; in dccp_newdccpcb()
2105 dp->optlen = 0; in dccp_newdccpcb()
2107 dp->cc_in_use[0] = -1; in dccp_newdccpcb()
2108 dp->cc_in_use[1] = -1; in dccp_newdccpcb()
2111 dp->cc_in_use[0] = 4; in dccp_newdccpcb()
2112 dp->cc_in_use[1] = 4; in dccp_newdccpcb()
2114 dp->av_size = 0; /* no ack vector initially */ in dccp_newdccpcb()
2115 dp->remote_ackvector = 0; /* no ack vector on remote side initially */ in dccp_newdccpcb()
2116 dp->retrans = 200; in dccp_newdccpcb()
2117 dp->avgpsize = 0; in dccp_newdccpcb()
2118 dp->d_maxseg = 1400; in dccp_newdccpcb()
2119 dp->ref_pseq.hi = 0; in dccp_newdccpcb()
2120 dp->ref_pseq.lo = 0; in dccp_newdccpcb()
2121 dp->pktlenidx = 0; in dccp_newdccpcb()
2122 dp->pktcnt = 0; in dccp_newdccpcb()
2125 dp->d_inpcb = inp; in dccp_newdccpcb()
2126 inp->inp_ppcb = dp; in dccp_newdccpcb()
2137 dp->cc_state[0] = (*cc_sw[4].cc_send_init)(dp); in dccp_newdccpcb()
2138 dp->cc_state[1] = (*cc_sw[4].cc_recv_init)(dp); in dccp_newdccpcb()
2141 return dp; in dccp_newdccpcb()
2145 dccp_add_option(struct dccpcb *dp, u_int8_t opt, char *val, u_int8_t val_len) in dccp_add_option() argument
2147 return dccp_add_feature_option(dp, opt, 0, val, val_len); in dccp_add_option()
2151 dccp_add_feature_option(struct dccpcb *dp, u_int8_t opt, u_int8_t feature, char *val, u_int8_t val_… in dccp_add_feature_option() argument
2154 …"Entering dccp_add_feature_option, opt = %u, val_len = %u optlen %u\n", opt, val_len, dp->optlen)); in dccp_add_feature_option()
2156 if (DCCP_MAX_OPTIONS > (dp->optlen + val_len + 2)) { in dccp_add_feature_option()
2157 dp->options[dp->optlen] = opt; in dccp_add_feature_option()
2159 dp->optlen++; in dccp_add_feature_option()
2162 dp->options[dp->optlen + 1] = val_len + 3; in dccp_add_feature_option()
2163 dp->options[dp->optlen +2] = feature; in dccp_add_feature_option()
2164 dp->optlen += 3; in dccp_add_feature_option()
2166 dp->options[dp->optlen + 1] = val_len + 2; in dccp_add_feature_option()
2167 dp->optlen += 2; in dccp_add_feature_option()
2171 dp->options[dp->optlen] = val[i]; in dccp_add_feature_option()
2172 dp->optlen++; in dccp_add_feature_option()
2176 DCCP_DEBUG((LOG_INFO, "No room for more options, optlen = %u\n", dp->optlen)); in dccp_add_feature_option()
2214 dccp_parse_options(struct dccpcb *dp, char *options, int optlen) in dccp_parse_options() argument
2250 …DCCP_DEBUG((LOG_INFO, "Calling dccp_feature neg(%u, %u, options[%u + 1], %u)!\n", (u_int)dp, opt, … in dccp_parse_options()
2251 dccp_feature_neg(dp, opt, options[i+2], (size -3) , val); in dccp_parse_options()
2276 dccp_add_option(dp, DCCP_OPT_TIMESTAMP_ECHO, val, 8); in dccp_parse_options()
2322 dccp_add_feature(struct dccpcb *dp, u_int8_t opt, u_int8_t feature, char *val, u_int8_t val_len) in dccp_add_feature() argument
2327 if (DCCP_MAX_OPTIONS > (dp->featlen + val_len + 3)) { in dccp_add_feature()
2328 dp->features[dp->featlen] = opt; in dccp_add_feature()
2329 dp->features[dp->featlen + 1] = val_len + 3; in dccp_add_feature()
2330 dp->features[dp->featlen +2] = feature; in dccp_add_feature()
2331 dp->featlen += 3; in dccp_add_feature()
2333 dp->features[dp->featlen] = val[i]; in dccp_add_feature()
2334 dp->featlen++; in dccp_add_feature()
2337 DCCP_DEBUG((LOG_INFO, "No room for more features, featlen = %u\n", dp->featlen)); in dccp_add_feature()
2345 dccp_remove_feature(struct dccpcb *dp, u_int8_t opt, u_int8_t feature) in dccp_remove_feature() argument
2349 …DCCP_DEBUG((LOG_INFO, "Entering dccp_remove_feature, featlen = %u, opt = %u, feature = %u\n", dp->… in dccp_remove_feature()
2351 while (i < dp->featlen) { in dccp_remove_feature()
2352 t_opt = dp->features[i]; in dccp_remove_feature()
2353 len = dp->features[i+ 1]; in dccp_remove_feature()
2355 if (i + len > dp->featlen) { in dccp_remove_feature()
2356 …DCCP_DEBUG((LOG_INFO, "Error, len = %u and i(%u) + len > dp->featlen (%u)\n", len, i, dp->featlen)… in dccp_remove_feature()
2359 t_feature = dp->features[i+2]; in dccp_remove_feature()
2366 dp->features[j+k] = dp->features[i+k]; in dccp_remove_feature()
2373 dp->featlen = j; in dccp_remove_feature()
2374 DCCP_DEBUG((LOG_INFO, "Exiting dccp_remove_feature, featlen = %u\n", dp->featlen)); in dccp_remove_feature()
2379 dccp_feature_neg(struct dccpcb *dp, u_int8_t opt, u_int8_t feature, u_int8_t val_len, char *val) in dccp_feature_neg() argument
2390 for (i = 1; i < val_len; i ++) if (val[i] == dp->pref_cc) val[0] = dp->pref_cc; in dccp_feature_neg()
2392 dccp_remove_feature(dp, DCCP_OPT_CONFIRM_L, DCCP_FEATURE_CC); in dccp_feature_neg()
2393 dccp_add_feature_option(dp, DCCP_OPT_CONFIRM_L, DCCP_FEATURE_CC , val, 1); in dccp_feature_neg()
2394 if (dp->cc_in_use[0] < 1) { in dccp_feature_neg()
2395 dp->cc_state[0] = (*cc_sw[val[0] + 1].cc_send_init)(dp); in dccp_feature_neg()
2396 dp->cc_in_use[0] = val[0] + 1; in dccp_feature_neg()
2403 dccp_remove_feature(dp, DCCP_OPT_CHANGE_R, DCCP_FEATURE_CC); in dccp_feature_neg()
2404 if (dp->cc_in_use[1] < 1) { in dccp_feature_neg()
2405 dp->cc_state[1] = (*cc_sw[val[0] + 1].cc_recv_init)(dp); in dccp_feature_neg()
2406 dp->cc_in_use[1] = val[0] + 1; in dccp_feature_neg()
2407 DCCP_DEBUG((LOG_INFO, "confirmed cc_in_use[1] = %d\n", dp->cc_in_use[1])); in dccp_feature_neg()
2409 DCCP_DEBUG((LOG_INFO, "We already have negotiated a CC!!! (confirm) %d\n", dp->cc_in_use[1])); in dccp_feature_neg()
2419 dccp_use_ackvector(dp); in dccp_feature_neg()
2420 dccp_remove_feature(dp, DCCP_OPT_CONFIRM_L, DCCP_FEATURE_ACKVECTOR); in dccp_feature_neg()
2421 dccp_add_feature_option(dp, DCCP_OPT_CONFIRM_L, DCCP_FEATURE_ACKVECTOR , val, 1); in dccp_feature_neg()
2426 dccp_remove_feature(dp, DCCP_OPT_CONFIRM_L, DCCP_FEATURE_ACKVECTOR); in dccp_feature_neg()
2428 dp->remote_ackvector = 1; in dccp_feature_neg()
2438 memcpy(&(dp->ack_ratio), val, 1); in dccp_feature_neg()
2439 ACK_DEBUG((LOG_INFO, "Feature: Change Ack Ratio to %u\n", dp->ack_ratio)); in dccp_feature_neg()
2447 dccp_add_option(dp, DCCP_OPT_CONFIRM_L, NULL, 0); in dccp_feature_neg()
2577 struct dccpcb *dp = dcb; in dccp_timewait_t() local
2582 INP_LOCK(dp->d_inpcb); in dccp_timewait_t()
2583 dccp_close(dp); in dccp_timewait_t()
2591 struct dccpcb *dp = dcb; in dccp_connect_t() local
2596 INP_LOCK(dp->d_inpcb); in dccp_connect_t()
2597 dccp_close(dp); in dccp_connect_t()
2605 struct dccpcb *dp = dcb; in dccp_close_t() local
2610 dp->state = DCCPS_TIME_WAIT; /* HMM */ in dccp_close_t()
2611 if (dp->who == DCCP_SERVER) { in dccp_close_t()
2612 INP_LOCK(dp->d_inpcb); in dccp_close_t()
2614 dccp_output(dp, DCCP_TYPE_RESET + 2); in dccp_close_t()
2616 dccp_close(dp); in dccp_close_t()
2618 INP_LOCK(dp->d_inpcb); in dccp_close_t()
2619 dccp_output(dp, DCCP_TYPE_RESET + 2); in dccp_close_t()
2621 callout_reset(&dp->timewait_timer, DCCP_TIMEWAIT_TIMER, in dccp_close_t()
2622 dccp_timewait_t, dp); in dccp_close_t()
2623 INP_UNLOCK(dp->d_inpcb); in dccp_close_t()
2632 struct dccpcb *dp = dcb; in dccp_retrans_t() local
2641 callout_stop(&dp->retrans_timer); in dccp_retrans_t()
2643 dccp_output(dp, 0); in dccp_retrans_t()
2645 dp->retrans = dp->retrans * 2; in dccp_retrans_t()
2646 callout_reset(&dp->retrans_timer, dp->retrans, dccp_retrans_t, dp); in dccp_retrans_t()
2752 dccp_use_ackvector(struct dccpcb *dp) in dccp_use_ackvector() argument
2755 if (dp->ackvector != 0) { in dccp_use_ackvector()
2759 dp->av_size = DCCP_VECTORSIZE; in dccp_use_ackvector()
2761 dp->ackvector = malloc(dp->av_size/4, M_PCB, M_NOWAIT | M_ZERO); in dccp_use_ackvector()
2762 if (dp->ackvector == 0) { in dccp_use_ackvector()
2765 dp->av_size = 0; in dccp_use_ackvector()
2768 memset(dp->ackvector, 0xff, dp->av_size/4); in dccp_use_ackvector()
2769 dp->av_hs = dp->av_ts = 0; in dccp_use_ackvector()
2770 dp->av_hp = dp->ackvector; in dccp_use_ackvector()
2777 dccp_update_ackvector(struct dccpcb *dp, u_int64_t seqnr) in dccp_update_ackvector() argument
2786 if (dp->av_size == 0) { in dccp_update_ackvector()
2788 dccp_use_ackvector(dp); in dccp_update_ackvector()
2791 if (seqnr > dp->av_hs) { in dccp_update_ackvector()
2792 gap = seqnr - dp->av_hs; in dccp_update_ackvector()
2798 t = dp->av_hp + (gap/4); in dccp_update_ackvector()
2799 if (t >= (dp->ackvector + (dp->av_size/4))) in dccp_update_ackvector()
2800 t -= (dp->av_size / 4); /* ackvector wrapped */ in dccp_update_ackvector()
2801 dp->av_hp = t; in dccp_update_ackvector()
2802 dp->av_hs = seqnr; in dccp_update_ackvector()
2810 dccp_increment_ackvector(struct dccpcb *dp, u_int64_t seqnr) in dccp_increment_ackvector() argument
2816 DCCP_DEBUG((LOG_INFO, "Entering dccp_increment_ackvecktor %d\n", dp->av_size)); in dccp_increment_ackvector()
2817 if (dp->av_size == 0) { in dccp_increment_ackvector()
2819 dccp_use_ackvector(dp); in dccp_increment_ackvector()
2822 if (dp->av_hs == dp->av_ts) { in dccp_increment_ackvector()
2824 dp->av_hs = dp->av_ts = seqnr; in dccp_increment_ackvector()
2828 if (seqnr >= dp->av_hs) { in dccp_increment_ackvector()
2830 gap = seqnr - dp->av_hs; in dccp_increment_ackvector()
2833 gap = seqnr + 0x1000000000000LL - dp->av_hs; /* seqnr = 48 bits */ in dccp_increment_ackvector()
2835 DCCP_DEBUG((LOG_INFO, "dccp_increment_ackvecktor gap=%llu av_size %d\n", gap, dp->av_size)); in dccp_increment_ackvector()
2837 if (gap >= dp->av_size) { in dccp_increment_ackvector()
2841 gap, dp->av_size, seqnr)); in dccp_increment_ackvector()
2846 t = dp->av_hp + (gap/4); in dccp_increment_ackvector()
2847 if (t >= (dp->ackvector + (dp->av_size/4))) in dccp_increment_ackvector()
2848 t -= (dp->av_size / 4); /* ackvector wrapped */ in dccp_increment_ackvector()
2852 dp->av_ts = seqnr + 1; in dccp_increment_ackvector()
2853 if (dp->av_ts == 0x1000000000000LL) in dccp_increment_ackvector()
2854 dp->av_ts = 0; in dccp_increment_ackvector()
2856 if (gap > (dp->av_size - 128)) { in dccp_increment_ackvector()
2857 n = malloc(dp->av_size/2, M_PCB, M_NOWAIT | M_ZERO); /* old size * 2 */ in dccp_increment_ackvector()
2858 memset (n + dp->av_size / 4, 0xff, dp->av_size / 4); /* new half all missing */ in dccp_increment_ackvector()
2859 dc = (dp->ackvector + (dp->av_size/4)) - dp->av_hp; in dccp_increment_ackvector()
2860 memcpy (n, dp->av_hp, dc); /* tail to end */ in dccp_increment_ackvector()
2861 memcpy (n+dc, dp->ackvector, dp->av_hp - dp->ackvector); /* start to tail */ in dccp_increment_ackvector()
2862 dp->av_size = dp->av_size * 2; /* counted in items, so it';s a doubling */ in dccp_increment_ackvector()
2863 free (dp->ackvector, M_PCB); in dccp_increment_ackvector()
2864 dp->av_hp = dp->ackvector = n; in dccp_increment_ackvector()
2875 dccp_generate_ackvector(struct dccpcb *dp, u_char *buf) in dccp_generate_ackvector() argument
2888 if (dp->av_size == 0) { in dccp_generate_ackvector()
2893 if (dp->seq_rcv > dp->av_ts) { in dccp_generate_ackvector()
2896 j = dp->seq_rcv - dp->av_ts -1; in dccp_generate_ackvector()
2916 i = (dp->seq_rcv < dp->av_ts) ? dp->seq_rcv : dp->av_ts; in dccp_generate_ackvector()
2917 st = dccp_ackvector_state(dp, i); in dccp_generate_ackvector()
2927 if (dp->av_ts > dp->av_hs) { in dccp_generate_ackvector()
2930 st = dccp_ackvector_state(dp, i); in dccp_generate_ackvector()
2943 } while (i > dp->av_hs); in dccp_generate_ackvector()
2948 st = dccp_ackvector_state(dp, i); in dccp_generate_ackvector()
2965 st = dccp_ackvector_state(dp, i); in dccp_generate_ackvector()
2977 } while (i > dp->av_hs); in dccp_generate_ackvector()
2988 dccp_ackvector_state(struct dccpcb *dp, u_int64_t seqnr) in dccp_ackvector_state() argument
2994 if (seqnr >= dp->av_hs) { in dccp_ackvector_state()
2996 gap = seqnr - dp->av_hs; in dccp_ackvector_state()
2999 gap = seqnr + 0x1000000000000LL - dp->av_hs; /* seq nr = 48 bits */ in dccp_ackvector_state()
3002 if (gap >= dp->av_size) { in dccp_ackvector_state()
3008 t = dp->av_hp + (gap/4); in dccp_ackvector_state()
3009 if (t >= (dp->ackvector + (dp->av_size/4))) in dccp_ackvector_state()
3010 t -= (dp->av_size / 4); /* wrapped */ in dccp_ackvector_state()