+extern int soaccept(struct socket *so, struct sockaddr **nam);
+extern int soacceptlock(struct socket *so, struct sockaddr **nam, int dolock);
+extern int soacceptfilter(struct socket *so);
+extern struct socket *soalloc(int waitok, int dom, int type);
+extern int sobindlock(struct socket *so, struct sockaddr *nam, int dolock);
+extern int soclose(struct socket *so);
+extern int soclose_locked(struct socket *so);
+extern void soclose_wait_locked(struct socket *so);
+extern int soconnect(struct socket *so, struct sockaddr *nam);
+extern int soconnectlock(struct socket *so, struct sockaddr *nam, int dolock);
+extern int soconnect2(struct socket *so1, struct socket *so2);
+extern int soconnectxlocked(struct socket *so, struct sockaddr_list **src_sl,
+ struct sockaddr_list **dst_sl, struct proc *, uint32_t, associd_t,
+ connid_t *, uint32_t, void *, u_int32_t);
+extern int sodisconnectx(struct socket *so, associd_t, connid_t);
+extern int sodisconnectxlocked(struct socket *so, associd_t, connid_t);
+extern int sopeelofflocked(struct socket *so, associd_t, struct socket **);
+extern void soevupcall(struct socket *, u_int32_t);
+/* flags for socreate_internal */
+#define SOCF_ASYNC 0x1 /* non-blocking socket */
+#define SOCF_MP_SUBFLOW 0x2 /* multipath subflow socket */
+extern int socreate_internal(int dom, struct socket **aso, int type, int proto,
+ struct proc *, uint32_t, struct proc *);
+extern int socreate(int dom, struct socket **aso, int type, int proto);
+extern int socreate_delegate(int dom, struct socket **aso, int type, int proto, pid_t epid);
+extern void sodealloc(struct socket *so);
+extern int sodisconnectlocked(struct socket *so);
+extern void soreference(struct socket *so);
+extern void sodereference(struct socket *so);
+extern void somultipages(struct socket *, boolean_t);
+extern void soif2kcl(struct socket *, boolean_t);
+extern int sosetdefunct(struct proc *, struct socket *, int level, boolean_t);
+extern int sodefunct(struct proc *, struct socket *, int level);
+extern void sohasoutofband(struct socket *so);
+extern void sodisconnectwakeup(struct socket *so);
+extern int soisthrottled(struct socket *so);
+extern int soisprivilegedtraffic(struct socket *so);
+extern int soissrcbackground(struct socket *so);
+extern int soissrcrealtime(struct socket *so);
+extern int solisten(struct socket *so, int backlog);
+extern struct socket *sodropablereq(struct socket *head);
+extern int socket_lock(struct socket *so, int refcount);
+extern int socket_unlock(struct socket *so, int refcount);
+extern int sogetaddr_locked(struct socket *, struct sockaddr **, int);
+extern const char *solockhistory_nr(struct socket *);
+extern void soevent(struct socket *so, long hint);
+extern void sorflush(struct socket *so);
+extern void sowflush(struct socket *so);
+extern void sowakeup(struct socket *so, struct sockbuf *sb);
+extern int soioctl(struct socket *so, u_long cmd, caddr_t data, struct proc *p);
+extern int sogetoptlock(struct socket *so, struct sockopt *sopt, int);
+extern int sosetoptlock(struct socket *so, struct sockopt *sopt, int);
+extern int soshutdown(struct socket *so, int how);
+extern int soshutdownlock(struct socket *so, int how);
+extern int soshutdownlock_final(struct socket *so, int how);
+extern void sotoxsocket(struct socket *so, struct xsocket *xso);
+extern void sotoxsocket64(struct socket *so, struct xsocket64 *xso);
+extern int sosendallatonce(struct socket *so);
+extern int soreadable(struct socket *so);
+extern int sowriteable(struct socket *so);
+extern void sowwakeup(struct socket *so);
+extern int sosendcheck(struct socket *, struct sockaddr *, user_ssize_t,
+ int32_t, int32_t, int, int *, struct mbuf *);
+
+extern int soo_ioctl(struct fileproc *, u_long, caddr_t, vfs_context_t);
+extern int soo_stat(struct socket *, void *, int);
+extern int soo_select(struct fileproc *, int, void *, vfs_context_t);
+extern int soo_kqfilter(struct fileproc *, struct knote *, vfs_context_t);
+
+extern struct sockaddr_entry *sockaddrentry_alloc(int);
+extern void sockaddrentry_free(struct sockaddr_entry *);
+extern struct sockaddr_entry *sockaddrentry_dup(const struct sockaddr_entry *,
+ int);
+extern struct sockaddr_list *sockaddrlist_alloc(int);
+extern void sockaddrlist_free(struct sockaddr_list *);
+extern void sockaddrlist_insert(struct sockaddr_list *,
+ struct sockaddr_entry *);
+extern void sockaddrlist_remove(struct sockaddr_list *,
+ struct sockaddr_entry *);
+extern struct sockaddr_list *sockaddrlist_dup(const struct sockaddr_list *,
+ int);
+
+/* Service class flags used for setting service class on a packet */
+#define PKT_SCF_IPV6 0x00000001 /* IPv6 packet */
+#define PKT_SCF_TCP_ACK 0x00000002 /* Pure TCP ACK */
+
+extern void set_packet_service_class(struct mbuf *, struct socket *,
+ mbuf_svc_class_t, u_int32_t);
+extern void so_tc_update_stats(struct mbuf *, struct socket *,
+ mbuf_svc_class_t);
+extern mbuf_svc_class_t mbuf_service_class_from_control(struct mbuf *);
+extern mbuf_svc_class_t so_tc2msc(int);
+extern int so_svc2tc(mbuf_svc_class_t);
+
+extern u_int8_t tcp_cansbgrow(struct sockbuf *sb);
+extern int tcp_get_msg_priority(struct mbuf *, uint32_t *);
+extern void set_tcp_stream_priority(struct socket *so);
+
+extern int so_set_traffic_class(struct socket *, int);
+extern void so_set_default_traffic_class(struct socket *);
+extern int so_set_opportunistic(struct socket *, int);
+extern int so_get_opportunistic(struct socket *);
+extern int so_set_recv_anyif(struct socket *, int);
+extern int so_get_recv_anyif(struct socket *);
+extern int so_set_effective_pid(struct socket *, int, struct proc *);
+extern int so_set_effective_uuid(struct socket *, uuid_t, struct proc *);
+extern int so_set_restrictions(struct socket *, uint32_t);
+extern uint32_t so_get_restrictions(struct socket *);
+extern void socket_tclass_init(void);
+extern int so_set_tcdbg(struct socket *, struct so_tcdbg *);
+extern int sogetopt_tcdbg(struct socket *, struct sockopt *);
+extern void so_set_lro(struct socket*, int);
+
+extern int so_isdstlocal(struct socket *);
+extern void so_recv_data_stat(struct socket *, struct mbuf *, size_t);
+extern void so_inc_recv_data_stat(struct socket *, size_t, size_t, uint32_t);
+extern int so_wait_for_if_feedback(struct socket *);
+extern int msgq_sbspace(struct socket *so, struct mbuf *control);
+extern int soopt_getm(struct sockopt *sopt, struct mbuf **mp);
+extern int soopt_mcopyin(struct sockopt *sopt, struct mbuf *m);
+extern int soopt_mcopyout(struct sockopt *sopt, struct mbuf *m);
+extern boolean_t so_cache_timer(void);
+
+extern void mptcp_preproc_sbdrop(struct mbuf *, unsigned int);
+extern void mptcp_postproc_sbdrop(struct mbuf *, u_int64_t, u_int32_t,
+ u_int32_t);
+extern int mptcp_adj_rmap(struct socket *, struct mbuf *);
+
+extern void netpolicy_post_msg(uint32_t, struct netpolicy_event_data *,
+ uint32_t);
+extern void socket_post_kev_msg(uint32_t, struct kev_socket_event_data *,
+ uint32_t);
+extern void socket_post_kev_msg_closed(struct socket *);
+/*
+ * Socket operation routines.
+ * These routines are called by the routines in
+ * sys_socket.c or from a system process, and
+ * implement the semantics of socket operations by
+ * switching out to the protocol specific routines.