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

Function sctp_add_cookie

freebsd/netinet/sctp_output.c:3814–3897  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3812#endif
3813
3814static struct mbuf *
3815sctp_add_cookie(struct mbuf *init, int init_offset,
3816 struct mbuf *initack, int initack_offset, struct sctp_state_cookie *stc_in, uint8_t **signature)
3817{
3818 struct mbuf *copy_init, *copy_initack, *m_at, *sig, *mret;
3819 struct sctp_state_cookie *stc;
3820 struct sctp_paramhdr *ph;
3821 uint16_t cookie_sz;
3822
3823 mret = sctp_get_mbuf_for_msg((sizeof(struct sctp_state_cookie) +
3824 sizeof(struct sctp_paramhdr)), 0,
3825 M_NOWAIT, 1, MT_DATA);
3826 if (mret == NULL) {
3827 return (NULL);
3828 }
3829 copy_init = SCTP_M_COPYM(init, init_offset, M_COPYALL, M_NOWAIT);
3830 if (copy_init == NULL) {
3831 sctp_m_freem(mret);
3832 return (NULL);
3833 }
3834#ifdef SCTP_MBUF_LOGGING
3835 if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) {
3836 sctp_log_mbc(copy_init, SCTP_MBUF_ICOPY);
3837 }
3838#endif
3839 copy_initack = SCTP_M_COPYM(initack, initack_offset, M_COPYALL,
3840 M_NOWAIT);
3841 if (copy_initack == NULL) {
3842 sctp_m_freem(mret);
3843 sctp_m_freem(copy_init);
3844 return (NULL);
3845 }
3846#ifdef SCTP_MBUF_LOGGING
3847 if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) {
3848 sctp_log_mbc(copy_initack, SCTP_MBUF_ICOPY);
3849 }
3850#endif
3851 /* easy side we just drop it on the end */
3852 ph = mtod(mret, struct sctp_paramhdr *);
3853 SCTP_BUF_LEN(mret) = sizeof(struct sctp_state_cookie) +
3854 sizeof(struct sctp_paramhdr);
3855 stc = (struct sctp_state_cookie *)((caddr_t)ph +
3856 sizeof(struct sctp_paramhdr));
3857 ph->param_type = htons(SCTP_STATE_COOKIE);
3858 ph->param_length = 0; /* fill in at the end */
3859 /* Fill in the stc cookie data */
3860 memcpy(stc, stc_in, sizeof(struct sctp_state_cookie));
3861
3862 /* tack the INIT and then the INIT-ACK onto the chain */
3863 cookie_sz = 0;
3864 for (m_at = mret; m_at; m_at = SCTP_BUF_NEXT(m_at)) {
3865 cookie_sz += SCTP_BUF_LEN(m_at);
3866 if (SCTP_BUF_NEXT(m_at) == NULL) {
3867 SCTP_BUF_NEXT(m_at) = copy_init;
3868 break;
3869 }
3870 }
3871 for (m_at = copy_init; m_at; m_at = SCTP_BUF_NEXT(m_at)) {

Callers 1

sctp_send_initiate_ackFunction · 0.85

Calls 5

sctp_get_mbuf_for_msgFunction · 0.85
sctp_m_freemFunction · 0.85
sctp_log_mbcFunction · 0.85
memsetFunction · 0.85
memcpyFunction · 0.50

Tested by

no test coverage detected