-/* $OpenBSD: uipc_usrreq.c,v 1.171 2022/08/21 22:45:55 mvs Exp $ */
+/* $OpenBSD: uipc_usrreq.c,v 1.172 2022/08/22 08:08:46 mvs Exp $ */
/* $NetBSD: uipc_usrreq.c,v 1.18 1996/02/09 19:00:50 christos Exp $ */
/*
.pru_bind = uipc_bind,
.pru_listen = uipc_listen,
.pru_connect = uipc_connect,
+ .pru_accept = uipc_accept,
};
void
unp_disconnect(unp);
break;
- case PRU_ACCEPT:
- /*
- * Pass back name of connected socket,
- * if it was bound and we are still connected
- * (our peer may have closed already!).
- */
- so2 = unp_solock_peer(so);
- uipc_setaddr(unp->unp_conn, nam);
- if (so2 != NULL && so2 != so)
- sounlock(so2);
- break;
-
case PRU_SHUTDOWN:
socantsendmore(so);
unp_shutdown(unp);
return unp_connect(so, nam, curproc);
}
+int
+uipc_accept(struct socket *so, struct mbuf *nam)
+{
+ struct socket *so2;
+ struct unpcb *unp = sotounpcb(so);
+
+ /*
+ * Pass back name of connected socket, if it was bound and
+ * we are still connected (our peer may have closed already!).
+ */
+ so2 = unp_solock_peer(so);
+ uipc_setaddr(unp->unp_conn, nam);
+
+ if (so2 != NULL && so2 != so)
+ sounlock(so2);
+ 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.238 2022/08/21 22:45:55 mvs Exp $ */
+/* $OpenBSD: pfkeyv2.c,v 1.239 2022/08/22 08:08:46 mvs Exp $ */
/*
* @(#)COPYRIGHT 1.1 (NRL) 17 January 1995
switch (req) {
/* no connect, bind, accept. Socket is connected from the start */
case PRU_CONNECT2:
- case PRU_ACCEPT:
error = EOPNOTSUPP;
break;
-/* $OpenBSD: rtsock.c,v 1.338 2022/08/21 22:45:55 mvs Exp $ */
+/* $OpenBSD: rtsock.c,v 1.339 2022/08/22 08:08:46 mvs Exp $ */
/* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */
/*
switch (req) {
/* no connect, bind, accept. Socket is connected from the start */
case PRU_CONNECT2:
- case PRU_ACCEPT:
error = EOPNOTSUPP;
break;
-/* $OpenBSD: ip_divert.c,v 1.73 2022/08/21 22:45:55 mvs Exp $ */
+/* $OpenBSD: ip_divert.c,v 1.74 2022/08/22 08:08:46 mvs Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
break;
case PRU_CONNECT2:
- case PRU_ACCEPT:
case PRU_DISCONNECT:
case PRU_SENDOOB:
case PRU_FASTTIMO:
-/* $OpenBSD: raw_ip.c,v 1.133 2022/08/21 22:45:55 mvs Exp $ */
+/* $OpenBSD: raw_ip.c,v 1.134 2022/08/22 08:08:46 mvs Exp $ */
/* $NetBSD: raw_ip.c,v 1.25 1996/02/18 18:58:33 christos Exp $ */
/*
/*
* Not supported.
*/
- case PRU_ACCEPT:
case PRU_SENDOOB:
case PRU_RCVD:
case PRU_RCVOOB:
-/* $OpenBSD: tcp_usrreq.c,v 1.191 2022/08/21 22:45:55 mvs Exp $ */
+/* $OpenBSD: tcp_usrreq.c,v 1.192 2022/08/22 08:08:46 mvs Exp $ */
/* $NetBSD: tcp_usrreq.c,v 1.20 1996/02/13 23:44:16 christos Exp $ */
/*
.pru_bind = tcp_bind,
.pru_listen = tcp_listen,
.pru_connect = tcp_connect,
+ .pru_accept = tcp_accept,
};
static int pr_slowhz = PR_SLOWHZ;
tp = tcp_disconnect(tp);
break;
- /*
- * Accept a connection. Essentially all the work is
- * done at higher levels; just return the address
- * of the peer, storing through addr.
- */
- case PRU_ACCEPT:
-#ifdef INET6
- if (inp->inp_flags & INP_IPV6)
- in6_setpeeraddr(inp, nam);
- else
-#endif
- in_setpeeraddr(inp, nam);
- break;
-
/*
* Mark the connection as being incapable of further output.
*/
return (error);
}
+/*
+ * Accept a connection. Essentially all the work is done at higher
+ * levels; just return the address of the peer, storing through addr.
+ */
+int
+tcp_accept(struct socket *so, struct mbuf *nam)
+{
+ struct inpcb *inp;
+ struct tcpcb *tp;
+ int error;
+ short ostate;
+
+ soassertlocked(so);
+
+ if ((error = tcp_sogetpcb(so, &inp, &tp)))
+ return (error);
+
+ if (so->so_options & SO_DEBUG)
+ ostate = tp->t_state;
+
+#ifdef INET6
+ if (inp->inp_flags & INP_IPV6)
+ in6_setpeeraddr(inp, nam);
+ else
+#endif
+ in_setpeeraddr(inp, nam);
+
+ if (so->so_options & SO_DEBUG)
+ tcp_trace(TA_USER, ostate, tp, tp, NULL, PRU_ACCEPT, 0);
+ return (error);
+}
/*
* Initiate (or continue) disconnect.
-/* $OpenBSD: tcp_var.h,v 1.144 2022/08/21 22:45:55 mvs Exp $ */
+/* $OpenBSD: tcp_var.h,v 1.145 2022/08/22 08:08:46 mvs Exp $ */
/* $NetBSD: tcp_var.h,v 1.17 1996/02/13 23:44:24 christos Exp $ */
/*
int tcp_bind(struct socket *, struct mbuf *, struct proc *);
int tcp_listen(struct socket *);
int tcp_connect(struct socket *, struct mbuf *);
+int tcp_accept(struct socket *, struct mbuf *);
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.285 2022/08/21 22:45:55 mvs Exp $ */
+/* $OpenBSD: udp_usrreq.c,v 1.286 2022/08/22 08:08:46 mvs Exp $ */
/* $NetBSD: udp_usrreq.c,v 1.28 1996/03/16 23:54:03 christos Exp $ */
/*
error = EOPNOTSUPP;
break;
- case PRU_ACCEPT:
- error = EOPNOTSUPP;
- break;
-
case PRU_DISCONNECT:
#ifdef INET6
if (inp->inp_flags & INP_IPV6) {
-/* $OpenBSD: ip6_divert.c,v 1.72 2022/08/21 22:45:55 mvs Exp $ */
+/* $OpenBSD: ip6_divert.c,v 1.73 2022/08/22 08:08:46 mvs Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
break;
case PRU_CONNECT2:
- case PRU_ACCEPT:
case PRU_DISCONNECT:
case PRU_SENDOOB:
case PRU_FASTTIMO:
-/* $OpenBSD: raw_ip6.c,v 1.153 2022/08/21 22:45:55 mvs Exp $ */
+/* $OpenBSD: raw_ip6.c,v 1.154 2022/08/22 08:08:46 mvs Exp $ */
/* $KAME: raw_ip6.c,v 1.69 2001/03/04 15:55:44 itojun Exp $ */
/*
/*
* Not supported.
*/
- case PRU_ACCEPT:
case PRU_SENDOOB:
case PRU_RCVD:
case PRU_RCVOOB:
-/* $OpenBSD: protosw.h,v 1.40 2022/08/21 22:45:55 mvs Exp $ */
+/* $OpenBSD: protosw.h,v 1.41 2022/08/22 08:08:47 mvs Exp $ */
/* $NetBSD: protosw.h,v 1.10 1996/04/09 20:55:32 cgd Exp $ */
/*-
int (*pru_bind)(struct socket *, struct mbuf *, struct proc *);
int (*pru_listen)(struct socket *);
int (*pru_connect)(struct socket *, struct mbuf *);
+ int (*pru_accept)(struct socket *, struct mbuf *);
};
struct protosw {
static inline int
pru_accept(struct socket *so, struct mbuf *nam)
{
- return (*so->so_proto->pr_usrreqs->pru_usrreq)(so,
- PRU_ACCEPT, NULL, nam, NULL, curproc);
+ if (so->so_proto->pr_usrreqs->pru_accept)
+ return (*so->so_proto->pr_usrreqs->pru_accept)(so, nam);
+ return (EOPNOTSUPP);
}
static inline int
-/* $OpenBSD: unpcb.h,v 1.30 2022/08/21 22:45:55 mvs Exp $ */
+/* $OpenBSD: unpcb.h,v 1.31 2022/08/22 08:08:47 mvs Exp $ */
/* $NetBSD: unpcb.h,v 1.6 1994/06/29 06:46:08 cgd Exp $ */
/*
int uipc_bind(struct socket *, struct mbuf *, struct proc *);
int uipc_listen(struct socket *);
int uipc_connect(struct socket *, struct mbuf *);
+int uipc_accept(struct socket *, struct mbuf *);
void unp_init(void);
int unp_bind(struct unpcb *, struct mbuf *, struct proc *);