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

Function sctp_notify_authentication

freebsd/netinet/sctp_auth.c:1709–1764  ·  view source on GitHub ↗

* Generate NOTIFICATION */

Source from the content-addressed store, hash-verified

1707 * Generate NOTIFICATION
1708 */
1709void
1710sctp_notify_authentication(struct sctp_tcb *stcb, uint32_t indication,
1711 uint16_t keyid, uint16_t alt_keyid, int so_locked)
1712{
1713 struct mbuf *m_notify;
1714 struct sctp_authkey_event *auth;
1715 struct sctp_queued_to_read *control;
1716
1717 if ((stcb == NULL) ||
1718 (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) ||
1719 (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) ||
1720 (stcb->asoc.state & SCTP_STATE_CLOSED_SOCKET)
1721 ) {
1722 /* If the socket is gone we are out of here */
1723 return;
1724 }
1725
1726 if (sctp_stcb_is_feature_off(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_AUTHEVNT))
1727 /* event not enabled */
1728 return;
1729
1730 m_notify = sctp_get_mbuf_for_msg(sizeof(struct sctp_authkey_event),
1731 0, M_NOWAIT, 1, MT_HEADER);
1732 if (m_notify == NULL)
1733 /* no space left */
1734 return;
1735
1736 SCTP_BUF_LEN(m_notify) = 0;
1737 auth = mtod(m_notify, struct sctp_authkey_event *);
1738 memset(auth, 0, sizeof(struct sctp_authkey_event));
1739 auth->auth_type = SCTP_AUTHENTICATION_EVENT;
1740 auth->auth_flags = 0;
1741 auth->auth_length = sizeof(*auth);
1742 auth->auth_keynumber = keyid;
1743 auth->auth_altkeynumber = alt_keyid;
1744 auth->auth_indication = indication;
1745 auth->auth_assoc_id = sctp_get_associd(stcb);
1746
1747 SCTP_BUF_LEN(m_notify) = sizeof(*auth);
1748 SCTP_BUF_NEXT(m_notify) = NULL;
1749
1750 /* append to socket */
1751 control = sctp_build_readq_entry(stcb, stcb->asoc.primary_destination,
1752 0, 0, stcb->asoc.context, 0, 0, 0, m_notify);
1753 if (control == NULL) {
1754 /* no memory */
1755 sctp_m_freem(m_notify);
1756 return;
1757 }
1758 control->length = SCTP_BUF_LEN(m_notify);
1759 control->spec_flags = M_NOTIFICATION;
1760 /* not that we need this */
1761 control->tail_mbuf = m_notify;
1762 sctp_add_to_readq(stcb->sctp_ep, stcb, control,
1763 &stcb->sctp_socket->so_rcv, 1, SCTP_READ_LOCK_NOT_HELD, so_locked);
1764}
1765
1766/*-

Callers 2

sctp_ulp_notifyFunction · 0.85
sctp_handle_authFunction · 0.85

Calls 5

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