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

Function sbcreatecontrol_how

freebsd/kern/uipc_sockbuf.c:1732–1763  ·  view source on GitHub ↗

* Create a "control" mbuf containing the specified data with the specified * type for presentation on a socket buffer. */

Source from the content-addressed store, hash-verified

1730 * type for presentation on a socket buffer.
1731 */
1732struct mbuf *
1733sbcreatecontrol_how(void *p, int size, int type, int level, int wait)
1734{
1735 struct cmsghdr *cp;
1736 struct mbuf *m;
1737
1738 MBUF_CHECKSLEEP(wait);
1739 if (CMSG_SPACE((u_int)size) > MCLBYTES)
1740 return ((struct mbuf *) NULL);
1741 if (CMSG_SPACE((u_int)size) > MLEN)
1742 m = m_getcl(wait, MT_CONTROL, 0);
1743 else
1744 m = m_get(wait, MT_CONTROL);
1745 if (m == NULL)
1746 return ((struct mbuf *) NULL);
1747 cp = mtod(m, struct cmsghdr *);
1748 m->m_len = 0;
1749 KASSERT(CMSG_SPACE((u_int)size) <= M_TRAILINGSPACE(m),
1750 ("sbcreatecontrol: short mbuf"));
1751 /*
1752 * Don't leave the padding between the msg header and the
1753 * cmsg data and the padding after the cmsg data un-initialized.
1754 */
1755 bzero(cp, CMSG_SPACE((u_int)size));
1756 if (p != NULL)
1757 (void)memcpy(CMSG_DATA(cp), p, size);
1758 m->m_len = CMSG_SPACE(size);
1759 cp->cmsg_len = CMSG_LEN(size);
1760 cp->cmsg_level = level;
1761 cp->cmsg_type = type;
1762 return (m);
1763}
1764
1765struct mbuf *
1766sbcreatecontrol(caddr_t p, int size, int type, int level)

Callers 2

ktls_decryptFunction · 0.85
sbcreatecontrolFunction · 0.85

Calls 4

bzeroFunction · 0.85
m_getclFunction · 0.50
m_getFunction · 0.50
memcpyFunction · 0.50

Tested by

no test coverage detected