-/* $OpenBSD: uipc_usrreq.c,v 1.181 2022/08/31 21:23:02 mvs Exp $ */
+/* $OpenBSD: uipc_usrreq.c,v 1.182 2022/09/01 18:21:22 mvs Exp $ */
/* $NetBSD: uipc_usrreq.c,v 1.18 1996/02/09 19:00:50 christos Exp $ */
/*
.pru_send = uipc_send,
.pru_abort = uipc_abort,
.pru_sense = uipc_sense,
+ .pru_connect2 = uipc_connect2,
};
void
struct mbuf *control, struct proc *p)
{
struct unpcb *unp = sotounpcb(so);
- struct unpcb *unp2;
struct socket *so2;
int error = 0;
switch (req) {
- case PRU_CONNECT2:
- error = unp_connect2(so, (struct socket *)nam);
- if (!error) {
- unp->unp_connid.uid = p->p_ucred->cr_uid;
- unp->unp_connid.gid = p->p_ucred->cr_gid;
- unp->unp_connid.pid = p->p_p->ps_pid;
- unp->unp_flags |= UNP_FEIDS;
- unp2 = sotounpcb((struct socket *)nam);
- unp2->unp_connid.uid = p->p_ucred->cr_uid;
- unp2->unp_connid.gid = p->p_ucred->cr_gid;
- unp2->unp_connid.pid = p->p_p->ps_pid;
- unp2->unp_flags |= UNP_FEIDS;
- }
- break;
-
case PRU_SOCKADDR:
uipc_setaddr(unp, nam);
break;
return (0);
}
+int
+uipc_connect2(struct socket *so, struct socket *so2)
+{
+ struct unpcb *unp = sotounpcb(so), *unp2;
+ int error;
+
+ if ((error = unp_connect2(so, so2)))
+ return (error);
+
+ unp->unp_connid.uid = curproc->p_ucred->cr_uid;
+ unp->unp_connid.gid = curproc->p_ucred->cr_gid;
+ unp->unp_connid.pid = curproc->p_p->ps_pid;
+ unp->unp_flags |= UNP_FEIDS;
+ unp2 = sotounpcb(so2);
+ unp2->unp_connid.uid = curproc->p_ucred->cr_uid;
+ unp2->unp_connid.gid = curproc->p_ucred->cr_gid;
+ unp2->unp_connid.pid = curproc->p_p->ps_pid;
+ unp2->unp_flags |= UNP_FEIDS;
+
+ 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.248 2022/08/31 21:23:02 mvs Exp $ */
+/* $OpenBSD: pfkeyv2.c,v 1.249 2022/09/01 18:21:23 mvs Exp $ */
/*
* @(#)COPYRIGHT 1.1 (NRL) 17 January 1995
}
switch (req) {
- /* no connect, bind, accept. Socket is connected from the start */
- case PRU_CONNECT2:
- error = EOPNOTSUPP;
- break;
-
/* minimal support, just implement a fake peer address */
case PRU_SOCKADDR:
error = EINVAL;
-/* $OpenBSD: rtsock.c,v 1.349 2022/08/31 21:23:02 mvs Exp $ */
+/* $OpenBSD: rtsock.c,v 1.350 2022/09/01 18:21:23 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:
- error = EOPNOTSUPP;
- break;
-
/* minimal support, just implement a fake peer address */
case PRU_SOCKADDR:
error = EINVAL;
-/* $OpenBSD: ip_divert.c,v 1.82 2022/08/31 21:23:02 mvs Exp $ */
+/* $OpenBSD: ip_divert.c,v 1.83 2022/09/01 18:21:23 mvs Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
in_setpeeraddr(inp, addr);
break;
- case PRU_CONNECT2:
case PRU_FASTTIMO:
case PRU_SLOWTIMO:
case PRU_PROTORCV:
-/* $OpenBSD: raw_ip.c,v 1.143 2022/08/31 21:23:02 mvs Exp $ */
+/* $OpenBSD: raw_ip.c,v 1.144 2022/09/01 18:21:23 mvs Exp $ */
/* $NetBSD: raw_ip.c,v 1.25 1996/02/18 18:58:33 christos Exp $ */
/*
switch (req) {
- case PRU_CONNECT2:
- error = EOPNOTSUPP;
- break;
-
case PRU_SOCKADDR:
in_setsockaddr(inp, nam);
break;
-/* $OpenBSD: tcp_usrreq.c,v 1.202 2022/08/31 21:23:02 mvs Exp $ */
+/* $OpenBSD: tcp_usrreq.c,v 1.203 2022/09/01 18:21:23 mvs Exp $ */
/* $NetBSD: tcp_usrreq.c,v 1.20 1996/02/13 23:44:16 christos Exp $ */
/*
switch (req) {
- /*
- * Create a TCP connection between two sockets.
- */
- case PRU_CONNECT2:
- error = EOPNOTSUPP;
- break;
-
case PRU_SOCKADDR:
#ifdef INET6
if (inp->inp_flags & INP_IPV6)
-/* $OpenBSD: udp_usrreq.c,v 1.297 2022/08/31 21:23:02 mvs Exp $ */
+/* $OpenBSD: udp_usrreq.c,v 1.298 2022/09/01 18:21:23 mvs Exp $ */
/* $NetBSD: udp_usrreq.c,v 1.28 1996/03/16 23:54:03 christos Exp $ */
/*
*/
switch (req) {
- case PRU_CONNECT2:
- error = EOPNOTSUPP;
- break;
-
case PRU_SOCKADDR:
#ifdef INET6
if (inp->inp_flags & INP_IPV6)
-/* $OpenBSD: ip6_divert.c,v 1.81 2022/08/31 21:23:02 mvs Exp $ */
+/* $OpenBSD: ip6_divert.c,v 1.82 2022/09/01 18:21:23 mvs Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
in6_setpeeraddr(inp, addr);
break;
- case PRU_CONNECT2:
case PRU_FASTTIMO:
case PRU_SLOWTIMO:
case PRU_PROTORCV:
-/* $OpenBSD: raw_ip6.c,v 1.164 2022/08/31 21:23:02 mvs Exp $ */
+/* $OpenBSD: raw_ip6.c,v 1.165 2022/09/01 18:21:23 mvs Exp $ */
/* $KAME: raw_ip6.c,v 1.69 2001/03/04 15:55:44 itojun Exp $ */
/*
}
switch (req) {
- case PRU_CONNECT2:
- error = EOPNOTSUPP;
- break;
-
case PRU_SOCKADDR:
in6_setsockaddr(in6p, nam);
break;
-/* $OpenBSD: protosw.h,v 1.50 2022/08/31 21:23:02 mvs Exp $ */
+/* $OpenBSD: protosw.h,v 1.51 2022/09/01 18:21:23 mvs Exp $ */
/* $NetBSD: protosw.h,v 1.10 1996/04/09 20:55:32 cgd Exp $ */
/*-
int (*pru_rcvoob)(struct socket *, struct mbuf *, int);
int (*pru_sendoob)(struct socket *, struct mbuf *, struct mbuf *,
struct mbuf *);
+ int (*pru_connect2)(struct socket *, struct socket *);
};
struct protosw {
static inline int
pru_connect2(struct socket *so1, struct socket *so2)
{
- return (*so1->so_proto->pr_usrreqs->pru_usrreq)(so1,
- PRU_CONNECT2, NULL, (struct mbuf *)so2, NULL, curproc);
+ if (so1->so_proto->pr_usrreqs->pru_connect2)
+ return (*so1->so_proto->pr_usrreqs->pru_connect2)(so1, so2);
+ return (EOPNOTSUPP);
}
#endif
-/* $OpenBSD: unpcb.h,v 1.37 2022/08/28 21:35:12 mvs Exp $ */
+/* $OpenBSD: unpcb.h,v 1.38 2022/09/01 18:21:23 mvs Exp $ */
/* $NetBSD: unpcb.h,v 1.6 1994/06/29 06:46:08 cgd Exp $ */
/*
struct mbuf *);
int uipc_abort(struct socket *);
int uipc_sense(struct socket *, struct stat *);
+int uipc_connect2(struct socket *, struct socket *);
void unp_init(void);
int unp_bind(struct unpcb *, struct mbuf *, struct proc *);