summaryrefslogtreecommitdiffstats
path: root/sys/kern/uipc_sockbuf.c
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2007-03-26 08:59:03 +0000
committerrwatson <rwatson@FreeBSD.org>2007-03-26 08:59:03 +0000
commit81eac4c7f0f3f91fd02a0c66295b715e72759166 (patch)
tree1cafec9e04f87ecd3e4fc2ed0d4b9265ce83ae83 /sys/kern/uipc_sockbuf.c
parent9b2be94dbc56f08c032f76636e4720837899d651 (diff)
downloadFreeBSD-src-81eac4c7f0f3f91fd02a0c66295b715e72759166.zip
FreeBSD-src-81eac4c7f0f3f91fd02a0c66295b715e72759166.tar.gz
Complete removal of uipc_socket2.c by moving the last few functions to
other C files: - Move sbcreatecontrol() and sbtoxsockbuf() to uipc_sockbuf.c. While sbcreatecontrol() is really an mbuf allocation routine, it does its work with awareness of the layout of socket buffer memory. - Move pru_*() protocol switch stubs to uipc_socket.c where the non-stub versions of several of these functions live. Likewise, move socket state transition calls (soisconnecting(), etc) to uipc_socket.c. Moveo sodupsockaddr() and sotoxsocket().
Diffstat (limited to 'sys/kern/uipc_sockbuf.c')
-rw-r--r--sys/kern/uipc_sockbuf.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/sys/kern/uipc_sockbuf.c b/sys/kern/uipc_sockbuf.c
index 638f485..2293eef 100644
--- a/sys/kern/uipc_sockbuf.c
+++ b/sys/kern/uipc_sockbuf.c
@@ -979,6 +979,58 @@ sbdroprecord(struct sockbuf *sb)
SOCKBUF_UNLOCK(sb);
}
+/*
+ * 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;
+}
+
/* This takes the place of kern.maxsockbuf, which moved to kern.ipc. */
static int dummy;
SYSCTL_INT(_kern, KERN_DUMMY, dummy, CTLFLAG_RW, &dummy, 0, "");
OpenPOWER on IntegriCloud