-#define sotoin6pcb(so) sotoinpcb(so) /* for KAME src sync over BSD*'s */
-
-#define INP_SOCKAF(so) so->so_proto->pr_domain->dom_family
-
-#define INP_CHECK_SOCKAF(so, af) (INP_SOCKAF(so) == af)
-
-#ifdef KERNEL
-extern int ipport_lowfirstauto;
-extern int ipport_lowlastauto;
-extern int ipport_firstauto;
-extern int ipport_lastauto;
-extern int ipport_hifirstauto;
-extern int ipport_hilastauto;
-
-#define INPCB_STATE_INUSE 0x1 /* freshly allocated PCB, it's in use */
-#define INPCB_STATE_CACHED 0x2 /* this pcb is sitting in a a cache */
-#define INPCB_STATE_DEAD 0x3 /* should treat as gone, will be garbage collected and freed */
-
-#define WNT_STOPUSING 0xffff /* marked as ready to be garbaged collected, should be treated as not found */
-#define WNT_ACQUIRE 0x1 /* that pcb is being acquired, do not recycle this time */
-#define WNT_RELEASE 0x2 /* release acquired mode, can be garbage collected when wantcnt is null */
-
-
-void in_pcbpurgeif0(struct inpcb *, struct ifnet *);
-void in_losing(struct inpcb *);
-void in_rtchange(struct inpcb *, int);
-int in_pcballoc(struct socket *, struct inpcbinfo *, struct proc *);
-int in_pcbbind(struct inpcb *, struct sockaddr *, struct proc *);
-int in_pcbconnect(struct inpcb *, struct sockaddr *, struct proc *);
-void in_pcbdetach(struct inpcb *);
-void in_pcbdispose (struct inpcb *);
-void in_pcbdisconnect(struct inpcb *);
-int in_pcbinshash(struct inpcb *, int);
-int in_pcbladdr(struct inpcb *, struct sockaddr *, struct sockaddr_in **);
-struct inpcb *
- in_pcblookup_local(struct inpcbinfo *, struct in_addr, u_int, int);
-struct inpcb *
- in_pcblookup_hash(struct inpcbinfo *,
- struct in_addr, u_int, struct in_addr, u_int,
- int, struct ifnet *);
-void in_pcbnotifyall(struct inpcbinfo *, struct in_addr,
- int, void (*)(struct inpcb *, int));
-void in_pcbrehash(struct inpcb *);
-int in_setpeeraddr(struct socket *so, struct sockaddr **nam);
-int in_setsockaddr(struct socket *so, struct sockaddr **nam);
-int in_pcb_checkstate(struct inpcb *pcb, int mode, int locked);
-
-int
-in_pcb_grab_port (struct inpcbinfo *pcbinfo,
- u_short options,
- struct in_addr laddr,
- u_short *lport,
- struct in_addr faddr,
- u_short fport,
- u_int cookie,
- u_char owner_id);
-
-int
-in_pcb_letgo_port(struct inpcbinfo *pcbinfo,
- struct in_addr laddr,
- u_short lport,
- struct in_addr faddr,
- u_short fport, u_char owner_id);
-
-u_char
-in_pcb_get_owner(struct inpcbinfo *pcbinfo,
- struct in_addr laddr,
- u_short lport,
- struct in_addr faddr,
- u_short fport,
- u_int *cookie);
-
-void in_pcb_nat_init(struct inpcbinfo *pcbinfo, int afamily, int pfamily,
- int protocol);
-
-int
-in_pcb_new_share_client(struct inpcbinfo *pcbinfo, u_char *owner_id);
-
-int
-in_pcb_rem_share_client(struct inpcbinfo *pcbinfo, u_char owner_id);
-
-void in_pcbremlists(struct inpcb *inp);
-int in_pcb_ckeckstate(struct inpcb *, int, int);
-void inpcb_to_compat(struct inpcb *inp, struct inpcb_compat *inp_compat);
-
-#endif /* KERNEL */
+#define sotoin6pcb(so) sotoinpcb(so)
+
+struct sysctl_req;
+
+extern int ipport_lowfirstauto;
+extern int ipport_lowlastauto;
+extern int ipport_firstauto;
+extern int ipport_lastauto;
+extern int ipport_hifirstauto;
+extern int ipport_hilastauto;
+
+/* freshly allocated PCB, it's in use */
+#define INPCB_STATE_INUSE 0x1
+/* this pcb is sitting in a a cache */
+#define INPCB_STATE_CACHED 0x2
+/* should treat as gone, will be garbage collected and freed */
+#define INPCB_STATE_DEAD 0x3
+
+/* marked as ready to be garbaged collected, should be treated as not found */
+#define WNT_STOPUSING 0xffff
+/* that pcb is being acquired, do not recycle this time */
+#define WNT_ACQUIRE 0x1
+/* release acquired mode, can be garbage collected when wantcnt is null */
+#define WNT_RELEASE 0x2
+
+extern void in_pcbinit(void);
+extern void in_pcbinfo_attach(struct inpcbinfo *);
+extern int in_pcbinfo_detach(struct inpcbinfo *);
+
+/* type of timer to be scheduled by inpcb_gc_sched and inpcb_timer_sched */
+enum {
+ INPCB_TIMER_LAZY = 0x1,
+ INPCB_TIMER_FAST,
+ INPCB_TIMER_NODELAY
+};
+extern void inpcb_gc_sched(struct inpcbinfo *, u_int32_t type);
+extern void inpcb_timer_sched(struct inpcbinfo *, u_int32_t type);
+
+extern void in_losing(struct inpcb *);
+extern void in_rtchange(struct inpcb *, int);
+extern int in_pcballoc(struct socket *, struct inpcbinfo *, struct proc *);
+extern int in_pcbbind(struct inpcb *, struct sockaddr *, struct proc *);
+extern int in_pcbconnect(struct inpcb *, struct sockaddr *, struct proc *,
+ unsigned int, struct ifnet **);
+extern void in_pcbdetach(struct inpcb *);
+extern void in_pcbdispose(struct inpcb *);
+extern void in_pcbdisconnect(struct inpcb *);
+extern int in_pcbinshash(struct inpcb *, int);
+extern int in_pcbladdr(struct inpcb *, struct sockaddr *, struct in_addr *,
+ unsigned int, struct ifnet **, int);
+extern struct inpcb *in_pcblookup_local(struct inpcbinfo *, struct in_addr,
+ u_int, int);
+extern struct inpcb *in_pcblookup_local_and_cleanup(struct inpcbinfo *,
+ struct in_addr, u_int, int);
+extern struct inpcb *in_pcblookup_hash(struct inpcbinfo *, struct in_addr,
+ u_int, struct in_addr, u_int, int, struct ifnet *);
+extern int in_pcblookup_hash_exists(struct inpcbinfo *, struct in_addr,
+ u_int, struct in_addr, u_int, int, uid_t *, gid_t *, struct ifnet *);
+extern void in_pcbnotifyall(struct inpcbinfo *, struct in_addr, int,
+ void (*)(struct inpcb *, int));
+extern void in_pcbrehash(struct inpcb *);
+extern int in_getpeeraddr(struct socket *, struct sockaddr **);
+extern int in_getpeeraddr_s(struct socket *, struct sockaddr_storage *);
+extern int in_getsockaddr(struct socket *, struct sockaddr **);
+extern int in_getsockaddr_s(struct socket *, struct sockaddr_storage *);
+extern int in_pcb_checkstate(struct inpcb *, int, int);
+extern void in_pcbremlists(struct inpcb *);
+extern void inpcb_to_compat(struct inpcb *, struct inpcb_compat *);
+extern void inpcb_to_xinpcb64(struct inpcb *, struct xinpcb64 *);
+
+extern int get_pcblist_n(short, struct sysctl_req *, struct inpcbinfo *);
+#define INPCB_GET_PORTS_USED_WILDCARDOK 0x01
+#define INPCB_GET_PORTS_USED_NOWAKEUPOK 0x02
+#define INPCB_GET_PORTS_USED_RECVANYIFONLY 0x04
+#define INPCB_GET_PORTS_USED_EXTBGIDLEONLY 0x08
+#define INPCB_GET_PORTS_USED_ACTIVEONLY 0x10
+
+extern void inpcb_get_ports_used(u_int32_t, int, u_int32_t, bitstr_t *,
+ struct inpcbinfo *);
+#define INPCB_OPPORTUNISTIC_THROTTLEON 0x0001
+#define INPCB_OPPORTUNISTIC_SETCMD 0x0002
+extern uint32_t inpcb_count_opportunistic(unsigned int, struct inpcbinfo *,
+ u_int32_t);
+extern uint32_t inpcb_find_anypcb_byaddr(struct ifaddr *, struct inpcbinfo *);
+extern void inp_route_copyout(struct inpcb *, struct route *);
+extern void inp_route_copyin(struct inpcb *, struct route *);
+extern int inp_bindif(struct inpcb *, unsigned int, struct ifnet **);
+extern void inp_set_nocellular(struct inpcb *);
+extern void inp_clear_nocellular(struct inpcb *);
+extern void inp_set_noexpensive(struct inpcb *);
+extern void inp_set_awdl_unrestricted(struct inpcb *);
+extern boolean_t inp_get_awdl_unrestricted(struct inpcb *);
+extern void inp_clear_awdl_unrestricted(struct inpcb *);
+extern void inp_set_intcoproc_allowed(struct inpcb *);
+extern boolean_t inp_get_intcoproc_allowed(struct inpcb *);
+extern void inp_clear_intcoproc_allowed(struct inpcb *);
+#if NECP
+extern void inp_update_necp_policy(struct inpcb *, struct sockaddr *, struct sockaddr *, u_int);
+extern void inp_set_want_app_policy(struct inpcb *);
+extern void inp_clear_want_app_policy(struct inpcb *);
+#endif /* NECP */
+extern u_int32_t inp_calc_flowhash(struct inpcb *);
+extern void inp_reset_fc_state(struct inpcb *);
+extern int inp_set_fc_state(struct inpcb *, int advcode);
+extern void inp_fc_unthrottle_tcp(struct inpcb *);
+extern void inp_flowadv(uint32_t);
+extern int inp_flush(struct inpcb *, int);
+extern int inp_findinpcb_procinfo(struct inpcbinfo *, uint32_t, struct so_procinfo *);
+extern void inp_get_soprocinfo(struct inpcb *, struct so_procinfo *);
+extern int inp_update_policy(struct inpcb *);
+extern boolean_t inp_restricted_recv(struct inpcb *, struct ifnet *);
+extern boolean_t inp_restricted_send(struct inpcb *, struct ifnet *);
+extern void inp_incr_sndbytes_total(struct socket *, int);
+extern void inp_decr_sndbytes_total(struct socket *, int);
+extern void inp_count_sndbytes(struct inpcb *, u_int32_t);
+extern void inp_incr_sndbytes_unsent(struct socket *, int32_t);
+extern void inp_decr_sndbytes_unsent(struct socket *, int32_t);
+extern int32_t inp_get_sndbytes_allunsent(struct socket *, u_int32_t);
+extern void inp_decr_sndbytes_allunsent(struct socket *, u_int32_t);
+#endif /* BSD_KERNEL_PRIVATE */
+#ifdef KERNEL_PRIVATE
+/* exported for PPP */
+extern void inp_clear_INP_INADDR_ANY(struct socket *);