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

Function sctp_copy_out_all

freebsd/netinet/sctp_output.c:6779–6819  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6777}
6778
6779static struct mbuf *
6780sctp_copy_out_all(struct uio *uio, ssize_t len)
6781{
6782 struct mbuf *ret, *at;
6783 ssize_t left, willcpy, cancpy, error;
6784
6785 ret = sctp_get_mbuf_for_msg(MCLBYTES, 0, M_WAITOK, 1, MT_DATA);
6786 if (ret == NULL) {
6787 /* TSNH */
6788 return (NULL);
6789 }
6790 left = len;
6791 SCTP_BUF_LEN(ret) = 0;
6792 /* save space for the data chunk header */
6793 cancpy = (int)M_TRAILINGSPACE(ret);
6794 willcpy = min(cancpy, left);
6795 at = ret;
6796 while (left > 0) {
6797 /* Align data to the end */
6798 error = uiomove(mtod(at, caddr_t), (int)willcpy, uio);
6799 if (error) {
6800 err_out_now:
6801 sctp_m_freem(at);
6802 return (NULL);
6803 }
6804 SCTP_BUF_LEN(at) = (int)willcpy;
6805 SCTP_BUF_NEXT_PKT(at) = SCTP_BUF_NEXT(at) = 0;
6806 left -= willcpy;
6807 if (left > 0) {
6808 SCTP_BUF_NEXT(at) = sctp_get_mbuf_for_msg((unsigned int)left, 0, M_WAITOK, 1, MT_DATA);
6809 if (SCTP_BUF_NEXT(at) == NULL) {
6810 goto err_out_now;
6811 }
6812 at = SCTP_BUF_NEXT(at);
6813 SCTP_BUF_LEN(at) = 0;
6814 cancpy = (int)M_TRAILINGSPACE(at);
6815 willcpy = min(cancpy, left);
6816 }
6817 }
6818 return (ret);
6819}
6820
6821static int
6822sctp_sendall(struct sctp_inpcb *inp, struct uio *uio, struct mbuf *m,

Callers 1

sctp_sendallFunction · 0.85

Calls 4

sctp_get_mbuf_for_msgFunction · 0.85
minFunction · 0.85
sctp_m_freemFunction · 0.85
uiomoveFunction · 0.50

Tested by

no test coverage detected