Lines Matching refs:chk

6184 	struct sctp_tmit_chunk *chk, *nchk;
6189 TAILQ_FOREACH(chk, &asoc->sent_queue, sctp_next) {
6196 if (PR_SCTP_BUF_ENABLED(chk->flags)) {
6201 if (chk->rec.data.timetodrop.tv_sec > (long)srcv->sinfo_timetolive) {
6209 if (chk->data) {
6217 if (chk->sent > SCTP_DATAGRAM_UNSENT)
6221 ret_spc = sctp_release_pr_sctp_chunk(stcb, chk,
6233 TAILQ_FOREACH_SAFE(chk, &asoc->send_queue, sctp_next, nchk) {
6235 if (PR_SCTP_BUF_ENABLED(chk->flags)) {
6236 if (chk->rec.data.timetodrop.tv_sec > (long)srcv->sinfo_timetolive) {
6237 if (chk->data) {
6244 ret_spc = sctp_release_pr_sctp_chunk(stcb, chk,
6251 } /* end if chk->data */
6253 } /* end if chk pr-sctp */
6254 } /* tailqforeachsafe (chk) */
6941 struct sctp_tmit_chunk *chk, *nchk;
6943 TAILQ_FOREACH_SAFE(chk, &asoc->control_send_queue, sctp_next, nchk) {
6944 if (chk->rec.chunk_id.id == SCTP_COOKIE_ECHO) {
6945 TAILQ_REMOVE(&asoc->control_send_queue, chk, sctp_next);
6947 if (chk->data) {
6948 sctp_m_freem(chk->data);
6949 chk->data = NULL;
6951 sctp_free_a_chunk(stcb, chk, SCTP_SO_NOT_LOCKED);
6960 struct sctp_tmit_chunk *chk, *nchk;
6964 TAILQ_FOREACH_SAFE(chk, &asoc->asconf_send_queue, sctp_next, nchk) {
6966 if (chk->rec.chunk_id.id == SCTP_ASCONF) {
6967 if (chk->data) {
6968 acp = mtod(chk->data, struct sctp_asconf_chunk *);
6974 TAILQ_REMOVE(&asoc->asconf_send_queue, chk, sctp_next);
6976 if (chk->data) {
6977 sctp_m_freem(chk->data);
6978 chk->data = NULL;
6980 sctp_free_a_chunk(stcb, chk, SCTP_SO_NOT_LOCKED);
7085 struct sctp_tmit_chunk *chk, *nchk;
7087 TAILQ_FOREACH_SAFE(chk, &asoc->control_send_queue, sctp_next, nchk) {
7088 if ((chk->rec.chunk_id.id == SCTP_SELECTIVE_ACK) ||
7089 (chk->rec.chunk_id.id == SCTP_NR_SELECTIVE_ACK) || /* EY */
7090 (chk->rec.chunk_id.id == SCTP_HEARTBEAT_REQUEST) ||
7091 (chk->rec.chunk_id.id == SCTP_HEARTBEAT_ACK) ||
7092 (chk->rec.chunk_id.id == SCTP_FORWARD_CUM_TSN) ||
7093 (chk->rec.chunk_id.id == SCTP_SHUTDOWN) ||
7094 (chk->rec.chunk_id.id == SCTP_SHUTDOWN_ACK) ||
7095 (chk->rec.chunk_id.id == SCTP_OPERATION_ERROR) ||
7096 (chk->rec.chunk_id.id == SCTP_PACKET_DROPPED) ||
7097 (chk->rec.chunk_id.id == SCTP_COOKIE_ACK) ||
7098 (chk->rec.chunk_id.id == SCTP_ECN_CWR) ||
7099 (chk->rec.chunk_id.id == SCTP_ASCONF_ACK)) {
7102 TAILQ_REMOVE(&asoc->control_send_queue, chk, sctp_next);
7104 if (chk->data) {
7105 sctp_m_freem(chk->data);
7106 chk->data = NULL;
7108 if (chk->rec.chunk_id.id == SCTP_FORWARD_CUM_TSN) {
7111 sctp_free_a_chunk(stcb, chk, so_locked);
7112 } else if (chk->rec.chunk_id.id == SCTP_STREAM_RESET) {
7114 if (chk != asoc->str_reset) {
7197 struct sctp_tmit_chunk *chk;
7384 sctp_alloc_a_chunk(stcb, chk);
7385 if (chk == NULL) {
7403 memset(chk, 0, sizeof(*chk));
7404 chk->rec.data.rcv_flags = rcv_flags;
7416 chk->data = sp->data;
7417 chk->last_mbuf = sp->tail_mbuf;
7424 chk->data = SCTP_M_COPYM(sp->data, 0, to_move, M_NOWAIT);
7425 chk->last_mbuf = NULL;
7426 if (chk->data == NULL) {
7428 sctp_free_a_chunk(stcb, chk, so_locked);
7435 sctp_log_mbc(chk->data, SCTP_MBUF_ICOPY);
7464 if (SCTP_BUF_IS_EXTENDED(chk->data)) {
7465 chk->copy_by_ref = 1;
7467 chk->copy_by_ref = 0;
7473 if (chk->last_mbuf == NULL) {
7474 chk->last_mbuf = chk->data;
7475 while (SCTP_BUF_NEXT(chk->last_mbuf) != NULL) {
7476 chk->last_mbuf = SCTP_BUF_NEXT(chk->last_mbuf);
7495 if (M_LEADINGSPACE(chk->data) < leading) {
7512 sp->data = chk->data;
7513 sp->tail_mbuf = chk->last_mbuf;
7519 sp->data = chk->data;
7520 SCTP_BUF_NEXT(chk->last_mbuf) = m_tmp;
7524 chk->data = NULL;
7526 sctp_free_a_chunk(stcb, chk, so_locked);
7531 SCTP_BUF_NEXT(m) = chk->data;
7532 chk->data = m;
7533 M_ALIGN(chk->data, 4);
7536 SCTP_BUF_PREPEND(chk->data, SCTP_DATA_CHUNK_OVERHEAD(stcb), M_NOWAIT);
7537 if (chk->data == NULL) {
7543 sctp_free_a_chunk(stcb, chk, so_locked);
7550 chk->book_size = chk->send_size = (uint16_t)(to_move + SCTP_DATA_CHUNK_OVERHEAD(stcb));
7551 chk->book_size_scale = 0;
7552 chk->sent = SCTP_DATAGRAM_UNSENT;
7554 chk->flags = 0;
7555 chk->asoc = &stcb->asoc;
7556 chk->pad_inplace = 0;
7557 chk->no_fr_allowed = 0;
7561 chk->rec.data.mid = 0;
7563 chk->rec.data.mid = strq->next_mid_ordered;
7570 chk->rec.data.mid = strq->next_mid_unordered;
7575 chk->rec.data.mid = strq->next_mid_ordered;
7581 chk->rec.data.sid = sp->sid;
7582 chk->rec.data.ppid = sp->ppid;
7583 chk->rec.data.context = sp->context;
7584 chk->rec.data.doing_fast_retransmit = 0;
7586 chk->rec.data.timetodrop = sp->ts;
7587 chk->flags = sp->act_flags;
7590 chk->whoTo = sp->net;
7591 atomic_add_int(&chk->whoTo->ref_count, 1);
7593 chk->whoTo = NULL;
7596 chk->auth_keyid = sp->auth_keyid;
7597 sctp_auth_key_acquire(stcb, chk->auth_keyid);
7598 chk->holds_key_ref = 1;
7600 chk->rec.data.tsn = atomic_fetchadd_int(&asoc->sending_seq, 1);
7604 (uint32_t)((chk->rec.data.sid << 16) | (0x0000ffff & chk->rec.data.mid)),
7605 chk->rec.data.tsn);
7608 dchkh = mtod(chk->data, struct sctp_data_chunk *);
7610 ndchkh = mtod(chk->data, struct sctp_idata_chunk *);
7623 asoc->out_tsnlog[asoc->tsn_out_at].tsn = chk->rec.data.tsn;
7624 asoc->out_tsnlog[asoc->tsn_out_at].strm = chk->rec.data.sid;
7625 asoc->out_tsnlog[asoc->tsn_out_at].seq = chk->rec.data.mid;
7626 asoc->out_tsnlog[asoc->tsn_out_at].sz = chk->send_size;
7627 asoc->out_tsnlog[asoc->tsn_out_at].flgs = chk->rec.data.rcv_flags;
7635 dchkh->ch.chunk_flags = chk->rec.data.rcv_flags;
7636 dchkh->dp.tsn = htonl(chk->rec.data.tsn);
7638 dchkh->dp.ssn = htons((uint16_t)chk->rec.data.mid);
7639 dchkh->dp.ppid = chk->rec.data.ppid;
7640 dchkh->ch.chunk_length = htons(chk->send_size);
7643 ndchkh->ch.chunk_flags = chk->rec.data.rcv_flags;
7644 ndchkh->dp.tsn = htonl(chk->rec.data.tsn);
7647 ndchkh->dp.mid = htonl(chk->rec.data.mid);
7649 ndchkh->dp.ppid_fsn.ppid = chk->rec.data.ppid;
7653 ndchkh->ch.chunk_length = htons(chk->send_size);
7655 /* Now advance the chk->send_size by the actual pad needed. */
7656 if (chk->send_size < SCTP_SIZE32(chk->book_size)) {
7661 pads = SCTP_SIZE32(chk->book_size) - chk->send_size;
7662 lm = sctp_pad_lastmbuf(chk->data, pads, chk->last_mbuf);
7664 chk->last_mbuf = lm;
7665 chk->pad_inplace = 1;
7667 chk->send_size += pads;
7669 if (PR_SCTP_ENABLED(chk->flags)) {
7707 TAILQ_INSERT_TAIL(&asoc->send_queue, chk, sctp_next);
7798 struct sctp_tmit_chunk *chk;
7800 TAILQ_FOREACH(chk, &asoc->control_send_queue, sctp_next) {
7801 if (chk->rec.chunk_id.id == SCTP_ECN_ECHO) {
7802 chk->sent = SCTP_DATAGRAM_UNSENT;
7811 struct sctp_tmit_chunk *chk;
7827 TAILQ_FOREACH(chk, &asoc->send_queue, sctp_next) {
7828 if (chk->whoTo == net) {
7829 sctp_free_remote_addr(chk->whoTo);
7830 chk->whoTo = NULL;
7862 struct sctp_tmit_chunk *chk, *nchk;
7937 TAILQ_FOREACH(chk, &asoc->control_send_queue, sctp_next) {
7938 if ((chk->rec.chunk_id.id == SCTP_SELECTIVE_ACK) ||
7939 (chk->rec.chunk_id.id == SCTP_NR_SELECTIVE_ACK)) {
7940 sack_goes_to = chk->whoTo;
7952 TAILQ_FOREACH(chk, &asoc->send_queue, sctp_next) {
7953 if (chk->whoTo == NULL) {
8038 TAILQ_FOREACH(chk, &asoc->control_send_queue, sctp_next) {
8039 if (chk->whoTo == NULL) {
8041 chk->whoTo = asoc->alternate;
8043 chk->whoTo = asoc->primary_destination;
8045 atomic_add_int(&chk->whoTo->ref_count, 1);
8113 TAILQ_FOREACH_SAFE(chk, &asoc->asconf_send_queue, sctp_next, nchk) {
8114 if (chk->rec.chunk_id.id != SCTP_ASCONF) {
8117 if (chk->whoTo == NULL) {
8128 if (chk->whoTo != net) {
8132 if (chk->data == NULL) {
8135 if (chk->sent != SCTP_DATAGRAM_UNSENT &&
8136 chk->sent != SCTP_DATAGRAM_RESEND) {
8148 sctp_auth_is_required_chunk(chk->rec.chunk_id.id,
8154 if ((chk->send_size < (int)(mtu - omtu)) ||
8155 (chk->flags & CHUNK_FLAGS_FRAGMENT_OK)) {
8158 * from the chk->data for control but the
8171 (sctp_auth_is_required_chunk(chk->rec.chunk_id.id,
8178 chk->rec.chunk_id.id);
8181 outchain = sctp_copy_mbufchain(chk->data, outchain, &endoutchain,
8182 (int)chk->rec.chunk_id.can_take_data,
8183 chk->send_size, chk->copy_by_ref);
8191 if (mtu > (chk->send_size + omtu))
8192 mtu -= (chk->send_size + omtu);
8195 to_out += (chk->send_size + omtu);
8197 if (chk->flags & CHUNK_FLAGS_FRAGMENT_OK) {
8200 if (chk->rec.chunk_id.can_take_data)
8201 chk->data = NULL;
8213 chk->sent = SCTP_DATAGRAM_SENT;
8214 if (chk->whoTo == NULL) {
8215 chk->whoTo = net;
8218 chk->snd_count++;
8314 TAILQ_FOREACH_SAFE(chk, &asoc->control_send_queue, sctp_next, nchk) {
8316 (chk->rec.chunk_id.id == SCTP_ECN_ECHO) &&
8317 (chk->whoTo != sack_goes_to)) {
8323 if (chk->whoTo == net) {
8337 if (chk->whoTo == NULL) {
8348 if (chk->whoTo != net) {
8353 if (chk->data == NULL) {
8356 if (chk->sent != SCTP_DATAGRAM_UNSENT) {
8373 sctp_auth_is_required_chunk(chk->rec.chunk_id.id,
8379 if ((chk->send_size <= (int)(mtu - omtu)) ||
8380 (chk->flags & CHUNK_FLAGS_FRAGMENT_OK)) {
8383 * from the chk->data for control but the
8396 (sctp_auth_is_required_chunk(chk->rec.chunk_id.id,
8403 chk->rec.chunk_id.id);
8406 outchain = sctp_copy_mbufchain(chk->data, outchain, &endoutchain,
8407 (int)chk->rec.chunk_id.can_take_data,
8408 chk->send_size, chk->copy_by_ref);
8416 if (mtu > (chk->send_size + omtu))
8417 mtu -= (chk->send_size + omtu);
8420 to_out += (chk->send_size + omtu);
8422 if (chk->flags & CHUNK_FLAGS_FRAGMENT_OK) {
8425 if (chk->rec.chunk_id.can_take_data)
8426 chk->data = NULL;
8428 if ((chk->rec.chunk_id.id == SCTP_SELECTIVE_ACK) ||
8429 (chk->rec.chunk_id.id == SCTP_NR_SELECTIVE_ACK) || /* EY */
8430 (chk->rec.chunk_id.id == SCTP_HEARTBEAT_REQUEST) ||
8431 (chk->rec.chunk_id.id == SCTP_HEARTBEAT_ACK) ||
8432 (chk->rec.chunk_id.id == SCTP_SHUTDOWN) ||
8433 (chk->rec.chunk_id.id == SCTP_SHUTDOWN_ACK) ||
8434 (chk->rec.chunk_id.id == SCTP_OPERATION_ERROR) ||
8435 (chk->rec.chunk_id.id == SCTP_COOKIE_ACK) ||
8436 (chk->rec.chunk_id.id == SCTP_ECN_CWR) ||
8437 (chk->rec.chunk_id.id == SCTP_PACKET_DROPPED) ||
8438 (chk->rec.chunk_id.id == SCTP_ASCONF_ACK)) {
8439 if (chk->rec.chunk_id.id == SCTP_HEARTBEAT_REQUEST) {
8443 if ((chk->rec.chunk_id.id == SCTP_SELECTIVE_ACK) ||
8444 (chk->rec.chunk_id.id == SCTP_NR_SELECTIVE_ACK)) {
8461 if (chk->rec.chunk_id.id == SCTP_COOKIE_ECHO) {
8464 } else if (chk->rec.chunk_id.id == SCTP_ECN_ECHO) {
8479 chk->sent = SCTP_DATAGRAM_SENT;
8480 if (chk->whoTo == NULL) {
8481 chk->whoTo = net;
8484 chk->snd_count++;
8654 TAILQ_FOREACH_SAFE(chk, &asoc->send_queue, sctp_next, nchk) {
8665 if ((chk->whoTo != NULL) &&
8666 (chk->whoTo != net)) {
8674 (chk->whoTo == NULL)) {
8678 (chk->whoTo == NULL)) {
8682 if ((chk->send_size > omtu) && ((chk->flags & CHUNK_FLAGS_FRAGMENT_OK) == 0)) {
8696 chk->send_size, mtu);
8697 chk->flags |= CHUNK_FLAGS_FRAGMENT_OK;
8703 dchkh = mtod(chk->data, struct sctp_data_chunk *);
8706 if (((chk->send_size <= mtu) && (chk->send_size <= r_mtu)) ||
8707 ((chk->flags & CHUNK_FLAGS_FRAGMENT_OK) && (chk->send_size <= asoc->peers_rwnd))) {
8723 auth_keyid = chk->auth_keyid;
8731 auth_keyid = chk->auth_keyid;
8733 } else if (auth_keyid != chk->auth_keyid) {
8741 outchain = sctp_copy_mbufchain(chk->data, outchain, &endoutchain, 0,
8742 chk->send_size, chk->copy_by_ref);
8754 if (chk->flags & CHUNK_FLAGS_FRAGMENT_OK) {
8758 if (mtu > chk->send_size)
8759 mtu -= chk->send_size;
8763 if (r_mtu > chk->send_size)
8764 r_mtu -= chk->send_size;
8768 to_out += chk->send_size;
8777 chk->window_probe = 0;
8778 data_list[bundle_at++] = chk;
8782 if (chk->sent == SCTP_DATAGRAM_UNSENT) {
8783 if ((chk->rec.data.rcv_flags & SCTP_DATA_UNORDERED) == 0) {
8788 if (((chk->rec.data.rcv_flags & SCTP_DATA_LAST_FRAG) == SCTP_DATA_LAST_FRAG) &&
8789 ((chk->rec.data.rcv_flags & SCTP_DATA_FIRST_FRAG) == 0))
8959 struct sctp_tmit_chunk *chk;
8991 sctp_alloc_a_chunk(stcb, chk);
8992 if (chk == NULL) {
8997 chk->copy_by_ref = 0;
8998 chk->rec.chunk_id.id = SCTP_OPERATION_ERROR;
8999 chk->rec.chunk_id.can_take_data = 0;
9000 chk->flags = 0;
9001 chk->send_size = (uint16_t)chunk_length;
9002 chk->sent = SCTP_DATAGRAM_UNSENT;
9003 chk->snd_count = 0;
9004 chk->asoc = &stcb->asoc;
9005 chk->data = op_err;
9006 chk->whoTo = NULL;
9010 hdr->chunk_length = htons(chk->send_size);
9011 TAILQ_INSERT_TAIL(&chk->asoc->control_send_queue, chk, sctp_next);
9012 chk->asoc->ctrl_queue_cnt++;
9029 struct sctp_tmit_chunk *chk;
9081 sctp_alloc_a_chunk(stcb, chk);
9082 if (chk == NULL) {
9087 chk->copy_by_ref = 0;
9088 chk->rec.chunk_id.id = SCTP_COOKIE_ECHO;
9089 chk->rec.chunk_id.can_take_data = 0;
9090 chk->flags = CHUNK_FLAGS_FRAGMENT_OK;
9091 chk->send_size = SCTP_SIZE32(plen);
9092 chk->sent = SCTP_DATAGRAM_UNSENT;
9093 chk->snd_count = 0;
9094 chk->asoc = &stcb->asoc;
9095 chk->data = cookie;
9096 chk->whoTo = net;
9097 atomic_add_int(&chk->whoTo->ref_count, 1);
9098 TAILQ_INSERT_HEAD(&chk->asoc->control_send_queue, chk, sctp_next);
9099 chk->asoc->ctrl_queue_cnt++;
9115 struct sctp_tmit_chunk *chk;
9137 sctp_alloc_a_chunk(stcb, chk);
9138 if (chk == NULL) {
9143 chk->copy_by_ref = 0;
9144 chk->rec.chunk_id.id = SCTP_HEARTBEAT_ACK;
9145 chk->rec.chunk_id.can_take_data = 1;
9146 chk->flags = 0;
9147 chk->send_size = chk_length;
9148 chk->sent = SCTP_DATAGRAM_UNSENT;
9149 chk->snd_count = 0;
9150 chk->asoc = &stcb->asoc;
9151 chk->data = outchain;
9152 chk->whoTo = net;
9153 atomic_add_int(&chk->whoTo->ref_count, 1);
9154 TAILQ_INSERT_TAIL(&chk->asoc->control_send_queue, chk, sctp_next);
9155 chk->asoc->ctrl_queue_cnt++;
9164 struct sctp_tmit_chunk *chk;
9174 sctp_alloc_a_chunk(stcb, chk);
9175 if (chk == NULL) {
9180 chk->copy_by_ref = 0;
9181 chk->rec.chunk_id.id = SCTP_COOKIE_ACK;
9182 chk->rec.chunk_id.can_take_data = 1;
9183 chk->flags = 0;
9184 chk->send_size = sizeof(struct sctp_chunkhdr);
9185 chk->sent = SCTP_DATAGRAM_UNSENT;
9186 chk->snd_count = 0;
9187 chk->asoc = &stcb->asoc;
9188 chk->data = cookie_ack;
9189 if (chk->asoc->last_control_chunk_from != NULL) {
9190 chk->whoTo = chk->asoc->last_control_chunk_from;
9191 atomic_add_int(&chk->whoTo->ref_count, 1);
9193 chk->whoTo = NULL;
9198 hdr->chunk_length = htons(chk->send_size);
9199 SCTP_BUF_LEN(cookie_ack) = chk->send_size;
9200 TAILQ_INSERT_TAIL(&chk->asoc->control_send_queue, chk, sctp_next);
9201 chk->asoc->ctrl_queue_cnt++;
9212 struct sctp_tmit_chunk *chk;
9220 sctp_alloc_a_chunk(stcb, chk);
9221 if (chk == NULL) {
9226 chk->copy_by_ref = 0;
9227 chk->rec.chunk_id.id = SCTP_SHUTDOWN_ACK;
9228 chk->rec.chunk_id.can_take_data = 1;
9229 chk->flags = 0;
9230 chk->send_size = sizeof(struct sctp_chunkhdr);
9231 chk->sent = SCTP_DATAGRAM_UNSENT;
9232 chk->snd_count = 0;
9233 chk->asoc = &stcb->asoc;
9234 chk->data = m_shutdown_ack;
9235 chk->whoTo = net;
9236 if (chk->whoTo) {
9237 atomic_add_int(&chk->whoTo->ref_count, 1);
9242 ack_cp->ch.chunk_length = htons(chk->send_size);
9243 SCTP_BUF_LEN(m_shutdown_ack) = chk->send_size;
9244 TAILQ_INSERT_TAIL(&chk->asoc->control_send_queue, chk, sctp_next);
9245 chk->asoc->ctrl_queue_cnt++;
9255 struct sctp_tmit_chunk *chk;
9257 TAILQ_FOREACH(chk, &stcb->asoc.control_send_queue, sctp_next) {
9258 if (chk->rec.chunk_id.id == SCTP_SHUTDOWN) {
9260 if (chk->whoTo) {
9261 sctp_free_remote_addr(chk->whoTo);
9262 chk->whoTo = NULL;
9267 if (chk == NULL) {
9274 sctp_alloc_a_chunk(stcb, chk);
9275 if (chk == NULL) {
9280 chk->copy_by_ref = 0;
9281 chk->rec.chunk_id.id = SCTP_SHUTDOWN;
9282 chk->rec.chunk_id.can_take_data = 1;
9283 chk->flags = 0;
9284 chk->send_size = sizeof(struct sctp_shutdown_chunk);
9285 chk->sent = SCTP_DATAGRAM_UNSENT;
9286 chk->snd_count = 0;
9287 chk->asoc = &stcb->asoc;
9288 chk->data = m_shutdown;
9289 chk->whoTo = net;
9290 if (chk->whoTo) {
9291 atomic_add_int(&chk->whoTo->ref_count, 1);
9296 shutdown_cp->ch.chunk_length = htons(chk->send_size);
9298 SCTP_BUF_LEN(m_shutdown) = chk->send_size;
9299 TAILQ_INSERT_TAIL(&chk->asoc->control_send_queue, chk, sctp_next);
9300 chk->asoc->ctrl_queue_cnt++;
9302 TAILQ_REMOVE(&stcb->asoc.control_send_queue, chk, sctp_next);
9303 chk->whoTo = net;
9304 if (chk->whoTo) {
9305 atomic_add_int(&chk->whoTo->ref_count, 1);
9307 shutdown_cp = mtod(chk->data, struct sctp_shutdown_chunk *);
9309 TAILQ_INSERT_TAIL(&stcb->asoc.control_send_queue, chk, sctp_next);
9321 struct sctp_tmit_chunk *chk;
9339 sctp_alloc_a_chunk(stcb, chk);
9340 if (chk == NULL) {
9346 chk->copy_by_ref = 0;
9347 chk->rec.chunk_id.id = SCTP_ASCONF;
9348 chk->rec.chunk_id.can_take_data = 0;
9349 chk->flags = CHUNK_FLAGS_FRAGMENT_OK;
9350 chk->data = m_asconf;
9351 chk->send_size = len;
9352 chk->sent = SCTP_DATAGRAM_UNSENT;
9353 chk->snd_count = 0;
9354 chk->asoc = &stcb->asoc;
9355 chk->whoTo = net;
9356 if (chk->whoTo) {
9357 atomic_add_int(&chk->whoTo->ref_count, 1);
9359 TAILQ_INSERT_TAIL(&chk->asoc->asconf_send_queue, chk, sctp_next);
9360 chk->asoc->ctrl_queue_cnt++;
9371 struct sctp_tmit_chunk *chk;
9429 sctp_alloc_a_chunk(stcb, chk);
9430 if (chk == NULL) {
9436 chk->copy_by_ref = 0;
9437 chk->rec.chunk_id.id = SCTP_ASCONF_ACK;
9438 chk->rec.chunk_id.can_take_data = 1;
9439 chk->flags = CHUNK_FLAGS_FRAGMENT_OK;
9440 chk->whoTo = net;
9441 if (chk->whoTo) {
9442 atomic_add_int(&chk->whoTo->ref_count, 1);
9444 chk->data = m_ack;
9445 chk->send_size = ack->len;
9446 chk->sent = SCTP_DATAGRAM_UNSENT;
9447 chk->snd_count = 0;
9448 chk->asoc = &stcb->asoc;
9450 TAILQ_INSERT_TAIL(&chk->asoc->control_send_queue, chk, sctp_next);
9451 chk->asoc->ctrl_queue_cnt++;
9480 struct sctp_tmit_chunk *chk, *fwd;
9515 TAILQ_FOREACH(chk, &asoc->control_send_queue, sctp_next) {
9516 if ((chk->rec.chunk_id.id == SCTP_COOKIE_ECHO) ||
9517 (chk->rec.chunk_id.id == SCTP_STREAM_RESET) ||
9518 (chk->rec.chunk_id.id == SCTP_FORWARD_CUM_TSN)) {
9519 if (chk->sent != SCTP_DATAGRAM_RESEND) {
9522 if (chk->rec.chunk_id.id == SCTP_STREAM_RESET) {
9523 if (chk != asoc->str_reset) {
9532 if (chk->rec.chunk_id.id == SCTP_FORWARD_CUM_TSN) {
9540 (sctp_auth_is_required_chunk(chk->rec.chunk_id.id,
9545 chk->rec.chunk_id.id);
9548 m = sctp_copy_mbufchain(chk->data, m, &endofchain, 0, chk->send_size, chk->copy_by_ref);
9557 if (chk->rec.chunk_id.id == SCTP_COOKIE_ECHO) {
9558 sctp_timer_start(SCTP_TIMER_TYPE_COOKIE, inp, stcb, chk->whoTo);
9559 } else if (chk->rec.chunk_id.id == SCTP_ASCONF)
9560 sctp_timer_start(SCTP_TIMER_TYPE_ASCONF, inp, stcb, chk->whoTo);
9561 chk->snd_count++; /* update our count */
9562 if ((error = sctp_lowlevel_chunk_output(inp, stcb, chk->whoTo,
9563 (struct sockaddr *)&chk->whoTo->ro._l_addr, m,
9567 chk->whoTo->port, NULL,
9586 /* (void)SCTP_GETTIME_TIMEVAL(&chk->whoTo->last_sent_time); */
9588 chk->sent = SCTP_DATAGRAM_SENT;
9614 TAILQ_FOREACH(chk, &asoc->sent_queue, sctp_next) {
9615 if (chk->sent != SCTP_DATAGRAM_RESEND) {
9619 if (chk->data == NULL) {
9620 SCTP_PRINTF("TSN:%x chk->snd_count:%d chk->sent:%d can't retran - no data\n",
9621 chk->rec.data.tsn, chk->snd_count, chk->sent);
9625 (chk->snd_count >= SCTP_BASE_SYSCTL(sctp_max_retran_chunk))) {
9630 chk->rec.data.tsn, chk->snd_count);
9641 net = chk->whoTo;
9664 if (tsn == chk->rec.data.tsn) {
9680 chk->window_probe = 1;
9681 chk->whoTo->window_probe = 1;
9690 if (chk->rec.data.doing_fast_retransmit == 0) {
9718 if ((chk->send_size <= (mtu - dmtu)) ||
9719 (chk->flags & CHUNK_FLAGS_FRAGMENT_OK)) {
9729 auth_keyid = chk->auth_keyid;
9733 auth_keyid = chk->auth_keyid;
9735 } else if (chk->auth_keyid != auth_keyid) {
9740 m = sctp_copy_mbufchain(chk->data, m, &endofchain, 0, chk->send_size, chk->copy_by_ref);
9746 if (chk->flags & CHUNK_FLAGS_FRAGMENT_OK) {
9750 if (mtu > (chk->send_size + dmtu))
9751 mtu -= (chk->send_size + dmtu);
9754 data_list[bundle_at++] = chk;
9761 * now are there anymore forward from chk to pick
9764 for (fwd = TAILQ_NEXT(chk, sctp_next); fwd != NULL; fwd = TAILQ_NEXT(fwd, sctp_next)) {
10324 struct sctp_tmit_chunk *chk, *at, *tp1, *last;
10334 TAILQ_FOREACH(chk, &asoc->control_send_queue, sctp_next) {
10335 if (chk->rec.chunk_id.id == SCTP_FORWARD_CUM_TSN) {
10337 chk->sent = SCTP_DATAGRAM_UNSENT;
10338 chk->snd_count = 0;
10340 if (chk->whoTo) {
10341 sctp_free_remote_addr(chk->whoTo);
10342 chk->whoTo = NULL;
10348 sctp_alloc_a_chunk(stcb, chk);
10349 if (chk == NULL) {
10353 chk->copy_by_ref = 0;
10359 chk->rec.chunk_id.id = SCTP_FORWARD_CUM_TSN;
10360 chk->rec.chunk_id.can_take_data = 0;
10361 chk->flags = 0;
10362 chk->asoc = asoc;
10363 chk->whoTo = NULL;
10364 chk->data = sctp_get_mbuf_for_msg(MCLBYTES, 0, M_NOWAIT, 1, MT_DATA);
10365 if (chk->data == NULL) {
10366 sctp_free_a_chunk(stcb, chk, SCTP_SO_NOT_LOCKED);
10369 SCTP_BUF_RESV_UF(chk->data, SCTP_MIN_OVERHEAD);
10370 chk->sent = SCTP_DATAGRAM_UNSENT;
10371 chk->snd_count = 0;
10372 TAILQ_INSERT_TAIL(&asoc->control_send_queue, chk, sctp_next);
10379 SCTP_BUF_LEN(chk->data) = 0;
10399 cnt_of_space = (unsigned int)M_TRAILINGSPACE(chk->data);
10467 chk->send_size = space_needed;
10469 fwdtsn = mtod(chk->data, struct sctp_forward_tsn_chunk *);
10470 fwdtsn->ch.chunk_length = htons(chk->send_size);
10478 SCTP_BUF_LEN(chk->data) = chk->send_size;
10548 struct sctp_tmit_chunk *chk, *a_chk;
10581 TAILQ_FOREACH(chk, &asoc->control_send_queue, sctp_next) {
10582 if (chk->rec.chunk_id.id == type) {
10584 TAILQ_REMOVE(&asoc->control_send_queue, chk, sctp_next);
10586 a_chk = chk;
11357 struct sctp_tmit_chunk *chk;
11378 sctp_alloc_a_chunk(stcb, chk);
11379 if (chk == NULL) {
11384 chk->copy_by_ref = 0;
11385 chk->rec.chunk_id.id = SCTP_HEARTBEAT_REQUEST;
11386 chk->rec.chunk_id.can_take_data = 1;
11387 chk->flags = 0;
11388 chk->asoc = &stcb->asoc;
11389 chk->send_size = sizeof(struct sctp_heartbeat_chunk);
11391 chk->data = sctp_get_mbuf_for_msg(chk->send_size, 0, M_NOWAIT, 1, MT_HEADER);
11392 if (chk->data == NULL) {
11393 sctp_free_a_chunk(stcb, chk, so_locked);
11396 SCTP_BUF_RESV_UF(chk->data, SCTP_MIN_OVERHEAD);
11397 SCTP_BUF_LEN(chk->data) = chk->send_size;
11398 chk->sent = SCTP_DATAGRAM_UNSENT;
11399 chk->snd_count = 0;
11400 chk->whoTo = net;
11401 atomic_add_int(&chk->whoTo->ref_count, 1);
11403 hb = mtod(chk->data, struct sctp_heartbeat_chunk *);
11408 hb->ch.chunk_length = htons(chk->send_size);
11444 if (chk->data) {
11445 sctp_m_freem(chk->data);
11446 chk->data = NULL;
11448 sctp_free_a_chunk(stcb, chk, so_locked);
11453 TAILQ_INSERT_TAIL(&stcb->asoc.control_send_queue, chk, sctp_next);
11465 struct sctp_tmit_chunk *chk;
11472 TAILQ_FOREACH(chk, &asoc->control_send_queue, sctp_next) {
11473 if ((chk->rec.chunk_id.id == SCTP_ECN_ECHO) && (net == chk->whoTo)) {
11477 ecne = mtod(chk->data, struct sctp_ecne_chunk *);
11490 sctp_alloc_a_chunk(stcb, chk);
11491 if (chk == NULL) {
11495 chk->copy_by_ref = 0;
11496 chk->rec.chunk_id.id = SCTP_ECN_ECHO;
11497 chk->rec.chunk_id.can_take_data = 0;
11498 chk->flags = 0;
11499 chk->asoc = &stcb->asoc;
11500 chk->send_size = sizeof(struct sctp_ecne_chunk);
11501 chk->data = sctp_get_mbuf_for_msg(chk->send_size, 0, M_NOWAIT, 1, MT_HEADER);
11502 if (chk->data == NULL) {
11503 sctp_free_a_chunk(stcb, chk, SCTP_SO_NOT_LOCKED);
11506 SCTP_BUF_RESV_UF(chk->data, SCTP_MIN_OVERHEAD);
11507 SCTP_BUF_LEN(chk->data) = chk->send_size;
11508 chk->sent = SCTP_DATAGRAM_UNSENT;
11509 chk->snd_count = 0;
11510 chk->whoTo = net;
11511 atomic_add_int(&chk->whoTo->ref_count, 1);
11514 ecne = mtod(chk->data, struct sctp_ecne_chunk *);
11520 TAILQ_INSERT_HEAD(&stcb->asoc.control_send_queue, chk, sctp_next);
11530 struct sctp_tmit_chunk *chk;
11553 sctp_alloc_a_chunk(stcb, chk);
11554 if (chk == NULL) {
11557 chk->copy_by_ref = 0;
11558 chk->rec.chunk_id.id = SCTP_PACKET_DROPPED;
11559 chk->rec.chunk_id.can_take_data = 1;
11560 chk->flags = 0;
11562 chk->send_size = len;
11583 sctp_free_a_chunk(stcb, chk, SCTP_SO_NOT_LOCKED);
11602 chk->asoc = &stcb->asoc;
11603 chk->data = sctp_get_mbuf_for_msg(MCLBYTES, 0, M_NOWAIT, 1, MT_DATA);
11604 if (chk->data == NULL) {
11606 sctp_free_a_chunk(stcb, chk, SCTP_SO_NOT_LOCKED);
11609 SCTP_BUF_RESV_UF(chk->data, SCTP_MIN_OVERHEAD);
11610 drp = mtod(chk->data, struct sctp_pktdrop_chunk *);
11612 sctp_m_freem(chk->data);
11613 chk->data = NULL;
11616 chk->book_size = SCTP_SIZE32((chk->send_size + sizeof(struct sctp_pktdrop_chunk) +
11618 chk->book_size_scale = 0;
11626 chk->send_size = (uint16_t)(len - sizeof(struct sctp_pktdrop_chunk));
11627 len = chk->send_size;
11636 chk->send_size += sizeof(struct sctp_pktdrop_chunk);
11637 SCTP_BUF_LEN(chk->data) = chk->send_size;
11638 chk->sent = SCTP_DATAGRAM_UNSENT;
11639 chk->snd_count = 0;
11642 chk->whoTo = net;
11643 atomic_add_int(&chk->whoTo->ref_count, 1);
11645 chk->whoTo = NULL;
11648 drp->ch.chunk_length = htons(chk->send_size);
11669 TAILQ_INSERT_TAIL(&stcb->asoc.control_send_queue, chk, sctp_next);
11678 struct sctp_tmit_chunk *chk;
11685 TAILQ_FOREACH(chk, &asoc->control_send_queue, sctp_next) {
11686 if ((chk->rec.chunk_id.id == SCTP_ECN_CWR) && (net == chk->whoTo)) {
11693 cwr = mtod(chk->data, struct sctp_cwr_chunk *);
11705 sctp_alloc_a_chunk(stcb, chk);
11706 if (chk == NULL) {
11709 chk->copy_by_ref = 0;
11710 chk->rec.chunk_id.id = SCTP_ECN_CWR;
11711 chk->rec.chunk_id.can_take_data = 1;
11712 chk->flags = 0;
11713 chk->asoc = &stcb->asoc;
11714 chk->send_size = sizeof(struct sctp_cwr_chunk);
11715 chk->data = sctp_get_mbuf_for_msg(chk->send_size, 0, M_NOWAIT, 1, MT_HEADER);
11716 if (chk->data == NULL) {
11717 sctp_free_a_chunk(stcb, chk, SCTP_SO_NOT_LOCKED);
11720 SCTP_BUF_RESV_UF(chk->data, SCTP_MIN_OVERHEAD);
11721 SCTP_BUF_LEN(chk->data) = chk->send_size;
11722 chk->sent = SCTP_DATAGRAM_UNSENT;
11723 chk->snd_count = 0;
11724 chk->whoTo = net;
11725 atomic_add_int(&chk->whoTo->ref_count, 1);
11726 cwr = mtod(chk->data, struct sctp_cwr_chunk *);
11731 TAILQ_INSERT_TAIL(&stcb->asoc.control_send_queue, chk, sctp_next);
11736 sctp_add_stream_reset_out(struct sctp_tcb *stcb, struct sctp_tmit_chunk *chk,
11745 ch = mtod(chk->data, struct sctp_chunkhdr *);
11801 chk->book_size = len + old_len;
11802 chk->book_size_scale = 0;
11803 chk->send_size = SCTP_SIZE32(chk->book_size);
11804 SCTP_BUF_LEN(chk->data) = chk->send_size;
11809 sctp_add_stream_reset_in(struct sctp_tmit_chunk *chk,
11817 ch = mtod(chk->data, struct sctp_chunkhdr *);
11842 chk->book_size = len + old_len;
11843 chk->book_size_scale = 0;
11844 chk->send_size = SCTP_SIZE32(chk->book_size);
11845 SCTP_BUF_LEN(chk->data) = chk->send_size;
11850 sctp_add_stream_reset_tsn(struct sctp_tmit_chunk *chk,
11857 ch = mtod(chk->data, struct sctp_chunkhdr *);
11870 chk->send_size = len + old_len;
11871 chk->book_size = SCTP_SIZE32(chk->send_size);
11872 chk->book_size_scale = 0;
11873 SCTP_BUF_LEN(chk->data) = SCTP_SIZE32(chk->send_size);
11878 sctp_add_stream_reset_result(struct sctp_tmit_chunk *chk,
11885 ch = mtod(chk->data, struct sctp_chunkhdr *);
11899 chk->book_size = len + old_len;
11900 chk->book_size_scale = 0;
11901 chk->send_size = SCTP_SIZE32(chk->book_size);
11902 SCTP_BUF_LEN(chk->data) = chk->send_size;
11912 struct sctp_tmit_chunk *chk;
11926 sctp_alloc_a_chunk(stcb, chk);
11927 if (chk == NULL) {
11931 chk->copy_by_ref = 0;
11932 chk->rec.chunk_id.id = SCTP_STREAM_RESET;
11933 chk->rec.chunk_id.can_take_data = 0;
11934 chk->flags = 0;
11935 chk->asoc = &stcb->asoc;
11936 chk->book_size = sizeof(struct sctp_chunkhdr);
11937 chk->send_size = SCTP_SIZE32(chk->book_size);
11938 chk->book_size_scale = 0;
11939 chk->data = sctp_get_mbuf_for_msg(MCLBYTES, 0, M_NOWAIT, 1, MT_DATA);
11940 if (chk->data == NULL) {
11941 sctp_free_a_chunk(stcb, chk, SCTP_SO_LOCKED);
11945 SCTP_BUF_RESV_UF(chk->data, SCTP_MIN_OVERHEAD);
11947 chk->sent = SCTP_DATAGRAM_UNSENT;
11948 chk->snd_count = 0;
11950 chk->whoTo = stcb->asoc.alternate;
11952 chk->whoTo = stcb->asoc.primary_destination;
11954 ch = mtod(chk->data, struct sctp_chunkhdr *);
11957 ch->chunk_length = htons(chk->book_size);
11958 atomic_add_int(&chk->whoTo->ref_count, 1);
11959 SCTP_BUF_LEN(chk->data) = chk->send_size;
11960 sctp_add_stream_reset_result(chk, ent->seq, response);
11963 chk,
11969 sctp_add_stream_reset_result_tsn(struct sctp_tmit_chunk *chk,
11977 ch = mtod(chk->data, struct sctp_chunkhdr *);
11993 chk->book_size = len + old_len;
11994 chk->send_size = SCTP_SIZE32(chk->book_size);
11995 chk->book_size_scale = 0;
11996 SCTP_BUF_LEN(chk->data) = chk->send_size;
12001 sctp_add_an_out_stream(struct sctp_tmit_chunk *chk,
12009 ch = mtod(chk->data, struct sctp_chunkhdr *);
12026 chk->send_size = len + old_len;
12027 chk->book_size = SCTP_SIZE32(chk->send_size);
12028 chk->book_size_scale = 0;
12029 SCTP_BUF_LEN(chk->data) = SCTP_SIZE32(chk->send_size);
12034 sctp_add_an_in_stream(struct sctp_tmit_chunk *chk,
12042 ch = mtod(chk->data, struct sctp_chunkhdr *);
12058 chk->send_size = len + old_len;
12059 chk->book_size = SCTP_SIZE32(chk->send_size);
12060 chk->book_size_scale = 0;
12061 SCTP_BUF_LEN(chk->data) = SCTP_SIZE32(chk->send_size);
12069 struct sctp_tmit_chunk *chk;
12078 sctp_alloc_a_chunk(stcb, chk);
12079 if (chk == NULL) {
12083 chk->copy_by_ref = 0;
12084 chk->rec.chunk_id.id = SCTP_STREAM_RESET;
12085 chk->rec.chunk_id.can_take_data = 0;
12086 chk->flags = 0;
12087 chk->asoc = &stcb->asoc;
12088 chk->book_size = sizeof(struct sctp_chunkhdr);
12089 chk->send_size = SCTP_SIZE32(chk->book_size);
12090 chk->book_size_scale = 0;
12091 chk->data = sctp_get_mbuf_for_msg(MCLBYTES, 0, M_NOWAIT, 1, MT_DATA);
12092 if (chk->data == NULL) {
12093 sctp_free_a_chunk(stcb, chk, so_locked);
12097 SCTP_BUF_RESV_UF(chk->data, SCTP_MIN_OVERHEAD);
12100 chk->sent = SCTP_DATAGRAM_UNSENT;
12101 chk->snd_count = 0;
12103 chk->whoTo = stcb->asoc.alternate;
12105 chk->whoTo = stcb->asoc.primary_destination;
12107 ch = mtod(chk->data, struct sctp_chunkhdr *);
12110 ch->chunk_length = htons(chk->book_size);
12111 atomic_add_int(&chk->whoTo->ref_count, 1);
12112 SCTP_BUF_LEN(chk->data) = chk->send_size;
12114 if (sctp_add_stream_reset_out(stcb, chk, seq, (stcb->asoc.str_reset_seq_in - 1), (stcb->asoc.sending_seq - 1))) {
12118 m_freem(chk->data);
12119 chk->data = NULL;
12120 sctp_free_a_chunk(stcb, chk, so_locked);
12123 asoc->str_reset = chk;
12126 chk,
12133 sctp_timer_start(SCTP_TIMER_TYPE_STRRESET, stcb->sctp_ep, stcb, chk->whoTo);
12147 struct sctp_tmit_chunk *chk;
12181 sctp_alloc_a_chunk(stcb, chk);
12182 if (chk == NULL) {
12186 chk->copy_by_ref = 0;
12187 chk->rec.chunk_id.id = SCTP_STREAM_RESET;
12188 chk->rec.chunk_id.can_take_data = 0;
12189 chk->flags = 0;
12190 chk->asoc = &stcb->asoc;
12191 chk->book_size = sizeof(struct sctp_chunkhdr);
12192 chk->send_size = SCTP_SIZE32(chk->book_size);
12193 chk->book_size_scale = 0;
12194 chk->data = sctp_get_mbuf_for_msg(MCLBYTES, 0, M_NOWAIT, 1, MT_DATA);
12195 if (chk->data == NULL) {
12196 sctp_free_a_chunk(stcb, chk, SCTP_SO_LOCKED);
12200 SCTP_BUF_RESV_UF(chk->data, SCTP_MIN_OVERHEAD);
12203 chk->sent = SCTP_DATAGRAM_UNSENT;
12204 chk->snd_count = 0;
12206 chk->whoTo = stcb->asoc.alternate;
12208 chk->whoTo = stcb->asoc.primary_destination;
12210 atomic_add_int(&chk->whoTo->ref_count, 1);
12211 ch = mtod(chk->data, struct sctp_chunkhdr *);
12214 ch->chunk_length = htons(chk->book_size);
12215 SCTP_BUF_LEN(chk->data) = chk->send_size;
12221 ret = sctp_add_stream_reset_out(stcb, chk, seq, (stcb->asoc.str_reset_seq_in - 1), (stcb->asoc.sending_seq - 1));
12307 sctp_add_an_out_stream(chk, seq, adding_o);
12312 sctp_add_an_in_stream(chk, seq, adding_i);
12317 sctp_add_stream_reset_in(chk, number_entries, list, seq);
12322 sctp_add_stream_reset_tsn(chk, seq);
12325 asoc->str_reset = chk;
12328 chk,
12334 sctp_timer_start(SCTP_TIMER_TYPE_STRRESET, stcb->sctp_ep, stcb, chk->whoTo);