Lines Matching defs:chk

6099 	struct sctp_tmit_chunk *chk, *nchk;
6104 TAILQ_FOREACH(chk, &asoc->sent_queue, sctp_next) {
6111 if (PR_SCTP_BUF_ENABLED(chk->flags)) {
6116 if (chk->rec.data.timetodrop.tv_sec >= (long)srcv->sinfo_timetolive) {
6124 if (chk->data) {
6132 if (chk->sent > SCTP_DATAGRAM_UNSENT)
6136 ret_spc = sctp_release_pr_sctp_chunk(stcb, chk,
6148 TAILQ_FOREACH_SAFE(chk, &asoc->send_queue, sctp_next, nchk) {
6150 if (PR_SCTP_BUF_ENABLED(chk->flags)) {
6151 if (chk->rec.data.timetodrop.tv_sec >= (long)srcv->sinfo_timetolive) {
6152 if (chk->data) {
6159 ret_spc = sctp_release_pr_sctp_chunk(stcb, chk,
6166 } /* end if chk->data */
6168 } /* end if chk pr-sctp */
6169 } /* tailqforeachsafe (chk) */
6849 struct sctp_tmit_chunk *chk, *nchk;
6851 TAILQ_FOREACH_SAFE(chk, &asoc->control_send_queue, sctp_next, nchk) {
6852 if (chk->rec.chunk_id.id == SCTP_COOKIE_ECHO) {
6853 TAILQ_REMOVE(&asoc->control_send_queue, chk, sctp_next);
6854 if (chk->data) {
6855 sctp_m_freem(chk->data);
6856 chk->data = NULL;
6859 sctp_free_a_chunk(stcb, chk, SCTP_SO_NOT_LOCKED);
6868 struct sctp_tmit_chunk *chk, *nchk;
6872 TAILQ_FOREACH_SAFE(chk, &asoc->asconf_send_queue, sctp_next, nchk) {
6874 if (chk->rec.chunk_id.id == SCTP_ASCONF) {
6875 if (chk->data) {
6876 acp = mtod(chk->data, struct sctp_asconf_chunk *);
6882 TAILQ_REMOVE(&asoc->asconf_send_queue, chk, sctp_next);
6883 if (chk->data) {
6884 sctp_m_freem(chk->data);
6885 chk->data = NULL;
6888 sctp_free_a_chunk(stcb, chk, SCTP_SO_NOT_LOCKED);
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_SELECTIVE_ACK) ||
6997 (chk->rec.chunk_id.id == SCTP_NR_SELECTIVE_ACK) || /* EY */
6998 (chk->rec.chunk_id.id == SCTP_HEARTBEAT_REQUEST) ||
6999 (chk->rec.chunk_id.id == SCTP_HEARTBEAT_ACK) ||
7000 (chk->rec.chunk_id.id == SCTP_FORWARD_CUM_TSN) ||
7001 (chk->rec.chunk_id.id == SCTP_SHUTDOWN) ||
7002 (chk->rec.chunk_id.id == SCTP_SHUTDOWN_ACK) ||
7003 (chk->rec.chunk_id.id == SCTP_OPERATION_ERROR) ||
7004 (chk->rec.chunk_id.id == SCTP_PACKET_DROPPED) ||
7005 (chk->rec.chunk_id.id == SCTP_COOKIE_ACK) ||
7006 (chk->rec.chunk_id.id == SCTP_ECN_CWR) ||
7007 (chk->rec.chunk_id.id == SCTP_ASCONF_ACK)) {
7010 TAILQ_REMOVE(&asoc->control_send_queue, chk, sctp_next);
7011 if (chk->data) {
7012 sctp_m_freem(chk->data);
7013 chk->data = NULL;
7016 if (chk->rec.chunk_id.id == SCTP_FORWARD_CUM_TSN)
7018 sctp_free_a_chunk(stcb, chk, so_locked);
7019 } else if (chk->rec.chunk_id.id == SCTP_STREAM_RESET) {
7021 if (chk != asoc->str_reset) {
7108 struct sctp_tmit_chunk *chk;
7296 sctp_alloc_a_chunk(stcb, chk);
7297 if (chk == NULL) {
7315 memset(chk, 0, sizeof(*chk));
7316 chk->rec.data.rcv_flags = rcv_flags;
7328 chk->data = sp->data;
7329 chk->last_mbuf = sp->tail_mbuf;
7336 chk->data = SCTP_M_COPYM(sp->data, 0, to_move, M_NOWAIT);
7337 chk->last_mbuf = NULL;
7338 if (chk->data == NULL) {
7340 sctp_free_a_chunk(stcb, chk, so_locked);
7347 sctp_log_mbc(chk->data, SCTP_MBUF_ICOPY);
7376 if (SCTP_BUF_IS_EXTENDED(chk->data)) {
7377 chk->copy_by_ref = 1;
7379 chk->copy_by_ref = 0;
7385 if (chk->last_mbuf == NULL) {
7386 chk->last_mbuf = chk->data;
7387 while (SCTP_BUF_NEXT(chk->last_mbuf) != NULL) {
7388 chk->last_mbuf = SCTP_BUF_NEXT(chk->last_mbuf);
7405 if (M_LEADINGSPACE(chk->data) < (int)sizeof(struct sctp_data_chunk)) {
7422 sp->data = chk->data;
7423 sp->tail_mbuf = chk->last_mbuf;
7429 sp->data = chk->data;
7430 SCTP_BUF_NEXT(chk->last_mbuf) = m_tmp;
7434 chk->data = NULL;
7436 sctp_free_a_chunk(stcb, chk, so_locked);
7441 SCTP_BUF_NEXT(m) = chk->data;
7442 chk->data = m;
7443 M_ALIGN(chk->data, 4);
7446 SCTP_BUF_PREPEND(chk->data, sizeof(struct sctp_data_chunk), M_NOWAIT);
7447 if (chk->data == NULL) {
7453 sctp_free_a_chunk(stcb, chk, so_locked);
7460 chk->book_size = chk->send_size = (to_move + sizeof(struct sctp_data_chunk));
7461 chk->book_size_scale = 0;
7462 chk->sent = SCTP_DATAGRAM_UNSENT;
7464 chk->flags = 0;
7465 chk->asoc = &stcb->asoc;
7466 chk->pad_inplace = 0;
7467 chk->no_fr_allowed = 0;
7468 chk->rec.data.stream_seq = strq->next_sequence_send;
7473 chk->rec.data.stream_number = sp->stream;
7474 chk->rec.data.payloadtype = sp->ppid;
7475 chk->rec.data.context = sp->context;
7476 chk->rec.data.doing_fast_retransmit = 0;
7478 chk->rec.data.timetodrop = sp->ts;
7479 chk->flags = sp->act_flags;
7482 chk->whoTo = sp->net;
7483 atomic_add_int(&chk->whoTo->ref_count, 1);
7485 chk->whoTo = NULL;
7488 chk->auth_keyid = sp->auth_keyid;
7489 sctp_auth_key_acquire(stcb, chk->auth_keyid);
7490 chk->holds_key_ref = 1;
7492 chk->rec.data.TSN_seq = atomic_fetchadd_int(&asoc->sending_seq, 1);
7496 (uint32_t) ((chk->rec.data.stream_number << 16) | chk->rec.data.stream_seq),
7497 chk->rec.data.TSN_seq);
7499 dchkh = mtod(chk->data, struct sctp_data_chunk *);
7511 asoc->out_tsnlog[asoc->tsn_out_at].tsn = chk->rec.data.TSN_seq;
7512 asoc->out_tsnlog[asoc->tsn_out_at].strm = chk->rec.data.stream_number;
7513 asoc->out_tsnlog[asoc->tsn_out_at].seq = chk->rec.data.stream_seq;
7514 asoc->out_tsnlog[asoc->tsn_out_at].sz = chk->send_size;
7515 asoc->out_tsnlog[asoc->tsn_out_at].flgs = chk->rec.data.rcv_flags;
7523 dchkh->ch.chunk_flags = chk->rec.data.rcv_flags;
7524 dchkh->dp.tsn = htonl(chk->rec.data.TSN_seq);
7526 dchkh->dp.stream_sequence = htons(chk->rec.data.stream_seq);
7527 dchkh->dp.protocol_id = chk->rec.data.payloadtype;
7528 dchkh->ch.chunk_length = htons(chk->send_size);
7529 /* Now advance the chk->send_size by the actual pad needed. */
7530 if (chk->send_size < SCTP_SIZE32(chk->book_size)) {
7535 pads = SCTP_SIZE32(chk->book_size) - chk->send_size;
7536 lm = sctp_pad_lastmbuf(chk->data, pads, chk->last_mbuf);
7538 chk->last_mbuf = lm;
7539 chk->pad_inplace = 1;
7541 chk->send_size += pads;
7543 if (PR_SCTP_ENABLED(chk->flags)) {
7583 TAILQ_INSERT_TAIL(&asoc->send_queue, chk, sctp_next);
7684 struct sctp_tmit_chunk *chk;
7686 TAILQ_FOREACH(chk, &asoc->control_send_queue, sctp_next) {
7687 if (chk->rec.chunk_id.id == SCTP_ECN_ECHO) {
7688 chk->sent = SCTP_DATAGRAM_UNSENT;
7697 struct sctp_tmit_chunk *chk;
7713 TAILQ_FOREACH(chk, &asoc->send_queue, sctp_next) {
7714 if (chk->whoTo == net) {
7715 sctp_free_remote_addr(chk->whoTo);
7716 chk->whoTo = NULL;
7745 struct sctp_tmit_chunk *chk, *nchk;
7820 TAILQ_FOREACH(chk, &asoc->control_send_queue, sctp_next) {
7821 if ((chk->rec.chunk_id.id == SCTP_SELECTIVE_ACK) ||
7822 (chk->rec.chunk_id.id == SCTP_NR_SELECTIVE_ACK)) {
7823 sack_goes_to = chk->whoTo;
7835 TAILQ_FOREACH(chk, &asoc->send_queue, sctp_next) {
7836 if (chk->whoTo == NULL) {
7920 TAILQ_FOREACH(chk, &asoc->control_send_queue, sctp_next) {
7921 if (chk->whoTo == NULL) {
7923 chk->whoTo = asoc->alternate;
7925 chk->whoTo = asoc->primary_destination;
7927 atomic_add_int(&chk->whoTo->ref_count, 1);
8009 TAILQ_FOREACH_SAFE(chk, &asoc->asconf_send_queue, sctp_next, nchk) {
8010 if (chk->rec.chunk_id.id != SCTP_ASCONF) {
8013 if (chk->whoTo == NULL) {
8024 if (chk->whoTo != net) {
8028 if (chk->data == NULL) {
8031 if (chk->sent != SCTP_DATAGRAM_UNSENT &&
8032 chk->sent != SCTP_DATAGRAM_RESEND) {
8044 sctp_auth_is_required_chunk(chk->rec.chunk_id.id,
8050 if ((chk->send_size < (int)(mtu - omtu)) ||
8051 (chk->flags & CHUNK_FLAGS_FRAGMENT_OK)) {
8054 * from the chk->data for control but the
8067 (sctp_auth_is_required_chunk(chk->rec.chunk_id.id,
8074 chk->rec.chunk_id.id);
8077 outchain = sctp_copy_mbufchain(chk->data, outchain, &endoutchain,
8078 (int)chk->rec.chunk_id.can_take_data,
8079 chk->send_size, chk->copy_by_ref);
8087 if (mtu > (chk->send_size + omtu))
8088 mtu -= (chk->send_size + omtu);
8091 to_out += (chk->send_size + omtu);
8093 if (chk->flags & CHUNK_FLAGS_FRAGMENT_OK) {
8096 if (chk->rec.chunk_id.can_take_data)
8097 chk->data = NULL;
8109 chk->sent = SCTP_DATAGRAM_SENT;
8110 if (chk->whoTo == NULL) {
8111 chk->whoTo = net;
8114 chk->snd_count++;
8210 TAILQ_FOREACH_SAFE(chk, &asoc->control_send_queue, sctp_next, nchk) {
8212 (chk->rec.chunk_id.id == SCTP_ECN_ECHO) &&
8213 (chk->whoTo != sack_goes_to)) {
8219 if (chk->whoTo == net) {
8233 if (chk->whoTo == NULL) {
8244 if (chk->whoTo != net) {
8249 if (chk->data == NULL) {
8252 if (chk->sent != SCTP_DATAGRAM_UNSENT) {
8269 sctp_auth_is_required_chunk(chk->rec.chunk_id.id,
8275 if ((chk->send_size <= (int)(mtu - omtu)) ||
8276 (chk->flags & CHUNK_FLAGS_FRAGMENT_OK)) {
8279 * from the chk->data for control but the
8292 (sctp_auth_is_required_chunk(chk->rec.chunk_id.id,
8299 chk->rec.chunk_id.id);
8302 outchain = sctp_copy_mbufchain(chk->data, outchain, &endoutchain,
8303 (int)chk->rec.chunk_id.can_take_data,
8304 chk->send_size, chk->copy_by_ref);
8312 if (mtu > (chk->send_size + omtu))
8313 mtu -= (chk->send_size + omtu);
8316 to_out += (chk->send_size + omtu);
8318 if (chk->flags & CHUNK_FLAGS_FRAGMENT_OK) {
8321 if (chk->rec.chunk_id.can_take_data)
8322 chk->data = NULL;
8324 if ((chk->rec.chunk_id.id == SCTP_SELECTIVE_ACK) ||
8325 (chk->rec.chunk_id.id == SCTP_NR_SELECTIVE_ACK) || /* EY */
8326 (chk->rec.chunk_id.id == SCTP_HEARTBEAT_REQUEST) ||
8327 (chk->rec.chunk_id.id == SCTP_HEARTBEAT_ACK) ||
8328 (chk->rec.chunk_id.id == SCTP_SHUTDOWN) ||
8329 (chk->rec.chunk_id.id == SCTP_SHUTDOWN_ACK) ||
8330 (chk->rec.chunk_id.id == SCTP_OPERATION_ERROR) ||
8331 (chk->rec.chunk_id.id == SCTP_COOKIE_ACK) ||
8332 (chk->rec.chunk_id.id == SCTP_ECN_CWR) ||
8333 (chk->rec.chunk_id.id == SCTP_PACKET_DROPPED) ||
8334 (chk->rec.chunk_id.id == SCTP_ASCONF_ACK)) {
8335 if (chk->rec.chunk_id.id == SCTP_HEARTBEAT_REQUEST) {
8339 if ((chk->rec.chunk_id.id == SCTP_SELECTIVE_ACK) ||
8340 (chk->rec.chunk_id.id == SCTP_NR_SELECTIVE_ACK)) {
8357 if (chk->rec.chunk_id.id == SCTP_COOKIE_ECHO) {
8360 } else if (chk->rec.chunk_id.id == SCTP_ECN_ECHO) {
8375 chk->sent = SCTP_DATAGRAM_SENT;
8376 if (chk->whoTo == NULL) {
8377 chk->whoTo = net;
8380 chk->snd_count++;
8550 TAILQ_FOREACH_SAFE(chk, &asoc->send_queue, sctp_next, nchk) {
8561 if ((chk->whoTo != NULL) &&
8562 (chk->whoTo != net)) {
8569 (chk->whoTo == NULL)) {
8573 (chk->whoTo == NULL)) {
8577 if ((chk->send_size > omtu) && ((chk->flags & CHUNK_FLAGS_FRAGMENT_OK) == 0)) {
8591 chk->send_size, mtu);
8592 chk->flags |= CHUNK_FLAGS_FRAGMENT_OK;
8598 dchkh = mtod(chk->data, struct sctp_data_chunk *);
8601 if (((chk->send_size <= mtu) && (chk->send_size <= r_mtu)) ||
8602 ((chk->flags & CHUNK_FLAGS_FRAGMENT_OK) && (chk->send_size <= asoc->peers_rwnd))) {
8618 auth_keyid = chk->auth_keyid;
8626 auth_keyid = chk->auth_keyid;
8628 } else if (auth_keyid != chk->auth_keyid) {
8636 outchain = sctp_copy_mbufchain(chk->data, outchain, &endoutchain, 0,
8637 chk->send_size, chk->copy_by_ref);
8649 if (chk->flags & CHUNK_FLAGS_FRAGMENT_OK) {
8653 if (mtu > chk->send_size)
8654 mtu -= chk->send_size;
8658 if (r_mtu > chk->send_size)
8659 r_mtu -= chk->send_size;
8663 to_out += chk->send_size;
8672 chk->window_probe = 0;
8673 data_list[bundle_at++] = chk;
8677 if (chk->sent == SCTP_DATAGRAM_UNSENT) {
8678 if ((chk->rec.data.rcv_flags & SCTP_DATA_UNORDERED) == 0) {
8683 if (((chk->rec.data.rcv_flags & SCTP_DATA_LAST_FRAG) == SCTP_DATA_LAST_FRAG) &&
8684 ((chk->rec.data.rcv_flags & SCTP_DATA_FIRST_FRAG) == 0))
8853 struct sctp_tmit_chunk *chk;
8857 sctp_alloc_a_chunk(stcb, chk);
8858 if (chk == NULL) {
8863 chk->copy_by_ref = 0;
8866 sctp_free_a_chunk(stcb, chk, SCTP_SO_NOT_LOCKED);
8869 chk->send_size = 0;
8871 chk->send_size += SCTP_BUF_LEN(mat);
8873 chk->sent = SCTP_DATAGRAM_UNSENT;
8874 chk->snd_count = 0;
8875 chk->asoc = &stcb->asoc;
8876 chk->data = op_err;
8877 chk->whoTo = NULL;
8881 hdr->chunk_length = htons(chk->send_size);
8882 TAILQ_INSERT_TAIL(&chk->asoc->control_send_queue,
8883 chk,
8885 chk->asoc->ctrl_queue_cnt++;
8902 struct sctp_tmit_chunk *chk;
8943 sctp_alloc_a_chunk(stcb, chk);
8944 if (chk == NULL) {
8949 chk->copy_by_ref = 0;
8950 chk->rec.chunk_id.id = SCTP_COOKIE_ECHO;
8951 chk->rec.chunk_id.can_take_data = 0;
8952 chk->flags = CHUNK_FLAGS_FRAGMENT_OK;
8953 chk->send_size = plen;
8954 chk->sent = SCTP_DATAGRAM_UNSENT;
8955 chk->snd_count = 0;
8956 chk->asoc = &stcb->asoc;
8957 chk->data = cookie;
8958 chk->whoTo = net;
8959 atomic_add_int(&chk->whoTo->ref_count, 1);
8960 TAILQ_INSERT_HEAD(&chk->asoc->control_send_queue, chk, sctp_next);
8961 chk->asoc->ctrl_queue_cnt++;
8977 struct sctp_tmit_chunk *chk;
9005 sctp_alloc_a_chunk(stcb, chk);
9006 if (chk == NULL) {
9011 chk->copy_by_ref = 0;
9012 chk->rec.chunk_id.id = SCTP_HEARTBEAT_ACK;
9013 chk->rec.chunk_id.can_take_data = 1;
9014 chk->flags = 0;
9015 chk->send_size = chk_length;
9016 chk->sent = SCTP_DATAGRAM_UNSENT;
9017 chk->snd_count = 0;
9018 chk->asoc = &stcb->asoc;
9019 chk->data = outchain;
9020 chk->whoTo = net;
9021 atomic_add_int(&chk->whoTo->ref_count, 1);
9022 TAILQ_INSERT_TAIL(&chk->asoc->control_send_queue, chk, sctp_next);
9023 chk->asoc->ctrl_queue_cnt++;
9032 struct sctp_tmit_chunk *chk;
9042 sctp_alloc_a_chunk(stcb, chk);
9043 if (chk == NULL) {
9048 chk->copy_by_ref = 0;
9049 chk->rec.chunk_id.id = SCTP_COOKIE_ACK;
9050 chk->rec.chunk_id.can_take_data = 1;
9051 chk->flags = 0;
9052 chk->send_size = sizeof(struct sctp_chunkhdr);
9053 chk->sent = SCTP_DATAGRAM_UNSENT;
9054 chk->snd_count = 0;
9055 chk->asoc = &stcb->asoc;
9056 chk->data = cookie_ack;
9057 if (chk->asoc->last_control_chunk_from != NULL) {
9058 chk->whoTo = chk->asoc->last_control_chunk_from;
9059 atomic_add_int(&chk->whoTo->ref_count, 1);
9061 chk->whoTo = NULL;
9066 hdr->chunk_length = htons(chk->send_size);
9067 SCTP_BUF_LEN(cookie_ack) = chk->send_size;
9068 TAILQ_INSERT_TAIL(&chk->asoc->control_send_queue, chk, sctp_next);
9069 chk->asoc->ctrl_queue_cnt++;
9080 struct sctp_tmit_chunk *chk;
9088 sctp_alloc_a_chunk(stcb, chk);
9089 if (chk == NULL) {
9094 chk->copy_by_ref = 0;
9095 chk->rec.chunk_id.id = SCTP_SHUTDOWN_ACK;
9096 chk->rec.chunk_id.can_take_data = 1;
9097 chk->flags = 0;
9098 chk->send_size = sizeof(struct sctp_chunkhdr);
9099 chk->sent = SCTP_DATAGRAM_UNSENT;
9100 chk->snd_count = 0;
9101 chk->flags = 0;
9102 chk->asoc = &stcb->asoc;
9103 chk->data = m_shutdown_ack;
9104 chk->whoTo = net;
9105 if (chk->whoTo) {
9106 atomic_add_int(&chk->whoTo->ref_count, 1);
9111 ack_cp->ch.chunk_length = htons(chk->send_size);
9112 SCTP_BUF_LEN(m_shutdown_ack) = chk->send_size;
9113 TAILQ_INSERT_TAIL(&chk->asoc->control_send_queue, chk, sctp_next);
9114 chk->asoc->ctrl_queue_cnt++;
9124 struct sctp_tmit_chunk *chk;
9132 sctp_alloc_a_chunk(stcb, chk);
9133 if (chk == NULL) {
9138 chk->copy_by_ref = 0;
9139 chk->rec.chunk_id.id = SCTP_SHUTDOWN;
9140 chk->rec.chunk_id.can_take_data = 1;
9141 chk->flags = 0;
9142 chk->send_size = sizeof(struct sctp_shutdown_chunk);
9143 chk->sent = SCTP_DATAGRAM_UNSENT;
9144 chk->snd_count = 0;
9145 chk->flags = 0;
9146 chk->asoc = &stcb->asoc;
9147 chk->data = m_shutdown;
9148 chk->whoTo = net;
9149 if (chk->whoTo) {
9150 atomic_add_int(&chk->whoTo->ref_count, 1);
9155 shutdown_cp->ch.chunk_length = htons(chk->send_size);
9157 SCTP_BUF_LEN(m_shutdown) = chk->send_size;
9158 TAILQ_INSERT_TAIL(&chk->asoc->control_send_queue, chk, sctp_next);
9159 chk->asoc->ctrl_queue_cnt++;
9170 struct sctp_tmit_chunk *chk;
9186 sctp_alloc_a_chunk(stcb, chk);
9187 if (chk == NULL) {
9192 chk->copy_by_ref = 0;
9193 chk->rec.chunk_id.id = SCTP_ASCONF;
9194 chk->rec.chunk_id.can_take_data = 0;
9195 chk->flags = CHUNK_FLAGS_FRAGMENT_OK;
9196 chk->data = m_asconf;
9197 chk->send_size = len;
9198 chk->sent = SCTP_DATAGRAM_UNSENT;
9199 chk->snd_count = 0;
9200 chk->asoc = &stcb->asoc;
9201 chk->whoTo = net;
9202 if (chk->whoTo) {
9203 atomic_add_int(&chk->whoTo->ref_count, 1);
9205 TAILQ_INSERT_TAIL(&chk->asoc->asconf_send_queue, chk, sctp_next);
9206 chk->asoc->ctrl_queue_cnt++;
9217 struct sctp_tmit_chunk *chk;
9274 sctp_alloc_a_chunk(stcb, chk);
9275 if (chk == NULL) {
9281 chk->copy_by_ref = 0;
9282 chk->rec.chunk_id.id = SCTP_ASCONF_ACK;
9283 chk->rec.chunk_id.can_take_data = 1;
9284 chk->flags = CHUNK_FLAGS_FRAGMENT_OK;
9285 chk->whoTo = net;
9286 if (chk->whoTo) {
9287 atomic_add_int(&chk->whoTo->ref_count, 1);
9289 chk->data = m_ack;
9290 chk->send_size = ack->len;
9291 chk->sent = SCTP_DATAGRAM_UNSENT;
9292 chk->snd_count = 0;
9293 chk->asoc = &stcb->asoc;
9295 TAILQ_INSERT_TAIL(&chk->asoc->control_send_queue, chk, sctp_next);
9296 chk->asoc->ctrl_queue_cnt++;
9325 struct sctp_tmit_chunk *chk, *fwd;
9360 TAILQ_FOREACH(chk, &asoc->control_send_queue, sctp_next) {
9361 if ((chk->rec.chunk_id.id == SCTP_COOKIE_ECHO) ||
9362 (chk->rec.chunk_id.id == SCTP_STREAM_RESET) ||
9363 (chk->rec.chunk_id.id == SCTP_FORWARD_CUM_TSN)) {
9364 if (chk->sent != SCTP_DATAGRAM_RESEND) {
9367 if (chk->rec.chunk_id.id == SCTP_STREAM_RESET) {
9368 if (chk != asoc->str_reset) {
9377 if (chk->rec.chunk_id.id == SCTP_FORWARD_CUM_TSN) {
9385 (sctp_auth_is_required_chunk(chk->rec.chunk_id.id,
9390 chk->rec.chunk_id.id);
9393 m = sctp_copy_mbufchain(chk->data, m, &endofchain, 0, chk->send_size, chk->copy_by_ref);
9402 if (chk->rec.chunk_id.id == SCTP_COOKIE_ECHO) {
9403 sctp_timer_start(SCTP_TIMER_TYPE_COOKIE, inp, stcb, chk->whoTo);
9404 } else if (chk->rec.chunk_id.id == SCTP_ASCONF)
9405 sctp_timer_start(SCTP_TIMER_TYPE_ASCONF, inp, stcb, chk->whoTo);
9406 chk->snd_count++; /* update our count */
9407 if ((error = sctp_lowlevel_chunk_output(inp, stcb, chk->whoTo,
9408 (struct sockaddr *)&chk->whoTo->ro._l_addr, m,
9412 chk->whoTo->port, NULL,
9425 /* (void)SCTP_GETTIME_TIMEVAL(&chk->whoTo->last_sent_time); */
9427 chk->sent = SCTP_DATAGRAM_SENT;
9453 TAILQ_FOREACH(chk, &asoc->sent_queue, sctp_next) {
9454 if (chk->sent != SCTP_DATAGRAM_RESEND) {
9458 if (chk->data == NULL) {
9459 SCTP_PRINTF("TSN:%x chk->snd_count:%d chk->sent:%d can't retran - no data\n",
9460 chk->rec.data.TSN_seq, chk->snd_count, chk->sent);
9464 (chk->snd_count >= SCTP_BASE_SYSCTL(sctp_max_retran_chunk))) {
9466 SCTP_PRINTF("Gak, chk->snd_count:%d >= max:%d - send abort\n",
9467 chk->snd_count,
9476 net = chk->whoTo;
9499 if (tsn == chk->rec.data.TSN_seq) {
9515 chk->window_probe = 1;
9516 chk->whoTo->window_probe = 1;
9525 if (chk->rec.data.doing_fast_retransmit == 0) {
9553 if ((chk->send_size <= (mtu - dmtu)) ||
9554 (chk->flags & CHUNK_FLAGS_FRAGMENT_OK)) {
9564 auth_keyid = chk->auth_keyid;
9568 auth_keyid = chk->auth_keyid;
9570 } else if (chk->auth_keyid != auth_keyid) {
9575 m = sctp_copy_mbufchain(chk->data, m, &endofchain, 0, chk->send_size, chk->copy_by_ref);
9581 if (chk->flags & CHUNK_FLAGS_FRAGMENT_OK) {
9585 if (mtu > (chk->send_size + dmtu))
9586 mtu -= (chk->send_size + dmtu);
9589 data_list[bundle_at++] = chk;
9596 * now are there anymore forward from chk to pick
9599 for (fwd = TAILQ_NEXT(chk, sctp_next); fwd != NULL; fwd = TAILQ_NEXT(fwd, sctp_next)) {
10145 struct sctp_tmit_chunk *chk;
10150 TAILQ_FOREACH(chk, &asoc->control_send_queue, sctp_next) {
10151 if (chk->rec.chunk_id.id == SCTP_FORWARD_CUM_TSN) {
10153 chk->sent = SCTP_DATAGRAM_UNSENT;
10154 chk->snd_count = 0;
10156 if (chk->whoTo) {
10157 sctp_free_remote_addr(chk->whoTo);
10158 chk->whoTo = NULL;
10164 sctp_alloc_a_chunk(stcb, chk);
10165 if (chk == NULL) {
10169 chk->copy_by_ref = 0;
10170 chk->rec.chunk_id.id = SCTP_FORWARD_CUM_TSN;
10171 chk->rec.chunk_id.can_take_data = 0;
10172 chk->flags = 0;
10173 chk->asoc = asoc;
10174 chk->whoTo = NULL;
10175 chk->data = sctp_get_mbuf_for_msg(MCLBYTES, 0, M_NOWAIT, 1, MT_DATA);
10176 if (chk->data == NULL) {
10177 sctp_free_a_chunk(stcb, chk, SCTP_SO_NOT_LOCKED);
10180 SCTP_BUF_RESV_UF(chk->data, SCTP_MIN_OVERHEAD);
10181 chk->sent = SCTP_DATAGRAM_UNSENT;
10182 chk->snd_count = 0;
10183 TAILQ_INSERT_TAIL(&asoc->control_send_queue, chk, sctp_next);
10190 SCTP_BUF_LEN(chk->data) = 0;
10213 cnt_of_space = M_TRAILINGSPACE(chk->data);
10272 chk->send_size = space_needed;
10274 fwdtsn = mtod(chk->data, struct sctp_forward_tsn_chunk *);
10275 fwdtsn->ch.chunk_length = htons(chk->send_size);
10279 SCTP_BUF_LEN(chk->data) = chk->send_size;
10335 struct sctp_tmit_chunk *chk, *a_chk;
10368 TAILQ_FOREACH(chk, &asoc->control_send_queue, sctp_next) {
10369 if (chk->rec.chunk_id.id == type) {
10371 TAILQ_REMOVE(&asoc->control_send_queue, chk, sctp_next);
10373 a_chk = chk;
11141 struct sctp_tmit_chunk *chk;
11162 sctp_alloc_a_chunk(stcb, chk);
11163 if (chk == NULL) {
11167 chk->copy_by_ref = 0;
11168 chk->rec.chunk_id.id = SCTP_HEARTBEAT_REQUEST;
11169 chk->rec.chunk_id.can_take_data = 1;
11170 chk->flags = 0;
11171 chk->asoc = &stcb->asoc;
11172 chk->send_size = sizeof(struct sctp_heartbeat_chunk);
11174 chk->data = sctp_get_mbuf_for_msg(chk->send_size, 0, M_NOWAIT, 1, MT_HEADER);
11175 if (chk->data == NULL) {
11176 sctp_free_a_chunk(stcb, chk, so_locked);
11179 SCTP_BUF_RESV_UF(chk->data, SCTP_MIN_OVERHEAD);
11180 SCTP_BUF_LEN(chk->data) = chk->send_size;
11181 chk->sent = SCTP_DATAGRAM_UNSENT;
11182 chk->snd_count = 0;
11183 chk->whoTo = net;
11184 atomic_add_int(&chk->whoTo->ref_count, 1);
11186 hb = mtod(chk->data, struct sctp_heartbeat_chunk *);
11191 hb->ch.chunk_length = htons(chk->send_size);
11231 TAILQ_INSERT_TAIL(&stcb->asoc.control_send_queue, chk, sctp_next);
11243 struct sctp_tmit_chunk *chk;
11250 TAILQ_FOREACH(chk, &asoc->control_send_queue, sctp_next) {
11251 if ((chk->rec.chunk_id.id == SCTP_ECN_ECHO) && (net == chk->whoTo)) {
11255 ecne = mtod(chk->data, struct sctp_ecne_chunk *);
11268 sctp_alloc_a_chunk(stcb, chk);
11269 if (chk == NULL) {
11273 chk->copy_by_ref = 0;
11274 chk->rec.chunk_id.id = SCTP_ECN_ECHO;
11275 chk->rec.chunk_id.can_take_data = 0;
11276 chk->flags = 0;
11277 chk->asoc = &stcb->asoc;
11278 chk->send_size = sizeof(struct sctp_ecne_chunk);
11279 chk->data = sctp_get_mbuf_for_msg(chk->send_size, 0, M_NOWAIT, 1, MT_HEADER);
11280 if (chk->data == NULL) {
11281 sctp_free_a_chunk(stcb, chk, SCTP_SO_NOT_LOCKED);
11284 SCTP_BUF_RESV_UF(chk->data, SCTP_MIN_OVERHEAD);
11285 SCTP_BUF_LEN(chk->data) = chk->send_size;
11286 chk->sent = SCTP_DATAGRAM_UNSENT;
11287 chk->snd_count = 0;
11288 chk->whoTo = net;
11289 atomic_add_int(&chk->whoTo->ref_count, 1);
11292 ecne = mtod(chk->data, struct sctp_ecne_chunk *);
11298 TAILQ_INSERT_HEAD(&stcb->asoc.control_send_queue, chk, sctp_next);
11308 struct sctp_tmit_chunk *chk;
11331 sctp_alloc_a_chunk(stcb, chk);
11332 if (chk == NULL) {
11335 chk->copy_by_ref = 0;
11336 chk->rec.chunk_id.id = SCTP_PACKET_DROPPED;
11337 chk->rec.chunk_id.can_take_data = 1;
11338 chk->flags = 0;
11340 chk->send_size = len;
11361 sctp_free_a_chunk(stcb, chk, SCTP_SO_NOT_LOCKED);
11380 chk->asoc = &stcb->asoc;
11381 chk->data = sctp_get_mbuf_for_msg(MCLBYTES, 0, M_NOWAIT, 1, MT_DATA);
11382 if (chk->data == NULL) {
11384 sctp_free_a_chunk(stcb, chk, SCTP_SO_NOT_LOCKED);
11387 SCTP_BUF_RESV_UF(chk->data, SCTP_MIN_OVERHEAD);
11388 drp = mtod(chk->data, struct sctp_pktdrop_chunk *);
11390 sctp_m_freem(chk->data);
11391 chk->data = NULL;
11394 chk->book_size = SCTP_SIZE32((chk->send_size + sizeof(struct sctp_pktdrop_chunk) +
11396 chk->book_size_scale = 0;
11404 chk->send_size = len - sizeof(struct sctp_pktdrop_chunk);
11405 len = chk->send_size;
11414 chk->send_size += sizeof(struct sctp_pktdrop_chunk);
11415 SCTP_BUF_LEN(chk->data) = chk->send_size;
11416 chk->sent = SCTP_DATAGRAM_UNSENT;
11417 chk->snd_count = 0;
11420 chk->whoTo = net;
11421 atomic_add_int(&chk->whoTo->ref_count, 1);
11423 chk->whoTo = NULL;
11426 drp->ch.chunk_length = htons(chk->send_size);
11447 TAILQ_INSERT_TAIL(&stcb->asoc.control_send_queue, chk, sctp_next);
11456 struct sctp_tmit_chunk *chk;
11463 TAILQ_FOREACH(chk, &asoc->control_send_queue, sctp_next) {
11464 if ((chk->rec.chunk_id.id == SCTP_ECN_CWR) && (net == chk->whoTo)) {
11471 cwr = mtod(chk->data, struct sctp_cwr_chunk *);
11483 sctp_alloc_a_chunk(stcb, chk);
11484 if (chk == NULL) {
11487 chk->copy_by_ref = 0;
11488 chk->rec.chunk_id.id = SCTP_ECN_CWR;
11489 chk->rec.chunk_id.can_take_data = 1;
11490 chk->flags = 0;
11491 chk->asoc = &stcb->asoc;
11492 chk->send_size = sizeof(struct sctp_cwr_chunk);
11493 chk->data = sctp_get_mbuf_for_msg(chk->send_size, 0, M_NOWAIT, 1, MT_HEADER);
11494 if (chk->data == NULL) {
11495 sctp_free_a_chunk(stcb, chk, SCTP_SO_NOT_LOCKED);
11498 SCTP_BUF_RESV_UF(chk->data, SCTP_MIN_OVERHEAD);
11499 SCTP_BUF_LEN(chk->data) = chk->send_size;
11500 chk->sent = SCTP_DATAGRAM_UNSENT;
11501 chk->snd_count = 0;
11502 chk->whoTo = net;
11503 atomic_add_int(&chk->whoTo->ref_count, 1);
11504 cwr = mtod(chk->data, struct sctp_cwr_chunk *);
11509 TAILQ_INSERT_TAIL(&stcb->asoc.control_send_queue, chk, sctp_next);
11514 sctp_add_stream_reset_out(struct sctp_tmit_chunk *chk,
11522 ch = mtod(chk->data, struct sctp_chunkhdr *);
11549 chk->book_size = len + old_len;
11550 chk->book_size_scale = 0;
11551 chk->send_size = SCTP_SIZE32(chk->book_size);
11552 SCTP_BUF_LEN(chk->data) = chk->send_size;
11557 sctp_add_stream_reset_in(struct sctp_tmit_chunk *chk,
11565 ch = mtod(chk->data, struct sctp_chunkhdr *);
11590 chk->book_size = len + old_len;
11591 chk->book_size_scale = 0;
11592 chk->send_size = SCTP_SIZE32(chk->book_size);
11593 SCTP_BUF_LEN(chk->data) = chk->send_size;
11598 sctp_add_stream_reset_tsn(struct sctp_tmit_chunk *chk,
11605 ch = mtod(chk->data, struct sctp_chunkhdr *);
11618 chk->send_size = len + old_len;
11619 chk->book_size = SCTP_SIZE32(chk->send_size);
11620 chk->book_size_scale = 0;
11621 SCTP_BUF_LEN(chk->data) = SCTP_SIZE32(chk->send_size);
11626 sctp_add_stream_reset_result(struct sctp_tmit_chunk *chk,
11633 ch = mtod(chk->data, struct sctp_chunkhdr *);
11647 chk->book_size = len + old_len;
11648 chk->book_size_scale = 0;
11649 chk->send_size = SCTP_SIZE32(chk->book_size);
11650 SCTP_BUF_LEN(chk->data) = chk->send_size;
11655 sctp_add_stream_reset_result_tsn(struct sctp_tmit_chunk *chk,
11663 ch = mtod(chk->data, struct sctp_chunkhdr *);
11679 chk->book_size = len + old_len;
11680 chk->send_size = SCTP_SIZE32(chk->book_size);
11681 chk->book_size_scale = 0;
11682 SCTP_BUF_LEN(chk->data) = chk->send_size;
11687 sctp_add_an_out_stream(struct sctp_tmit_chunk *chk,
11695 ch = mtod(chk->data, struct sctp_chunkhdr *);
11712 chk->send_size = len + old_len;
11713 chk->book_size = SCTP_SIZE32(chk->send_size);
11714 chk->book_size_scale = 0;
11715 SCTP_BUF_LEN(chk->data) = SCTP_SIZE32(chk->send_size);
11720 sctp_add_an_in_stream(struct sctp_tmit_chunk *chk,
11728 ch = mtod(chk->data, struct sctp_chunkhdr *);
11744 chk->send_size = len + old_len;
11745 chk->book_size = SCTP_SIZE32(chk->send_size);
11746 chk->book_size_scale = 0;
11747 SCTP_BUF_LEN(chk->data) = SCTP_SIZE32(chk->send_size);
11763 struct sctp_tmit_chunk *chk;
11794 sctp_alloc_a_chunk(stcb, chk);
11795 if (chk == NULL) {
11799 chk->copy_by_ref = 0;
11800 chk->rec.chunk_id.id = SCTP_STREAM_RESET;
11801 chk->rec.chunk_id.can_take_data = 0;
11802 chk->flags = 0;
11803 chk->asoc = &stcb->asoc;
11804 chk->book_size = sizeof(struct sctp_chunkhdr);
11805 chk->send_size = SCTP_SIZE32(chk->book_size);
11806 chk->book_size_scale = 0;
11808 chk->data = sctp_get_mbuf_for_msg(MCLBYTES, 0, M_NOWAIT, 1, MT_DATA);
11809 if (chk->data == NULL) {
11810 sctp_free_a_chunk(stcb, chk, SCTP_SO_LOCKED);
11814 SCTP_BUF_RESV_UF(chk->data, SCTP_MIN_OVERHEAD);
11817 chk->sent = SCTP_DATAGRAM_UNSENT;
11818 chk->snd_count = 0;
11820 chk->whoTo = stcb->asoc.alternate;
11822 chk->whoTo = stcb->asoc.primary_destination;
11824 atomic_add_int(&chk->whoTo->ref_count, 1);
11825 ch = mtod(chk->data, struct sctp_chunkhdr *);
11828 ch->chunk_length = htons(chk->book_size);
11829 SCTP_BUF_LEN(chk->data) = chk->send_size;
11833 sctp_add_stream_reset_out(chk, number_entries, list,
11918 sctp_add_an_out_stream(chk, seq, adding_o);
11923 sctp_add_an_in_stream(chk, seq, adding_i);
11928 sctp_add_stream_reset_in(chk, number_entries, list, seq);
11933 sctp_add_stream_reset_tsn(chk, seq);
11936 asoc->str_reset = chk;
11939 chk,
11942 sctp_timer_start(SCTP_TIMER_TYPE_STRRESET, stcb->sctp_ep, stcb, chk->whoTo);