-struct sockaddr *dup_sockaddr(struct sockaddr *sa, int canwait);
-int getsock(struct filedesc *fdp, int fd, struct file **fpp);
-int sockargs(struct mbuf **mp, user_addr_t data, int buflen, int type);
-int getsockaddr(struct sockaddr **namp, user_addr_t uaddr, size_t len);
-int sbappend(struct sockbuf *sb, struct mbuf *m);
-int sbappendaddr(struct sockbuf *sb, struct sockaddr *asa,
- struct mbuf *m0, struct mbuf *control, int *error_out);
-int sbappendcontrol(struct sockbuf *sb, struct mbuf *m0,
- struct mbuf *control, int *error_out);
-int sbappendrecord(struct sockbuf *sb, struct mbuf *m0);
-void sbcheck(struct sockbuf *sb);
-struct mbuf *
- sbcreatecontrol(caddr_t p, int size, int type, int level);
-void sbdrop(struct sockbuf *sb, int len);
-void sbdroprecord(struct sockbuf *sb);
-void sbflush(struct sockbuf *sb);
-int sbinsertoob(struct sockbuf *sb, struct mbuf *m0);
-void sbrelease(struct sockbuf *sb);
-int sbreserve(struct sockbuf *sb, u_long cc);
-void sbtoxsockbuf(struct sockbuf *sb, struct xsockbuf *xsb);
-int sbwait(struct sockbuf *sb);
-int sb_lock(struct sockbuf *sb);
-int soabort(struct socket *so);
-int soaccept(struct socket *so, struct sockaddr **nam);
-int soacceptlock (struct socket *so, struct sockaddr **nam, int dolock);
-struct socket *soalloc(int waitok, int dom, int type);
-int sobind(struct socket *so, struct sockaddr *nam);
-void socantrcvmore(struct socket *so);
-void socantsendmore(struct socket *so);
-int soclose(struct socket *so);
-int soconnect(struct socket *so, struct sockaddr *nam);
-int soconnectlock (struct socket *so, struct sockaddr *nam, int dolock);
-int soconnect2(struct socket *so1, struct socket *so2);
-int socreate(int dom, struct socket **aso, int type, int proto);
-void sodealloc(struct socket *so);
-int sodisconnect(struct socket *so);
-void sofree(struct socket *so);
-int sogetopt(struct socket *so, struct sockopt *sopt);
-void sohasoutofband(struct socket *so);
-void soisconnected(struct socket *so);
-void soisconnecting(struct socket *so);
-void soisdisconnected(struct socket *so);
-void soisdisconnecting(struct socket *so);
-int solisten(struct socket *so, int backlog);
-struct socket *
- sodropablereq(struct socket *head);
-struct socket *
- sonewconn(struct socket *head, int connstatus, const struct sockaddr* from);
-int sooptcopyin(struct sockopt *sopt, void *data, size_t len, size_t minlen);
-int sooptcopyout(struct sockopt *sopt, void *data, size_t len);
-int socket_lock(struct socket *so, int refcount);
-int socket_unlock(struct socket *so, int refcount);
+/* Exported */
+extern int sbappendaddr(struct sockbuf *sb, struct sockaddr *asa,
+ struct mbuf *m0, struct mbuf *control, int *error_out);
+extern int sbappendchain(struct sockbuf *sb, struct mbuf *m, int space);
+extern int sbappendrecord(struct sockbuf *sb, struct mbuf *m0);
+extern void sbflush(struct sockbuf *sb);
+extern int sbspace(struct sockbuf *sb);
+extern int soabort(struct socket *so);
+extern void socantrcvmore(struct socket *so);
+extern void socantsendmore(struct socket *so);
+extern int sodisconnect(struct socket *so);
+extern void sofree(struct socket *so);
+extern void sofreelastref(struct socket *, int);
+extern void soisconnected(struct socket *so);
+extern boolean_t socanwrite(struct socket *so);
+extern void soisconnecting(struct socket *so);
+extern void soisdisconnected(struct socket *so);
+extern void soisdisconnecting(struct socket *so);
+extern struct socket *sonewconn(struct socket *head, int connstatus,
+ const struct sockaddr *from);
+extern int sopoll(struct socket *so, int events, struct ucred *cred, void *wql);
+extern int sooptcopyin(struct sockopt *sopt, void *data, size_t len,
+ size_t minlen)
+__attribute__ ((warn_unused_result));
+extern int sooptcopyout(struct sockopt *sopt, void *data, size_t len)
+__attribute__ ((warn_unused_result));
+extern int soopt_cred_check(struct socket *so, int priv, boolean_t allow_root,
+ boolean_t ignore_delegate);
+extern int soreceive(struct socket *so, struct sockaddr **paddr,
+ struct uio *uio, struct mbuf **mp0, struct mbuf **controlp, int *flagsp);
+extern int soreserve(struct socket *so, u_int32_t sndcc, u_int32_t rcvcc);
+extern void soreserve_preconnect(struct socket *so, unsigned int pre_cc);
+extern void sorwakeup(struct socket *so);
+extern int sosend(struct socket *so, struct sockaddr *addr, struct uio *uio,
+ struct mbuf *top, struct mbuf *control, int flags);
+extern int sosend_reinject(struct socket *so, struct sockaddr *addr, struct mbuf *top,
+ struct mbuf *control, uint32_t sendflags);
+extern int sosend_list(struct socket *so, struct uio **uio, u_int uiocnt,
+ int flags);
+extern int soreceive_list(struct socket *so, struct recv_msg_elem *msgarray,
+ u_int msgcnt, int *flags);
+extern void sonullevent(struct socket *so, void *arg, uint32_t hint);
+extern struct mbuf *sbconcat_mbufs(struct sockbuf *sb, struct sockaddr *asa, struct mbuf *m0,
+ struct mbuf *control);
+
+
+__END_DECLS
+
+#ifdef BSD_KERNEL_PRIVATE
+struct file;
+struct filedesc;
+struct so_tcdbg;
+
+__BEGIN_DECLS
+/* Not exported */
+extern void socketinit(void);
+extern struct sockaddr *dup_sockaddr(struct sockaddr *sa, int canwait);
+extern int getsock(struct filedesc *fdp, int fd, struct file **fpp);
+extern int sockargs(struct mbuf **mp, user_addr_t data, int buflen, int type);
+extern void get_sockev_state(struct socket *, u_int32_t *);
+extern void so_update_last_owner_locked(struct socket *, struct proc *);
+extern void so_update_policy(struct socket *);
+extern void so_acquire_accept_list(struct socket *, struct socket *);
+extern void so_release_accept_list(struct socket *);
+
+extern int sbappend(struct sockbuf *sb, struct mbuf *m);
+extern int sbappendstream(struct sockbuf *sb, struct mbuf *m);
+extern int sbappendcontrol(struct sockbuf *sb, struct mbuf *m0,
+ struct mbuf *control, int *error_out);
+extern int sbappendmsgstream_rcv(struct sockbuf *sb, struct mbuf *m,
+ uint32_t seqnum, int flags);
+extern int sbappendstream_rcvdemux(struct socket *so, struct mbuf *m,
+ uint32_t seqnum, int flags);
+#if MPTCP
+extern int sbappendmptcpstream_rcv(struct sockbuf *sb, struct mbuf *m);
+#endif /* MPTCP */
+extern int sbappendmsg_snd(struct sockbuf *sb, struct mbuf *m);
+extern void sbpull_unordered_data(struct socket *, int32_t, int32_t);
+extern void sbcheck(struct sockbuf *sb);
+extern void sblastmbufchk(struct sockbuf *, const char *);
+extern void sblastrecordchk(struct sockbuf *, const char *);
+extern struct mbuf *sbcreatecontrol(caddr_t p, int size, int type, int level);
+extern struct mbuf **sbcreatecontrol_mbuf(caddr_t p, int size, int type,
+ int level, struct mbuf **m);
+extern void sbdrop(struct sockbuf *sb, int len);
+extern void sbdroprecord(struct sockbuf *sb);
+extern void sbrelease(struct sockbuf *sb);
+extern int sbreserve(struct sockbuf *sb, u_int32_t cc);
+extern void sbtoxsockbuf(struct sockbuf *sb, struct xsockbuf *xsb);
+extern int sbwait(struct sockbuf *sb);
+extern void sbwakeup(struct sockbuf *sb);
+extern void sb_empty_assert(struct sockbuf *, const char *);
+extern int sb_notify(struct sockbuf *sb);
+extern void sballoc(struct sockbuf *sb, struct mbuf *m);
+extern void sbfree(struct sockbuf *sb, struct mbuf *m);
+extern void sbfree_chunk(struct sockbuf *sb, struct mbuf *m);