Lines Matching defs:chk
6215 struct sctp_tmit_chunk *chk, *nchk;
6220 TAILQ_FOREACH(chk, &asoc->sent_queue, sctp_next) {
6227 if (PR_SCTP_BUF_ENABLED(chk->flags)) {
6232 if (chk->rec.data.timetodrop.tv_sec > (long)srcv->sinfo_timetolive) {
6240 if (chk->data) {
6248 if (chk->sent > SCTP_DATAGRAM_UNSENT)
6252 ret_spc = sctp_release_pr_sctp_chunk(stcb, chk,
6264 TAILQ_FOREACH_SAFE(chk, &asoc->send_queue, sctp_next, nchk) {
6266 if (PR_SCTP_BUF_ENABLED(chk->flags)) {
6267 if (chk->rec.data.timetodrop.tv_sec > (long)srcv->sinfo_timetolive) {
6268 if (chk->data) {
6275 ret_spc = sctp_release_pr_sctp_chunk(stcb, chk,
6282 } /* end if chk->data */
6284 } /* end if chk pr-sctp */
6285 } /* tailqforeachsafe (chk) */
6993 struct sctp_tmit_chunk *chk, *nchk;
6995 TAILQ_FOREACH_SAFE(chk, &asoc->control_send_queue, sctp_next, nchk) {
6996 if (chk->rec.chunk_id.id == SCTP_COOKIE_ECHO) {
6997 TAILQ_REMOVE(&asoc->control_send_queue, chk, sctp_next);
6999 if (chk->data) {
7000 sctp_m_freem(chk->data);
7001 chk->data = NULL;
7003 sctp_free_a_chunk(stcb, chk, SCTP_SO_NOT_LOCKED);
7012 struct sctp_tmit_chunk *chk, *nchk;
7016 TAILQ_FOREACH_SAFE(chk, &asoc->asconf_send_queue, sctp_next, nchk) {
7018 if (chk->rec.chunk_id.id == SCTP_ASCONF) {
7019 if (chk->data) {
7020 acp = mtod(chk->data, struct sctp_asconf_chunk *);
7026 TAILQ_REMOVE(&asoc->asconf_send_queue, chk, sctp_next);
7028 if (chk->data) {
7029 sctp_m_freem(chk->data);
7030 chk->data = NULL;
7032 sctp_free_a_chunk(stcb, chk, SCTP_SO_NOT_LOCKED);
7132 struct sctp_tmit_chunk *chk, *nchk;
7134 TAILQ_FOREACH_SAFE(chk, &asoc->control_send_queue, sctp_next, nchk) {
7135 if ((chk->rec.chunk_id.id == SCTP_SELECTIVE_ACK) ||
7136 (chk->rec.chunk_id.id == SCTP_NR_SELECTIVE_ACK) || /* EY */
7137 (chk->rec.chunk_id.id == SCTP_HEARTBEAT_REQUEST) ||
7138 (chk->rec.chunk_id.id == SCTP_HEARTBEAT_ACK) ||
7139 (chk->rec.chunk_id.id == SCTP_FORWARD_CUM_TSN) ||
7140 (chk->rec.chunk_id.id == SCTP_SHUTDOWN) ||
7141 (chk->rec.chunk_id.id == SCTP_SHUTDOWN_ACK) ||
7142 (chk->rec.chunk_id.id == SCTP_OPERATION_ERROR) ||
7143 (chk->rec.chunk_id.id == SCTP_PACKET_DROPPED) ||
7144 (chk->rec.chunk_id.id == SCTP_COOKIE_ACK) ||
7145 (chk->rec.chunk_id.id == SCTP_ECN_CWR) ||
7146 (chk->rec.chunk_id.id == SCTP_ASCONF_ACK)) {
7149 TAILQ_REMOVE(&asoc->control_send_queue, chk, sctp_next);
7151 if (chk->data) {
7152 sctp_m_freem(chk->data);
7153 chk->data = NULL;
7155 if (chk->rec.chunk_id.id == SCTP_FORWARD_CUM_TSN) {
7158 sctp_free_a_chunk(stcb, chk, so_locked);
7159 } else if (chk->rec.chunk_id.id == SCTP_STREAM_RESET) {
7161 if (chk != asoc->str_reset) {
7241 struct sctp_tmit_chunk *chk;
7382 sctp_alloc_a_chunk(stcb, chk);
7383 if (chk == NULL) {
7401 memset(chk, 0, sizeof(*chk));
7402 chk->rec.data.rcv_flags = rcv_flags;
7410 chk->data = sp->data;
7411 chk->last_mbuf = sp->tail_mbuf;
7418 chk->data = SCTP_M_COPYM(sp->data, 0, to_move, M_NOWAIT);
7419 chk->last_mbuf = NULL;
7420 if (chk->data == NULL) {
7422 sctp_free_a_chunk(stcb, chk, so_locked);
7429 sctp_log_mbc(chk->data, SCTP_MBUF_ICOPY);
7457 if (SCTP_BUF_IS_EXTENDED(chk->data)) {
7458 chk->copy_by_ref = 1;
7460 chk->copy_by_ref = 0;
7466 if (chk->last_mbuf == NULL) {
7467 chk->last_mbuf = chk->data;
7468 while (SCTP_BUF_NEXT(chk->last_mbuf) != NULL) {
7469 chk->last_mbuf = SCTP_BUF_NEXT(chk->last_mbuf);
7488 if (M_LEADINGSPACE(chk->data) < leading) {
7501 sp->data = chk->data;
7502 sp->tail_mbuf = chk->last_mbuf;
7508 sp->data = chk->data;
7509 SCTP_BUF_NEXT(chk->last_mbuf) = m_tmp;
7513 chk->data = NULL;
7515 sctp_free_a_chunk(stcb, chk, so_locked);
7520 SCTP_BUF_NEXT(m) = chk->data;
7521 chk->data = m;
7522 M_ALIGN(chk->data, 4);
7525 SCTP_BUF_PREPEND(chk->data, SCTP_DATA_CHUNK_OVERHEAD(stcb), M_NOWAIT);
7526 if (chk->data == NULL) {
7532 sctp_free_a_chunk(stcb, chk, so_locked);
7539 chk->book_size = chk->send_size = (uint16_t)(to_move + SCTP_DATA_CHUNK_OVERHEAD(stcb));
7540 chk->book_size_scale = 0;
7541 chk->sent = SCTP_DATAGRAM_UNSENT;
7543 chk->flags = 0;
7544 chk->asoc = &stcb->asoc;
7545 chk->pad_inplace = 0;
7546 chk->no_fr_allowed = 0;
7550 chk->rec.data.mid = 0;
7552 chk->rec.data.mid = strq->next_mid_ordered;
7559 chk->rec.data.mid = strq->next_mid_unordered;
7564 chk->rec.data.mid = strq->next_mid_ordered;
7570 chk->rec.data.sid = sp->sid;
7571 chk->rec.data.ppid = sp->ppid;
7572 chk->rec.data.context = sp->context;
7573 chk->rec.data.doing_fast_retransmit = 0;
7575 chk->rec.data.timetodrop = sp->ts;
7576 chk->flags = sp->act_flags;
7579 chk->whoTo = sp->net;
7580 atomic_add_int(&chk->whoTo->ref_count, 1);
7582 chk->whoTo = NULL;
7585 chk->auth_keyid = sp->auth_keyid;
7586 sctp_auth_key_acquire(stcb, chk->auth_keyid);
7587 chk->holds_key_ref = 1;
7590 chk->rec.data.tsn = atomic_fetchadd_int(&asoc->sending_seq, 1);
7594 (uint32_t)((chk->rec.data.sid << 16) | (0x0000ffff & chk->rec.data.mid)),
7595 chk->rec.data.tsn);
7598 dchkh = mtod(chk->data, struct sctp_data_chunk *);
7600 ndchkh = mtod(chk->data, struct sctp_idata_chunk *);
7613 asoc->out_tsnlog[asoc->tsn_out_at].tsn = chk->rec.data.tsn;
7614 asoc->out_tsnlog[asoc->tsn_out_at].strm = chk->rec.data.sid;
7615 asoc->out_tsnlog[asoc->tsn_out_at].seq = chk->rec.data.mid;
7616 asoc->out_tsnlog[asoc->tsn_out_at].sz = chk->send_size;
7617 asoc->out_tsnlog[asoc->tsn_out_at].flgs = chk->rec.data.rcv_flags;
7625 dchkh->ch.chunk_flags = chk->rec.data.rcv_flags;
7626 dchkh->dp.tsn = htonl(chk->rec.data.tsn);
7628 dchkh->dp.ssn = htons((uint16_t)chk->rec.data.mid);
7629 dchkh->dp.ppid = chk->rec.data.ppid;
7630 dchkh->ch.chunk_length = htons(chk->send_size);
7633 ndchkh->ch.chunk_flags = chk->rec.data.rcv_flags;
7634 ndchkh->dp.tsn = htonl(chk->rec.data.tsn);
7637 ndchkh->dp.mid = htonl(chk->rec.data.mid);
7639 ndchkh->dp.ppid_fsn.ppid = chk->rec.data.ppid;
7643 ndchkh->ch.chunk_length = htons(chk->send_size);
7645 /* Now advance the chk->send_size by the actual pad needed. */
7646 if (chk->send_size < SCTP_SIZE32(chk->book_size)) {
7651 pads = SCTP_SIZE32(chk->book_size) - chk->send_size;
7652 lm = sctp_pad_lastmbuf(chk->data, pads, chk->last_mbuf);
7654 chk->last_mbuf = lm;
7655 chk->pad_inplace = 1;
7657 chk->send_size += pads;
7659 if (PR_SCTP_ENABLED(chk->flags)) {
7692 TAILQ_INSERT_TAIL(&asoc->send_queue, chk, sctp_next);
7776 struct sctp_tmit_chunk *chk;
7778 TAILQ_FOREACH(chk, &asoc->control_send_queue, sctp_next) {
7779 if (chk->rec.chunk_id.id == SCTP_ECN_ECHO) {
7780 chk->sent = SCTP_DATAGRAM_UNSENT;
7789 struct sctp_tmit_chunk *chk;
7805 TAILQ_FOREACH(chk, &asoc->send_queue, sctp_next) {
7806 if (chk->whoTo == net) {
7807 sctp_free_remote_addr(chk->whoTo);
7808 chk->whoTo = NULL;
7837 struct sctp_tmit_chunk *chk, *nchk;
7913 TAILQ_FOREACH(chk, &asoc->control_send_queue, sctp_next) {
7914 if ((chk->rec.chunk_id.id == SCTP_SELECTIVE_ACK) ||
7915 (chk->rec.chunk_id.id == SCTP_NR_SELECTIVE_ACK)) {
7916 sack_goes_to = chk->whoTo;
7928 TAILQ_FOREACH(chk, &asoc->send_queue, sctp_next) {
7929 if (chk->whoTo == NULL) {
8013 TAILQ_FOREACH(chk, &asoc->control_send_queue, sctp_next) {
8014 if (chk->whoTo == NULL) {
8016 chk->whoTo = asoc->alternate;
8018 chk->whoTo = asoc->primary_destination;
8020 atomic_add_int(&chk->whoTo->ref_count, 1);
8088 TAILQ_FOREACH_SAFE(chk, &asoc->asconf_send_queue, sctp_next, nchk) {
8089 if (chk->rec.chunk_id.id != SCTP_ASCONF) {
8092 if (chk->whoTo == NULL) {
8103 if (chk->whoTo != net) {
8107 if (chk->data == NULL) {
8110 if (chk->sent != SCTP_DATAGRAM_UNSENT &&
8111 chk->sent != SCTP_DATAGRAM_RESEND) {
8123 sctp_auth_is_required_chunk(chk->rec.chunk_id.id,
8129 if ((chk->send_size < (int)(mtu - omtu)) ||
8130 (chk->flags & CHUNK_FLAGS_FRAGMENT_OK)) {
8133 * from the chk->data for control but the
8146 (sctp_auth_is_required_chunk(chk->rec.chunk_id.id,
8153 chk->rec.chunk_id.id);
8156 outchain = sctp_copy_mbufchain(chk->data, outchain, &endoutchain,
8157 (int)chk->rec.chunk_id.can_take_data,
8158 chk->send_size, chk->copy_by_ref);
8166 if (mtu > (chk->send_size + omtu))
8167 mtu -= (chk->send_size + omtu);
8170 to_out += (chk->send_size + omtu);
8172 if (chk->flags & CHUNK_FLAGS_FRAGMENT_OK) {
8175 if (chk->rec.chunk_id.can_take_data)
8176 chk->data = NULL;
8188 chk->sent = SCTP_DATAGRAM_SENT;
8189 if (chk->whoTo == NULL) {
8190 chk->whoTo = net;
8193 chk->snd_count++;
8291 TAILQ_FOREACH_SAFE(chk, &asoc->control_send_queue, sctp_next, nchk) {
8293 (chk->rec.chunk_id.id == SCTP_ECN_ECHO) &&
8294 (chk->whoTo != sack_goes_to)) {
8300 if (chk->whoTo == net) {
8314 if (chk->whoTo == NULL) {
8325 if (chk->whoTo != net) {
8330 if (chk->data == NULL) {
8333 if (chk->sent != SCTP_DATAGRAM_UNSENT) {
8350 sctp_auth_is_required_chunk(chk->rec.chunk_id.id,
8356 if ((chk->send_size <= (int)(mtu - omtu)) ||
8357 (chk->flags & CHUNK_FLAGS_FRAGMENT_OK)) {
8360 * from the chk->data for control but the
8373 (sctp_auth_is_required_chunk(chk->rec.chunk_id.id,
8380 chk->rec.chunk_id.id);
8383 outchain = sctp_copy_mbufchain(chk->data, outchain, &endoutchain,
8384 (int)chk->rec.chunk_id.can_take_data,
8385 chk->send_size, chk->copy_by_ref);
8393 if (mtu > (chk->send_size + omtu))
8394 mtu -= (chk->send_size + omtu);
8397 to_out += (chk->send_size + omtu);
8399 if (chk->flags & CHUNK_FLAGS_FRAGMENT_OK) {
8402 if (chk->rec.chunk_id.can_take_data)
8403 chk->data = NULL;
8405 if ((chk->rec.chunk_id.id == SCTP_SELECTIVE_ACK) ||
8406 (chk->rec.chunk_id.id == SCTP_NR_SELECTIVE_ACK) || /* EY */
8407 (chk->rec.chunk_id.id == SCTP_HEARTBEAT_REQUEST) ||
8408 (chk->rec.chunk_id.id == SCTP_HEARTBEAT_ACK) ||
8409 (chk->rec.chunk_id.id == SCTP_SHUTDOWN) ||
8410 (chk->rec.chunk_id.id == SCTP_SHUTDOWN_ACK) ||
8411 (chk->rec.chunk_id.id == SCTP_OPERATION_ERROR) ||
8412 (chk->rec.chunk_id.id == SCTP_COOKIE_ACK) ||
8413 (chk->rec.chunk_id.id == SCTP_ECN_CWR) ||
8414 (chk->rec.chunk_id.id == SCTP_PACKET_DROPPED) ||
8415 (chk->rec.chunk_id.id == SCTP_ASCONF_ACK)) {
8416 if (chk->rec.chunk_id.id == SCTP_HEARTBEAT_REQUEST) {
8420 if ((chk->rec.chunk_id.id == SCTP_SELECTIVE_ACK) ||
8421 (chk->rec.chunk_id.id == SCTP_NR_SELECTIVE_ACK)) {
8438 if (chk->rec.chunk_id.id == SCTP_COOKIE_ECHO) {
8441 } else if (chk->rec.chunk_id.id == SCTP_ECN_ECHO) {
8456 chk->sent = SCTP_DATAGRAM_SENT;
8457 if (chk->whoTo == NULL) {
8458 chk->whoTo = net;
8461 chk->snd_count++;
8643 TAILQ_FOREACH_SAFE(chk, &asoc->send_queue, sctp_next, nchk) {
8654 if ((chk->whoTo != NULL) &&
8655 (chk->whoTo != net)) {
8663 (chk->whoTo == NULL)) {
8667 (chk->whoTo == NULL)) {
8671 if ((chk->send_size > omtu) && ((chk->flags & CHUNK_FLAGS_FRAGMENT_OK) == 0)) {
8685 chk->send_size, mtu);
8686 chk->flags |= CHUNK_FLAGS_FRAGMENT_OK;
8692 dchkh = mtod(chk->data, struct sctp_data_chunk *);
8695 if (((chk->send_size <= mtu) && (chk->send_size <= r_mtu)) ||
8696 ((chk->flags & CHUNK_FLAGS_FRAGMENT_OK) && (chk->send_size <= asoc->peers_rwnd))) {
8712 auth_keyid = chk->auth_keyid;
8720 auth_keyid = chk->auth_keyid;
8722 } else if (auth_keyid != chk->auth_keyid) {
8730 outchain = sctp_copy_mbufchain(chk->data, outchain, &endoutchain, 0,
8731 chk->send_size, chk->copy_by_ref);
8743 if (chk->flags & CHUNK_FLAGS_FRAGMENT_OK) {
8747 if (mtu > chk->send_size)
8748 mtu -= chk->send_size;
8752 if (r_mtu > chk->send_size)
8753 r_mtu -= chk->send_size;
8757 to_out += chk->send_size;
8766 chk->window_probe = 0;
8767 data_list[bundle_at++] = chk;
8771 if (chk->sent == SCTP_DATAGRAM_UNSENT) {
8772 if ((chk->rec.data.rcv_flags & SCTP_DATA_UNORDERED) == 0) {
8777 if (((chk->rec.data.rcv_flags & SCTP_DATA_LAST_FRAG) == SCTP_DATA_LAST_FRAG) &&
8778 ((chk->rec.data.rcv_flags & SCTP_DATA_FIRST_FRAG) == 0))
8961 struct sctp_tmit_chunk *chk;
8993 sctp_alloc_a_chunk(stcb, chk);
8994 if (chk == NULL) {
8999 chk->copy_by_ref = 0;
9000 chk->rec.chunk_id.id = SCTP_OPERATION_ERROR;
9001 chk->rec.chunk_id.can_take_data = 0;
9002 chk->flags = 0;
9003 chk->send_size = (uint16_t)chunk_length;
9004 chk->sent = SCTP_DATAGRAM_UNSENT;
9005 chk->snd_count = 0;
9006 chk->asoc = &stcb->asoc;
9007 chk->data = op_err;
9008 chk->whoTo = NULL;
9012 hdr->chunk_length = htons(chk->send_size);
9013 TAILQ_INSERT_TAIL(&chk->asoc->control_send_queue, chk, sctp_next);
9014 chk->asoc->ctrl_queue_cnt++;
9031 struct sctp_tmit_chunk *chk;
9083 sctp_alloc_a_chunk(stcb, chk);
9084 if (chk == NULL) {
9089 chk->copy_by_ref = 0;
9090 chk->rec.chunk_id.id = SCTP_COOKIE_ECHO;
9091 chk->rec.chunk_id.can_take_data = 0;
9092 chk->flags = CHUNK_FLAGS_FRAGMENT_OK;
9093 chk->send_size = SCTP_SIZE32(plen);
9094 chk->sent = SCTP_DATAGRAM_UNSENT;
9095 chk->snd_count = 0;
9096 chk->asoc = &stcb->asoc;
9097 chk->data = cookie;
9098 chk->whoTo = net;
9099 atomic_add_int(&chk->whoTo->ref_count, 1);
9100 TAILQ_INSERT_HEAD(&chk->asoc->control_send_queue, chk, sctp_next);
9101 chk->asoc->ctrl_queue_cnt++;
9117 struct sctp_tmit_chunk *chk;
9139 sctp_alloc_a_chunk(stcb, chk);
9140 if (chk == NULL) {
9145 chk->copy_by_ref = 0;
9146 chk->rec.chunk_id.id = SCTP_HEARTBEAT_ACK;
9147 chk->rec.chunk_id.can_take_data = 1;
9148 chk->flags = 0;
9149 chk->send_size = chk_length;
9150 chk->sent = SCTP_DATAGRAM_UNSENT;
9151 chk->snd_count = 0;
9152 chk->asoc = &stcb->asoc;
9153 chk->data = outchain;
9154 chk->whoTo = net;
9155 atomic_add_int(&chk->whoTo->ref_count, 1);
9156 TAILQ_INSERT_TAIL(&chk->asoc->control_send_queue, chk, sctp_next);
9157 chk->asoc->ctrl_queue_cnt++;
9166 struct sctp_tmit_chunk *chk;
9176 sctp_alloc_a_chunk(stcb, chk);
9177 if (chk == NULL) {
9182 chk->copy_by_ref = 0;
9183 chk->rec.chunk_id.id = SCTP_COOKIE_ACK;
9184 chk->rec.chunk_id.can_take_data = 1;
9185 chk->flags = 0;
9186 chk->send_size = sizeof(struct sctp_chunkhdr);
9187 chk->sent = SCTP_DATAGRAM_UNSENT;
9188 chk->snd_count = 0;
9189 chk->asoc = &stcb->asoc;
9190 chk->data = cookie_ack;
9191 if (chk->asoc->last_control_chunk_from != NULL) {
9192 chk->whoTo = chk->asoc->last_control_chunk_from;
9193 atomic_add_int(&chk->whoTo->ref_count, 1);
9195 chk->whoTo = NULL;
9200 hdr->chunk_length = htons(chk->send_size);
9201 SCTP_BUF_LEN(cookie_ack) = chk->send_size;
9202 TAILQ_INSERT_TAIL(&chk->asoc->control_send_queue, chk, sctp_next);
9203 chk->asoc->ctrl_queue_cnt++;
9213 struct sctp_tmit_chunk *chk;
9221 sctp_alloc_a_chunk(stcb, chk);
9222 if (chk == NULL) {
9227 chk->copy_by_ref = 0;
9228 chk->rec.chunk_id.id = SCTP_SHUTDOWN_ACK;
9229 chk->rec.chunk_id.can_take_data = 1;
9230 chk->flags = 0;
9231 chk->send_size = sizeof(struct sctp_chunkhdr);
9232 chk->sent = SCTP_DATAGRAM_UNSENT;
9233 chk->snd_count = 0;
9234 chk->asoc = &stcb->asoc;
9235 chk->data = m_shutdown_ack;
9236 chk->whoTo = net;
9237 if (chk->whoTo) {
9238 atomic_add_int(&chk->whoTo->ref_count, 1);
9243 ack_cp->ch.chunk_length = htons(chk->send_size);
9244 SCTP_BUF_LEN(m_shutdown_ack) = chk->send_size;
9245 TAILQ_INSERT_TAIL(&chk->asoc->control_send_queue, chk, sctp_next);
9246 chk->asoc->ctrl_queue_cnt++;
9256 struct sctp_tmit_chunk *chk;
9258 TAILQ_FOREACH(chk, &stcb->asoc.control_send_queue, sctp_next) {
9259 if (chk->rec.chunk_id.id == SCTP_SHUTDOWN) {
9261 if (chk->whoTo) {
9262 sctp_free_remote_addr(chk->whoTo);
9263 chk->whoTo = NULL;
9268 if (chk == NULL) {
9275 sctp_alloc_a_chunk(stcb, chk);
9276 if (chk == NULL) {
9281 chk->copy_by_ref = 0;
9282 chk->rec.chunk_id.id = SCTP_SHUTDOWN;
9283 chk->rec.chunk_id.can_take_data = 1;
9284 chk->flags = 0;
9285 chk->send_size = sizeof(struct sctp_shutdown_chunk);
9286 chk->sent = SCTP_DATAGRAM_UNSENT;
9287 chk->snd_count = 0;
9288 chk->asoc = &stcb->asoc;
9289 chk->data = m_shutdown;
9290 chk->whoTo = net;
9291 if (chk->whoTo) {
9292 atomic_add_int(&chk->whoTo->ref_count, 1);
9297 shutdown_cp->ch.chunk_length = htons(chk->send_size);
9299 SCTP_BUF_LEN(m_shutdown) = chk->send_size;
9300 TAILQ_INSERT_TAIL(&chk->asoc->control_send_queue, chk, sctp_next);
9301 chk->asoc->ctrl_queue_cnt++;
9303 TAILQ_REMOVE(&stcb->asoc.control_send_queue, chk, sctp_next);
9304 chk->whoTo = net;
9305 if (chk->whoTo) {
9306 atomic_add_int(&chk->whoTo->ref_count, 1);
9308 shutdown_cp = mtod(chk->data, struct sctp_shutdown_chunk *);
9310 TAILQ_INSERT_TAIL(&stcb->asoc.control_send_queue, chk, sctp_next);
9322 struct sctp_tmit_chunk *chk;
9340 sctp_alloc_a_chunk(stcb, chk);
9341 if (chk == NULL) {
9347 chk->copy_by_ref = 0;
9348 chk->rec.chunk_id.id = SCTP_ASCONF;
9349 chk->rec.chunk_id.can_take_data = 0;
9350 chk->flags = CHUNK_FLAGS_FRAGMENT_OK;
9351 chk->data = m_asconf;
9352 chk->send_size = len;
9353 chk->sent = SCTP_DATAGRAM_UNSENT;
9354 chk->snd_count = 0;
9355 chk->asoc = &stcb->asoc;
9356 chk->whoTo = net;
9357 if (chk->whoTo) {
9358 atomic_add_int(&chk->whoTo->ref_count, 1);
9360 TAILQ_INSERT_TAIL(&chk->asoc->asconf_send_queue, chk, sctp_next);
9361 chk->asoc->ctrl_queue_cnt++;
9372 struct sctp_tmit_chunk *chk;
9430 sctp_alloc_a_chunk(stcb, chk);
9431 if (chk == NULL) {
9437 chk->copy_by_ref = 0;
9438 chk->rec.chunk_id.id = SCTP_ASCONF_ACK;
9439 chk->rec.chunk_id.can_take_data = 1;
9440 chk->flags = CHUNK_FLAGS_FRAGMENT_OK;
9441 chk->whoTo = net;
9442 if (chk->whoTo) {
9443 atomic_add_int(&chk->whoTo->ref_count, 1);
9445 chk->data = m_ack;
9446 chk->send_size = ack->len;
9447 chk->sent = SCTP_DATAGRAM_UNSENT;
9448 chk->snd_count = 0;
9449 chk->asoc = &stcb->asoc;
9451 TAILQ_INSERT_TAIL(&chk->asoc->control_send_queue, chk, sctp_next);
9452 chk->asoc->ctrl_queue_cnt++;
9476 struct sctp_tmit_chunk *chk, *fwd;
9512 TAILQ_FOREACH(chk, &asoc->control_send_queue, sctp_next) {
9513 if ((chk->rec.chunk_id.id == SCTP_COOKIE_ECHO) ||
9514 (chk->rec.chunk_id.id == SCTP_STREAM_RESET) ||
9515 (chk->rec.chunk_id.id == SCTP_FORWARD_CUM_TSN)) {
9516 if (chk->sent != SCTP_DATAGRAM_RESEND) {
9519 if (chk->rec.chunk_id.id == SCTP_STREAM_RESET) {
9520 if (chk != asoc->str_reset) {
9529 if (chk->rec.chunk_id.id == SCTP_FORWARD_CUM_TSN) {
9537 (sctp_auth_is_required_chunk(chk->rec.chunk_id.id,
9542 chk->rec.chunk_id.id);
9545 m = sctp_copy_mbufchain(chk->data, m, &endofchain, 0, chk->send_size, chk->copy_by_ref);
9561 if (chk->rec.chunk_id.id == SCTP_COOKIE_ECHO) {
9562 sctp_timer_start(SCTP_TIMER_TYPE_COOKIE, inp, stcb, chk->whoTo);
9564 } else if (chk->rec.chunk_id.id == SCTP_ASCONF) {
9566 sctp_timer_start(SCTP_TIMER_TYPE_ASCONF, inp, stcb, chk->whoTo);
9569 chk->snd_count++; /* update our count */
9570 if ((error = sctp_lowlevel_chunk_output(inp, stcb, chk->whoTo,
9571 (struct sockaddr *)&chk->whoTo->ro._l_addr, m,
9575 chk->whoTo->port, NULL,
9595 /* (void)SCTP_GETTIME_TIMEVAL(&chk->whoTo->last_sent_time); */
9597 chk->sent = SCTP_DATAGRAM_SENT;
9623 TAILQ_FOREACH(chk, &asoc->sent_queue, sctp_next) {
9624 if (chk->sent != SCTP_DATAGRAM_RESEND) {
9628 if (chk->data == NULL) {
9629 SCTP_PRINTF("TSN:%x chk->snd_count:%d chk->sent:%d can't retran - no data\n",
9630 chk->rec.data.tsn, chk->snd_count, chk->sent);
9634 (chk->snd_count >= SCTP_BASE_SYSCTL(sctp_max_retran_chunk))) {
9639 chk->rec.data.tsn, chk->snd_count);
9650 net = chk->whoTo;
9673 if (tsn == chk->rec.data.tsn) {
9689 chk->window_probe = 1;
9690 chk->whoTo->window_probe = 1;
9699 if (chk->rec.data.doing_fast_retransmit == 0) {
9727 if ((chk->send_size <= (mtu - dmtu)) ||
9728 (chk->flags & CHUNK_FLAGS_FRAGMENT_OK)) {
9738 auth_keyid = chk->auth_keyid;
9742 auth_keyid = chk->auth_keyid;
9744 } else if (chk->auth_keyid != auth_keyid) {
9749 m = sctp_copy_mbufchain(chk->data, m, &endofchain, 0, chk->send_size, chk->copy_by_ref);
9755 if (chk->flags & CHUNK_FLAGS_FRAGMENT_OK) {
9759 if (mtu > (chk->send_size + dmtu))
9760 mtu -= (chk->send_size + dmtu);
9763 data_list[bundle_at++] = chk;
9770 * now are there anymore forward from chk to pick
9773 for (fwd = TAILQ_NEXT(chk, sctp_next); fwd != NULL; fwd = TAILQ_NEXT(fwd, sctp_next)) {
10333 struct sctp_tmit_chunk *chk, *at, *tp1, *last;
10343 TAILQ_FOREACH(chk, &asoc->control_send_queue, sctp_next) {
10344 if (chk->rec.chunk_id.id == SCTP_FORWARD_CUM_TSN) {
10346 chk->sent = SCTP_DATAGRAM_UNSENT;
10347 chk->snd_count = 0;
10349 if (chk->whoTo) {
10350 sctp_free_remote_addr(chk->whoTo);
10351 chk->whoTo = NULL;
10357 sctp_alloc_a_chunk(stcb, chk);
10358 if (chk == NULL) {
10362 chk->copy_by_ref = 0;
10368 chk->rec.chunk_id.id = SCTP_FORWARD_CUM_TSN;
10369 chk->rec.chunk_id.can_take_data = 0;
10370 chk->flags = 0;
10371 chk->asoc = asoc;
10372 chk->whoTo = NULL;
10373 chk->data = sctp_get_mbuf_for_msg(MCLBYTES, 0, M_NOWAIT, 1, MT_DATA);
10374 if (chk->data == NULL) {
10375 sctp_free_a_chunk(stcb, chk, SCTP_SO_NOT_LOCKED);
10378 SCTP_BUF_RESV_UF(chk->data, SCTP_MIN_OVERHEAD);
10379 chk->sent = SCTP_DATAGRAM_UNSENT;
10380 chk->snd_count = 0;
10381 TAILQ_INSERT_TAIL(&asoc->control_send_queue, chk, sctp_next);
10388 SCTP_BUF_LEN(chk->data) = 0;
10408 cnt_of_space = (unsigned int)M_TRAILINGSPACE(chk->data);
10476 chk->send_size = space_needed;
10478 fwdtsn = mtod(chk->data, struct sctp_forward_tsn_chunk *);
10479 fwdtsn->ch.chunk_length = htons(chk->send_size);
10487 SCTP_BUF_LEN(chk->data) = chk->send_size;
10553 struct sctp_tmit_chunk *chk, *a_chk;
10586 TAILQ_FOREACH(chk, &asoc->control_send_queue, sctp_next) {
10587 if (chk->rec.chunk_id.id == type) {
10589 TAILQ_REMOVE(&asoc->control_send_queue, chk, sctp_next);
10591 a_chk = chk;
11375 struct sctp_tmit_chunk *chk;
11396 sctp_alloc_a_chunk(stcb, chk);
11397 if (chk == NULL) {
11402 chk->copy_by_ref = 0;
11403 chk->rec.chunk_id.id = SCTP_HEARTBEAT_REQUEST;
11404 chk->rec.chunk_id.can_take_data = 1;
11405 chk->flags = 0;
11406 chk->asoc = &stcb->asoc;
11407 chk->send_size = sizeof(struct sctp_heartbeat_chunk);
11409 chk->data = sctp_get_mbuf_for_msg(chk->send_size, 0, M_NOWAIT, 1, MT_HEADER);
11410 if (chk->data == NULL) {
11411 sctp_free_a_chunk(stcb, chk, so_locked);
11414 SCTP_BUF_RESV_UF(chk->data, SCTP_MIN_OVERHEAD);
11415 SCTP_BUF_LEN(chk->data) = chk->send_size;
11416 chk->sent = SCTP_DATAGRAM_UNSENT;
11417 chk->snd_count = 0;
11418 chk->whoTo = net;
11419 atomic_add_int(&chk->whoTo->ref_count, 1);
11421 hb = mtod(chk->data, struct sctp_heartbeat_chunk *);
11426 hb->ch.chunk_length = htons(chk->send_size);
11462 if (chk->data) {
11463 sctp_m_freem(chk->data);
11464 chk->data = NULL;
11466 sctp_free_a_chunk(stcb, chk, so_locked);
11471 TAILQ_INSERT_TAIL(&stcb->asoc.control_send_queue, chk, sctp_next);
11483 struct sctp_tmit_chunk *chk;
11490 TAILQ_FOREACH(chk, &asoc->control_send_queue, sctp_next) {
11491 if ((chk->rec.chunk_id.id == SCTP_ECN_ECHO) && (net == chk->whoTo)) {
11495 ecne = mtod(chk->data, struct sctp_ecne_chunk *);
11508 sctp_alloc_a_chunk(stcb, chk);
11509 if (chk == NULL) {
11513 chk->copy_by_ref = 0;
11514 chk->rec.chunk_id.id = SCTP_ECN_ECHO;
11515 chk->rec.chunk_id.can_take_data = 0;
11516 chk->flags = 0;
11517 chk->asoc = &stcb->asoc;
11518 chk->send_size = sizeof(struct sctp_ecne_chunk);
11519 chk->data = sctp_get_mbuf_for_msg(chk->send_size, 0, M_NOWAIT, 1, MT_HEADER);
11520 if (chk->data == NULL) {
11521 sctp_free_a_chunk(stcb, chk, SCTP_SO_NOT_LOCKED);
11524 SCTP_BUF_RESV_UF(chk->data, SCTP_MIN_OVERHEAD);
11525 SCTP_BUF_LEN(chk->data) = chk->send_size;
11526 chk->sent = SCTP_DATAGRAM_UNSENT;
11527 chk->snd_count = 0;
11528 chk->whoTo = net;
11529 atomic_add_int(&chk->whoTo->ref_count, 1);
11532 ecne = mtod(chk->data, struct sctp_ecne_chunk *);
11538 TAILQ_INSERT_HEAD(&stcb->asoc.control_send_queue, chk, sctp_next);
11548 struct sctp_tmit_chunk *chk;
11571 sctp_alloc_a_chunk(stcb, chk);
11572 if (chk == NULL) {
11575 chk->copy_by_ref = 0;
11576 chk->rec.chunk_id.id = SCTP_PACKET_DROPPED;
11577 chk->rec.chunk_id.can_take_data = 1;
11578 chk->flags = 0;
11580 chk->send_size = len;
11601 sctp_free_a_chunk(stcb, chk, SCTP_SO_NOT_LOCKED);
11620 chk->asoc = &stcb->asoc;
11621 chk->data = sctp_get_mbuf_for_msg(MCLBYTES, 0, M_NOWAIT, 1, MT_DATA);
11622 if (chk->data == NULL) {
11624 sctp_free_a_chunk(stcb, chk, SCTP_SO_NOT_LOCKED);
11627 SCTP_BUF_RESV_UF(chk->data, SCTP_MIN_OVERHEAD);
11628 drp = mtod(chk->data, struct sctp_pktdrop_chunk *);
11630 sctp_m_freem(chk->data);
11631 chk->data = NULL;
11634 chk->book_size = SCTP_SIZE32((chk->send_size + sizeof(struct sctp_pktdrop_chunk) +
11636 chk->book_size_scale = 0;
11644 chk->send_size = (uint16_t)(len - sizeof(struct sctp_pktdrop_chunk));
11645 len = chk->send_size;
11654 chk->send_size += sizeof(struct sctp_pktdrop_chunk);
11655 SCTP_BUF_LEN(chk->data) = chk->send_size;
11656 chk->sent = SCTP_DATAGRAM_UNSENT;
11657 chk->snd_count = 0;
11660 chk->whoTo = net;
11661 atomic_add_int(&chk->whoTo->ref_count, 1);
11663 chk->whoTo = NULL;
11666 drp->ch.chunk_length = htons(chk->send_size);
11687 TAILQ_INSERT_TAIL(&stcb->asoc.control_send_queue, chk, sctp_next);
11696 struct sctp_tmit_chunk *chk;
11703 TAILQ_FOREACH(chk, &asoc->control_send_queue, sctp_next) {
11704 if ((chk->rec.chunk_id.id == SCTP_ECN_CWR) && (net == chk->whoTo)) {
11711 cwr = mtod(chk->data, struct sctp_cwr_chunk *);
11723 sctp_alloc_a_chunk(stcb, chk);
11724 if (chk == NULL) {
11727 chk->copy_by_ref = 0;
11728 chk->rec.chunk_id.id = SCTP_ECN_CWR;
11729 chk->rec.chunk_id.can_take_data = 1;
11730 chk->flags = 0;
11731 chk->asoc = asoc;
11732 chk->send_size = sizeof(struct sctp_cwr_chunk);
11733 chk->data = sctp_get_mbuf_for_msg(chk->send_size, 0, M_NOWAIT, 1, MT_HEADER);
11734 if (chk->data == NULL) {
11735 sctp_free_a_chunk(stcb, chk, SCTP_SO_NOT_LOCKED);
11738 SCTP_BUF_RESV_UF(chk->data, SCTP_MIN_OVERHEAD);
11739 SCTP_BUF_LEN(chk->data) = chk->send_size;
11740 chk->sent = SCTP_DATAGRAM_UNSENT;
11741 chk->snd_count = 0;
11742 chk->whoTo = net;
11743 atomic_add_int(&chk->whoTo->ref_count, 1);
11744 cwr = mtod(chk->data, struct sctp_cwr_chunk *);
11749 TAILQ_INSERT_TAIL(&asoc->control_send_queue, chk, sctp_next);
11754 sctp_add_stream_reset_out(struct sctp_tcb *stcb, struct sctp_tmit_chunk *chk,
11763 ch = mtod(chk->data, struct sctp_chunkhdr *);
11819 chk->book_size = len + old_len;
11820 chk->book_size_scale = 0;
11821 chk->send_size = SCTP_SIZE32(chk->book_size);
11822 SCTP_BUF_LEN(chk->data) = chk->send_size;
11827 sctp_add_stream_reset_in(struct sctp_tmit_chunk *chk,
11835 ch = mtod(chk->data, struct sctp_chunkhdr *);
11860 chk->book_size = len + old_len;
11861 chk->book_size_scale = 0;
11862 chk->send_size = SCTP_SIZE32(chk->book_size);
11863 SCTP_BUF_LEN(chk->data) = chk->send_size;
11868 sctp_add_stream_reset_tsn(struct sctp_tmit_chunk *chk,
11875 ch = mtod(chk->data, struct sctp_chunkhdr *);
11888 chk->send_size = len + old_len;
11889 chk->book_size = SCTP_SIZE32(chk->send_size);
11890 chk->book_size_scale = 0;
11891 SCTP_BUF_LEN(chk->data) = SCTP_SIZE32(chk->send_size);
11896 sctp_add_stream_reset_result(struct sctp_tmit_chunk *chk,
11903 ch = mtod(chk->data, struct sctp_chunkhdr *);
11917 chk->book_size = len + old_len;
11918 chk->book_size_scale = 0;
11919 chk->send_size = SCTP_SIZE32(chk->book_size);
11920 SCTP_BUF_LEN(chk->data) = chk->send_size;
11930 struct sctp_tmit_chunk *chk;
11944 sctp_alloc_a_chunk(stcb, chk);
11945 if (chk == NULL) {
11949 chk->copy_by_ref = 0;
11950 chk->rec.chunk_id.id = SCTP_STREAM_RESET;
11951 chk->rec.chunk_id.can_take_data = 0;
11952 chk->flags = 0;
11953 chk->asoc = &stcb->asoc;
11954 chk->book_size = sizeof(struct sctp_chunkhdr);
11955 chk->send_size = SCTP_SIZE32(chk->book_size);
11956 chk->book_size_scale = 0;
11957 chk->data = sctp_get_mbuf_for_msg(MCLBYTES, 0, M_NOWAIT, 1, MT_DATA);
11958 if (chk->data == NULL) {
11959 sctp_free_a_chunk(stcb, chk, SCTP_SO_LOCKED);
11963 SCTP_BUF_RESV_UF(chk->data, SCTP_MIN_OVERHEAD);
11965 chk->sent = SCTP_DATAGRAM_UNSENT;
11966 chk->snd_count = 0;
11968 chk->whoTo = stcb->asoc.alternate;
11970 chk->whoTo = stcb->asoc.primary_destination;
11972 ch = mtod(chk->data, struct sctp_chunkhdr *);
11975 ch->chunk_length = htons(chk->book_size);
11976 atomic_add_int(&chk->whoTo->ref_count, 1);
11977 SCTP_BUF_LEN(chk->data) = chk->send_size;
11978 sctp_add_stream_reset_result(chk, ent->seq, response);
11981 chk,
11987 sctp_add_stream_reset_result_tsn(struct sctp_tmit_chunk *chk,
11995 ch = mtod(chk->data, struct sctp_chunkhdr *);
12011 chk->book_size = len + old_len;
12012 chk->send_size = SCTP_SIZE32(chk->book_size);
12013 chk->book_size_scale = 0;
12014 SCTP_BUF_LEN(chk->data) = chk->send_size;
12019 sctp_add_an_out_stream(struct sctp_tmit_chunk *chk,
12027 ch = mtod(chk->data, struct sctp_chunkhdr *);
12044 chk->send_size = len + old_len;
12045 chk->book_size = SCTP_SIZE32(chk->send_size);
12046 chk->book_size_scale = 0;
12047 SCTP_BUF_LEN(chk->data) = SCTP_SIZE32(chk->send_size);
12052 sctp_add_an_in_stream(struct sctp_tmit_chunk *chk,
12060 ch = mtod(chk->data, struct sctp_chunkhdr *);
12076 chk->send_size = len + old_len;
12077 chk->book_size = SCTP_SIZE32(chk->send_size);
12078 chk->book_size_scale = 0;
12079 SCTP_BUF_LEN(chk->data) = SCTP_SIZE32(chk->send_size);
12087 struct sctp_tmit_chunk *chk;
12096 sctp_alloc_a_chunk(stcb, chk);
12097 if (chk == NULL) {
12101 chk->copy_by_ref = 0;
12102 chk->rec.chunk_id.id = SCTP_STREAM_RESET;
12103 chk->rec.chunk_id.can_take_data = 0;
12104 chk->flags = 0;
12105 chk->asoc = &stcb->asoc;
12106 chk->book_size = sizeof(struct sctp_chunkhdr);
12107 chk->send_size = SCTP_SIZE32(chk->book_size);
12108 chk->book_size_scale = 0;
12109 chk->data = sctp_get_mbuf_for_msg(MCLBYTES, 0, M_NOWAIT, 1, MT_DATA);
12110 if (chk->data == NULL) {
12111 sctp_free_a_chunk(stcb, chk, so_locked);
12115 SCTP_BUF_RESV_UF(chk->data, SCTP_MIN_OVERHEAD);
12118 chk->sent = SCTP_DATAGRAM_UNSENT;
12119 chk->snd_count = 0;
12121 chk->whoTo = stcb->asoc.alternate;
12123 chk->whoTo = stcb->asoc.primary_destination;
12125 ch = mtod(chk->data, struct sctp_chunkhdr *);
12128 ch->chunk_length = htons(chk->book_size);
12129 atomic_add_int(&chk->whoTo->ref_count, 1);
12130 SCTP_BUF_LEN(chk->data) = chk->send_size;
12132 if (sctp_add_stream_reset_out(stcb, chk, seq, (stcb->asoc.str_reset_seq_in - 1), (stcb->asoc.sending_seq - 1))) {
12136 m_freem(chk->data);
12137 chk->data = NULL;
12138 sctp_free_a_chunk(stcb, chk, so_locked);
12141 asoc->str_reset = chk;
12144 chk,
12151 sctp_timer_start(SCTP_TIMER_TYPE_STRRESET, stcb->sctp_ep, stcb, chk->whoTo);
12165 struct sctp_tmit_chunk *chk;
12201 sctp_alloc_a_chunk(stcb, chk);
12202 if (chk == NULL) {
12206 chk->copy_by_ref = 0;
12207 chk->rec.chunk_id.id = SCTP_STREAM_RESET;
12208 chk->rec.chunk_id.can_take_data = 0;
12209 chk->flags = 0;
12210 chk->asoc = &stcb->asoc;
12211 chk->book_size = sizeof(struct sctp_chunkhdr);
12212 chk->send_size = SCTP_SIZE32(chk->book_size);
12213 chk->book_size_scale = 0;
12214 chk->data = sctp_get_mbuf_for_msg(MCLBYTES, 0, M_NOWAIT, 1, MT_DATA);
12215 if (chk->data == NULL) {
12216 sctp_free_a_chunk(stcb, chk, SCTP_SO_LOCKED);
12220 SCTP_BUF_RESV_UF(chk->data, SCTP_MIN_OVERHEAD);
12223 chk->sent = SCTP_DATAGRAM_UNSENT;
12224 chk->snd_count = 0;
12226 chk->whoTo = stcb->asoc.alternate;
12228 chk->whoTo = stcb->asoc.primary_destination;
12230 atomic_add_int(&chk->whoTo->ref_count, 1);
12231 ch = mtod(chk->data, struct sctp_chunkhdr *);
12234 ch->chunk_length = htons(chk->book_size);
12235 SCTP_BUF_LEN(chk->data) = chk->send_size;
12241 ret = sctp_add_stream_reset_out(stcb, chk, seq, (stcb->asoc.str_reset_seq_in - 1), (stcb->asoc.sending_seq - 1));
12333 sctp_add_an_out_stream(chk, seq, adding_o);
12338 sctp_add_an_in_stream(chk, seq, adding_i);
12343 sctp_add_stream_reset_in(chk, number_entries, list, seq);
12348 sctp_add_stream_reset_tsn(chk, seq);
12351 asoc->str_reset = chk;
12354 chk,
12360 sctp_timer_start(SCTP_TIMER_TYPE_STRRESET, stcb->sctp_ep, stcb, chk->whoTo);