Deleted Added
full compact
33c33
< __FBSDID("$FreeBSD: head/sys/kern/uipc_sockbuf.c 167715 2007-03-19 18:35:13Z andre $");
---
> __FBSDID("$FreeBSD: head/sys/kern/uipc_sockbuf.c 167895 2007-03-26 08:59:03Z rwatson $");
981a982,1033
> /*
> * Create a "control" mbuf containing the specified data
> * with the specified type for presentation on a socket buffer.
> */
> struct mbuf *
> sbcreatecontrol(p, size, type, level)
> caddr_t p;
> register int size;
> int type, level;
> {
> register struct cmsghdr *cp;
> struct mbuf *m;
>
> if (CMSG_SPACE((u_int)size) > MCLBYTES)
> return ((struct mbuf *) NULL);
> if (CMSG_SPACE((u_int)size) > MLEN)
> m = m_getcl(M_DONTWAIT, MT_CONTROL, 0);
> else
> m = m_get(M_DONTWAIT, MT_CONTROL);
> if (m == NULL)
> return ((struct mbuf *) NULL);
> cp = mtod(m, struct cmsghdr *);
> m->m_len = 0;
> KASSERT(CMSG_SPACE((u_int)size) <= M_TRAILINGSPACE(m),
> ("sbcreatecontrol: short mbuf"));
> if (p != NULL)
> (void)memcpy(CMSG_DATA(cp), p, size);
> m->m_len = CMSG_SPACE(size);
> cp->cmsg_len = CMSG_LEN(size);
> cp->cmsg_level = level;
> cp->cmsg_type = type;
> return (m);
> }
>
> /*
> * This does the same for sockbufs. Note that the xsockbuf structure,
> * since it is always embedded in a socket, does not include a self
> * pointer nor a length. We make this entry point public in case
> * some other mechanism needs it.
> */
> void
> sbtoxsockbuf(struct sockbuf *sb, struct xsockbuf *xsb)
> {
> xsb->sb_cc = sb->sb_cc;
> xsb->sb_hiwat = sb->sb_hiwat;
> xsb->sb_mbcnt = sb->sb_mbcnt;
> xsb->sb_mbmax = sb->sb_mbmax;
> xsb->sb_lowat = sb->sb_lowat;
> xsb->sb_flags = sb->sb_flags;
> xsb->sb_timeo = sb->sb_timeo;
> }
>