MCPcopy Create free account
hub / github.com/F-Stack/f-stack / sctp_notify_shutdown_event

Function sctp_notify_shutdown_event

freebsd/netinet/sctputil.c:3713–3764  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3711}
3712
3713static void
3714sctp_notify_shutdown_event(struct sctp_tcb *stcb)
3715{
3716 struct mbuf *m_notify;
3717 struct sctp_shutdown_event *sse;
3718 struct sctp_queued_to_read *control;
3719
3720 /*
3721 * For TCP model AND UDP connected sockets we will send an error up
3722 * when an SHUTDOWN completes
3723 */
3724 if ((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
3725 (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL)) {
3726 /* mark socket closed for read/write and wakeup! */
3727 socantsendmore(stcb->sctp_socket);
3728 }
3729 if (sctp_stcb_is_feature_off(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_RECVSHUTDOWNEVNT)) {
3730 /* event not enabled */
3731 return;
3732 }
3733
3734 m_notify = sctp_get_mbuf_for_msg(sizeof(struct sctp_shutdown_event), 0, M_NOWAIT, 1, MT_DATA);
3735 if (m_notify == NULL)
3736 /* no space left */
3737 return;
3738 sse = mtod(m_notify, struct sctp_shutdown_event *);
3739 memset(sse, 0, sizeof(struct sctp_shutdown_event));
3740 sse->sse_type = SCTP_SHUTDOWN_EVENT;
3741 sse->sse_flags = 0;
3742 sse->sse_length = sizeof(struct sctp_shutdown_event);
3743 sse->sse_assoc_id = sctp_get_associd(stcb);
3744
3745 SCTP_BUF_LEN(m_notify) = sizeof(struct sctp_shutdown_event);
3746 SCTP_BUF_NEXT(m_notify) = NULL;
3747
3748 /* append to socket */
3749 control = sctp_build_readq_entry(stcb, stcb->asoc.primary_destination,
3750 0, 0, stcb->asoc.context, 0, 0, 0,
3751 m_notify);
3752 if (control == NULL) {
3753 /* no memory */
3754 sctp_m_freem(m_notify);
3755 return;
3756 }
3757 control->length = SCTP_BUF_LEN(m_notify);
3758 control->spec_flags = M_NOTIFICATION;
3759 /* not that we need this */
3760 control->tail_mbuf = m_notify;
3761 sctp_add_to_readq(stcb->sctp_ep, stcb,
3762 control,
3763 &stcb->sctp_socket->so_rcv, 1, SCTP_READ_LOCK_NOT_HELD, SCTP_SO_NOT_LOCKED);
3764}
3765
3766static void
3767sctp_notify_sender_dry_event(struct sctp_tcb *stcb,

Callers 1

sctp_ulp_notifyFunction · 0.85

Calls 6

socantsendmoreFunction · 0.85
sctp_get_mbuf_for_msgFunction · 0.85
memsetFunction · 0.85
sctp_build_readq_entryFunction · 0.85
sctp_m_freemFunction · 0.85
sctp_add_to_readqFunction · 0.85

Tested by

no test coverage detected