* Create a "control" mbuf containing the specified data with the specified * type for presentation on a socket buffer. */
| 1730 | * type for presentation on a socket buffer. |
| 1731 | */ |
| 1732 | struct mbuf * |
| 1733 | sbcreatecontrol_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 | |
| 1765 | struct mbuf * |
| 1766 | sbcreatecontrol(caddr_t p, int size, int type, int level) |
no test coverage detected