-/* $OpenBSD: uipc_usrreq.c,v 1.169 2022/08/20 23:48:57 mvs Exp $ */
+/* $OpenBSD: uipc_usrreq.c,v 1.170 2022/08/21 17:30:21 mvs Exp $ */
/* $NetBSD: uipc_usrreq.c,v 1.18 1996/02/09 19:00:50 christos Exp $ */
/*
.pru_attach = uipc_attach,
.pru_detach = uipc_detach,
.pru_bind = uipc_bind,
+ .pru_listen = uipc_listen,
};
void
switch (req) {
- case PRU_LISTEN:
- if (unp->unp_vnode == NULL)
- error = EINVAL;
- break;
-
case PRU_CONNECT:
error = unp_connect(so, nam, p);
break;
return unp_bind(unp, nam, p);
}
+int
+uipc_listen(struct socket *so)
+{
+ struct unpcb *unp = sotounpcb(so);
+
+ if (unp->unp_vnode == NULL)
+ return (EINVAL);
+ return (0);
+}
+
int
uipc_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
size_t newlen)
-/* $OpenBSD: pfkeyv2.c,v 1.236 2022/08/20 23:48:57 mvs Exp $ */
+/* $OpenBSD: pfkeyv2.c,v 1.237 2022/08/21 17:30:21 mvs Exp $ */
/*
* @(#)COPYRIGHT 1.1 (NRL) 17 January 1995
/* no connect, bind, accept. Socket is connected from the start */
case PRU_CONNECT:
case PRU_CONNECT2:
- case PRU_LISTEN:
case PRU_ACCEPT:
error = EOPNOTSUPP;
break;
-/* $OpenBSD: rtsock.c,v 1.336 2022/08/20 23:48:58 mvs Exp $ */
+/* $OpenBSD: rtsock.c,v 1.337 2022/08/21 17:30:21 mvs Exp $ */
/* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */
/*
/* no connect, bind, accept. Socket is connected from the start */
case PRU_CONNECT:
case PRU_CONNECT2:
- case PRU_LISTEN:
case PRU_ACCEPT:
error = EOPNOTSUPP;
break;
-/* $OpenBSD: ip_divert.c,v 1.71 2022/08/21 11:44:54 bluhm Exp $ */
+/* $OpenBSD: ip_divert.c,v 1.72 2022/08/21 17:30:21 mvs Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
case PRU_SENSE:
break;
- case PRU_LISTEN:
case PRU_CONNECT:
case PRU_CONNECT2:
case PRU_ACCEPT:
-/* $OpenBSD: raw_ip.c,v 1.131 2022/08/20 23:48:58 mvs Exp $ */
+/* $OpenBSD: raw_ip.c,v 1.132 2022/08/21 17:30:21 mvs Exp $ */
/* $NetBSD: raw_ip.c,v 1.25 1996/02/18 18:58:33 christos Exp $ */
/*
/*
* Not supported.
*/
- case PRU_LISTEN:
case PRU_ACCEPT:
case PRU_SENDOOB:
case PRU_RCVD:
-/* $OpenBSD: tcp_usrreq.c,v 1.189 2022/08/20 23:48:58 mvs Exp $ */
+/* $OpenBSD: tcp_usrreq.c,v 1.190 2022/08/21 17:30:21 mvs Exp $ */
/* $NetBSD: tcp_usrreq.c,v 1.20 1996/02/13 23:44:16 christos Exp $ */
/*
.pru_attach = tcp_attach,
.pru_detach = tcp_detach,
.pru_bind = tcp_bind,
+ .pru_listen = tcp_listen,
};
static int pr_slowhz = PR_SLOWHZ;
switch (req) {
- /*
- * Prepare to accept connections.
- */
- case PRU_LISTEN:
- if (inp->inp_lport == 0)
- error = in_pcbbind(inp, NULL, p);
- /* If the in_pcbbind() above is called, the tp->pf
- should still be whatever it was before. */
- if (error == 0)
- tp->t_state = TCPS_LISTEN;
- break;
-
/*
* Initiate connection to peer.
* Create a template for use in transmissions on this connection.
return (error);
}
+/*
+ * Prepare to accept connections.
+ */
+int
+tcp_listen(struct socket *so)
+{
+ struct inpcb *inp;
+ struct tcpcb *tp, *otp = NULL;
+ int error;
+ short ostate;
+
+ soassertlocked(so);
+
+ if ((error = tcp_sogetpcb(so, &inp, &tp)))
+ return (error);
+
+ if (so->so_options & SO_DEBUG) {
+ otp = tp;
+ ostate = tp->t_state;
+ }
+
+ if (inp->inp_lport == 0)
+ if ((error = in_pcbbind(inp, NULL, curproc)))
+ goto out;
+
+ /*
+ * If the in_pcbbind() above is called, the tp->pf
+ * should still be whatever it was before.
+ */
+ tp->t_state = TCPS_LISTEN;
+
+out:
+ if (otp)
+ tcp_trace(TA_USER, ostate, tp, otp, NULL, PRU_LISTEN, 0);
+ return (error);
+}
+
/*
* Initiate (or continue) disconnect.
* If embryonic state, just send reset (once).
-/* $OpenBSD: tcp_var.h,v 1.142 2022/08/20 23:48:58 mvs Exp $ */
+/* $OpenBSD: tcp_var.h,v 1.143 2022/08/21 17:30:21 mvs Exp $ */
/* $NetBSD: tcp_var.h,v 1.17 1996/02/13 23:44:24 christos Exp $ */
/*
int tcp_attach(struct socket *, int);
int tcp_detach(struct socket *);
int tcp_bind(struct socket *, struct mbuf *, struct proc *);
+int tcp_listen(struct socket *);
void tcp_xmit_timer(struct tcpcb *, int);
void tcpdropoldhalfopen(struct tcpcb *, u_int16_t);
void tcp_sack_option(struct tcpcb *,struct tcphdr *,u_char *,int);
-/* $OpenBSD: udp_usrreq.c,v 1.283 2022/08/20 23:48:58 mvs Exp $ */
+/* $OpenBSD: udp_usrreq.c,v 1.284 2022/08/21 17:30:21 mvs Exp $ */
/* $NetBSD: udp_usrreq.c,v 1.28 1996/03/16 23:54:03 christos Exp $ */
/*
*/
switch (req) {
- case PRU_LISTEN:
- error = EOPNOTSUPP;
- break;
-
case PRU_CONNECT:
#ifdef INET6
if (inp->inp_flags & INP_IPV6) {
-/* $OpenBSD: ip6_divert.c,v 1.70 2022/08/21 11:44:54 bluhm Exp $ */
+/* $OpenBSD: ip6_divert.c,v 1.71 2022/08/21 17:30:21 mvs Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
case PRU_SENSE:
break;
- case PRU_LISTEN:
case PRU_CONNECT:
case PRU_CONNECT2:
case PRU_ACCEPT:
-/* $OpenBSD: raw_ip6.c,v 1.151 2022/08/20 23:48:58 mvs Exp $ */
+/* $OpenBSD: raw_ip6.c,v 1.152 2022/08/21 17:30:21 mvs Exp $ */
/* $KAME: raw_ip6.c,v 1.69 2001/03/04 15:55:44 itojun Exp $ */
/*
/*
* Not supported.
*/
- case PRU_LISTEN:
case PRU_ACCEPT:
case PRU_SENDOOB:
case PRU_RCVD:
-/* $OpenBSD: protosw.h,v 1.38 2022/08/20 23:48:58 mvs Exp $ */
+/* $OpenBSD: protosw.h,v 1.39 2022/08/21 17:30:21 mvs Exp $ */
/* $NetBSD: protosw.h,v 1.10 1996/04/09 20:55:32 cgd Exp $ */
/*-
int (*pru_attach)(struct socket *, int);
int (*pru_detach)(struct socket *);
int (*pru_bind)(struct socket *, struct mbuf *, struct proc *);
+ int (*pru_listen)(struct socket *);
};
struct protosw {
static inline int
pru_listen(struct socket *so)
{
- return (*so->so_proto->pr_usrreqs->pru_usrreq)(so,
- PRU_LISTEN, NULL, NULL, NULL, curproc);
+ if (so->so_proto->pr_usrreqs->pru_listen)
+ return (*so->so_proto->pr_usrreqs->pru_listen)(so);
+ return (EOPNOTSUPP);
}
static inline int
-/* $OpenBSD: unpcb.h,v 1.28 2022/08/20 23:48:58 mvs Exp $ */
+/* $OpenBSD: unpcb.h,v 1.29 2022/08/21 17:30:21 mvs Exp $ */
/* $NetBSD: unpcb.h,v 1.6 1994/06/29 06:46:08 cgd Exp $ */
/*
int uipc_attach(struct socket *, int);
int uipc_detach(struct socket *);
int uipc_bind(struct socket *, struct mbuf *, struct proc *);
+int uipc_listen(struct socket *);
void unp_init(void);
int unp_bind(struct unpcb *, struct mbuf *, struct proc *);