+ }
+ sbcompress(sb, m, n);
+}
+
+/*
+ * As above, except the mbuf chain
+ * begins a new record.
+ */
+sbappendrecord(sb, m0)
+ register struct sockbuf *sb;
+ register struct mbuf *m0;
+{
+ register struct mbuf *m;
+
+ if (m0 == 0)
+ return;
+ if (m = sb->sb_mb)
+ while (m->m_act)
+ m = m->m_act;
+ /*
+ * Put the first mbuf on the queue.
+ * Note this permits zero length records.
+ */
+ sballoc(sb, m0);
+ if (m)
+ m->m_act = m0;
+ else
+ sb->sb_mb = m0;
+ m = m0->m_next;
+ m0->m_next = 0;
+ sbcompress(sb, m, m0);
+}
+
+/*
+ * Append address and data, and optionally, rights
+ * to the receive queue of a socket. Return 0 if
+ * no space in sockbuf or insufficient mbufs.
+ */
+sbappendaddr(sb, asa, m0, rights0) /* XXX */
+ register struct sockbuf *sb;
+ struct sockaddr *asa;
+ struct mbuf *rights0, *m0;
+{
+ register struct mbuf *m, *n;
+ int space = sizeof (*asa);
+
+ m = m0;
+ if (m == 0)
+ panic("sbappendaddr");
+ do {
+ space += m->m_len;
+ m = m->m_next;
+ } while (m);
+ if (rights0)
+ space += rights0->m_len;
+ if (space > sbspace(sb))
+ return (0);
+ m = m_get(M_DONTWAIT, MT_SONAME);
+ if (m == 0)
+ return (0);
+ *mtod(m, struct sockaddr *) = *asa;
+ m->m_len = sizeof (*asa);
+ if (rights0) {
+ m->m_act = m_copy(rights0, 0, rights0->m_len);
+ if (m->m_act == 0) {
+ m_freem(m);
+ return (0);
+ }
+ sballoc(sb, m);
+ sballoc(sb, m->m_act);
+ } else
+ sballoc(sb, m);
+ if (n = sb->sb_mb) {
+ while (n->m_act)
+ n = n->m_act;
+ n->m_act = m;
+ } else
+ sb->sb_mb = m;
+ if (m->m_act)
+ m = m->m_act;
+ sballoc(sb, m0);
+ m->m_act = m0;
+ m = m0->m_next;
+ m0->m_next = 0;
+ sbcompress(sb, m, m0);
+ return (1);
+}
+
+#ifdef notdef
+sbappendrights(sb, rights, m0)
+ struct sockbuf *sb;
+ struct mbuf *rights, *m;
+{
+ register struct mbuf *m, *n;
+ int space = 0;
+
+ m = m0;
+ if (m == 0 || rights == 0)
+ panic("sbappendrights");
+ do {
+ space += m->m_len;
+ m = m->m_next;
+ } while (m);
+ space += rights->m_len;
+ if (space > sbspace(sb))
+ return (0);
+ m = m_copy(rights, 0, rights->m_len);
+ if (m == 0)
+ return (0);
+ sballoc(sb, m);
+ if (n = sb->sb_mb) {
+ while (n->m_act)
+ n = n->m_act;
+ n->m_act = m;
+ } else
+ n->m_act = m;
+ sballoc(sb, m0);
+ m->m_act = m0;
+ m = m0->m_next;
+ m0->m_next = 0;
+ sbcompress(sb, m, m0);
+ return (1);
+}
+#endif
+
+/*
+ * Compress mbuf chain m into the socket
+ * buffer sb following mbuf n. If n
+ * is null, the buffer is presumed empty.
+ */
+sbcompress(sb, m, n)
+ register struct sockbuf *sb;
+ register struct mbuf *m, *n;
+{
+