-/* $OpenBSD: uipc_usrreq.c,v 1.183 2022/09/02 13:12:31 mvs Exp $ */
+/* $OpenBSD: uipc_usrreq.c,v 1.184 2022/09/03 18:48:49 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_sockaddr = uipc_sockaddr,
.pru_connect2 = uipc_connect2,
};
switch (req) {
- case PRU_SOCKADDR:
- uipc_setaddr(unp, nam);
- break;
-
case PRU_PEERADDR:
so2 = unp_solock_peer(so);
uipc_setaddr(unp->unp_conn, nam);
return (0);
}
+int
+uipc_sockaddr(struct socket *so, struct mbuf *nam)
+{
+ struct unpcb *unp = sotounpcb(so);
+
+ uipc_setaddr(unp, nam);
+ return (0);
+}
+
int
uipc_connect2(struct socket *so, struct socket *so2)
{
-/* $OpenBSD: pfkeyv2.c,v 1.250 2022/09/02 13:12:32 mvs Exp $ */
+/* $OpenBSD: pfkeyv2.c,v 1.251 2022/09/03 18:48:50 mvs Exp $ */
/*
* @(#)COPYRIGHT 1.1 (NRL) 17 January 1995
int pfkeyv2_send(struct socket *, struct mbuf *, struct mbuf *,
struct mbuf *);
int pfkeyv2_abort(struct socket *);
+int pfkeyv2_sockaddr(struct socket *, struct mbuf *);
int pfkeyv2_usrreq(struct socket *, int, struct mbuf *, struct mbuf *,
struct mbuf *, struct proc *);
int pfkeyv2_output(struct mbuf *, struct socket *);
.pru_shutdown = pfkeyv2_shutdown,
.pru_send = pfkeyv2_send,
.pru_abort = pfkeyv2_abort,
+ .pru_sockaddr = pfkeyv2_sockaddr,
};
const struct protosw pfkeysw[] = {
return (0);
}
+int
+pfkeyv2_sockaddr(struct socket *so, struct mbuf *nam)
+{
+ return (EINVAL);
+}
+
int
pfkeyv2_usrreq(struct socket *so, int req, struct mbuf *m,
struct mbuf *nam, struct mbuf *control, struct proc *p)
switch (req) {
/* minimal support, just implement a fake peer address */
- case PRU_SOCKADDR:
- error = EINVAL;
- break;
case PRU_PEERADDR:
bcopy(&pfkey_addr, mtod(nam, caddr_t), pfkey_addr.sa_len);
nam->m_len = pfkey_addr.sa_len;
-/* $OpenBSD: rtsock.c,v 1.351 2022/09/02 13:12:32 mvs Exp $ */
+/* $OpenBSD: rtsock.c,v 1.352 2022/09/03 18:48:50 mvs Exp $ */
/* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */
/*
int route_send(struct socket *, struct mbuf *, struct mbuf *,
struct mbuf *);
int route_abort(struct socket *);
+int route_sockaddr(struct socket *, struct mbuf *);
void route_input(struct mbuf *m0, struct socket *, sa_family_t);
int route_arp_conflict(struct rtentry *, struct rt_addrinfo *);
int route_cleargateway(struct rtentry *, void *, unsigned int);
switch (req) {
/* minimal support, just implement a fake peer address */
- case PRU_SOCKADDR:
- error = EINVAL;
- break;
case PRU_PEERADDR:
bcopy(&route_src, mtod(nam, caddr_t), route_src.sa_len);
nam->m_len = route_src.sa_len;
return (0);
}
+int
+route_sockaddr(struct socket *so, struct mbuf *nam)
+{
+ return (EINVAL);
+}
+
int
route_ctloutput(int op, struct socket *so, int level, int optname,
struct mbuf *m)
.pru_rcvd = route_rcvd,
.pru_send = route_send,
.pru_abort = route_abort,
+ .pru_sockaddr = route_sockaddr,
};
const struct protosw routesw[] = {
-/* $OpenBSD: in_pcb.c,v 1.273 2022/08/30 11:53:04 bluhm Exp $ */
+/* $OpenBSD: in_pcb.c,v 1.274 2022/09/03 18:48:50 mvs Exp $ */
/* $NetBSD: in_pcb.c,v 1.25 1996/02/13 23:41:53 christos Exp $ */
/*
sin->sin_addr = inp->inp_faddr;
}
+int
+in_sockaddr(struct socket *so, struct mbuf *nam)
+{
+ struct inpcb *inp;
+
+ inp = sotoinpcb(so);
+ in_setsockaddr(inp, nam);
+
+ return (0);
+}
+
/*
* Pass some notification to all connections of a protocol
* associated with address dst. The "usual action" will be
-/* $OpenBSD: in_pcb.h,v 1.132 2022/08/30 11:53:04 bluhm Exp $ */
+/* $OpenBSD: in_pcb.h,v 1.133 2022/09/03 18:48:50 mvs Exp $ */
/* $NetBSD: in_pcb.h,v 1.14 1996/02/13 23:42:00 christos Exp $ */
/*
int in6_pcbconnect(struct inpcb *, struct mbuf *);
void in6_setsockaddr(struct inpcb *, struct mbuf *);
void in6_setpeeraddr(struct inpcb *, struct mbuf *);
+int in6_sockaddr(struct socket *, struct mbuf *);
#endif /* INET6 */
void in_pcbinit(struct inpcbtable *, int);
struct inpcb *
void in_rtchange(struct inpcb *, int);
void in_setpeeraddr(struct inpcb *, struct mbuf *);
void in_setsockaddr(struct inpcb *, struct mbuf *);
+int in_sockaddr(struct socket *, struct mbuf *);
int in_baddynamic(u_int16_t, u_int16_t);
int in_rootonly(u_int16_t, u_int16_t);
int in_pcbselsrc(struct in_addr *, struct sockaddr_in *, struct inpcb *);
-/* $OpenBSD: ip_divert.c,v 1.84 2022/09/02 13:12:32 mvs Exp $ */
+/* $OpenBSD: ip_divert.c,v 1.85 2022/09/03 18:48:50 mvs Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
.pru_send = divert_send,
.pru_abort = divert_abort,
.pru_control = in_control,
+ .pru_sockaddr = in_sockaddr,
};
int divbhashsize = DIVERTHASHSIZE;
}
switch (req) {
- case PRU_SOCKADDR:
- in_setsockaddr(inp, addr);
- break;
-
case PRU_PEERADDR:
in_setpeeraddr(inp, addr);
break;
-/* $OpenBSD: ip_gre.c,v 1.82 2022/09/02 13:12:32 mvs Exp $ */
+/* $OpenBSD: ip_gre.c,v 1.83 2022/09/03 18:48:50 mvs Exp $ */
/* $NetBSD: ip_gre.c,v 1.9 1999/10/25 19:18:11 drochner Exp $ */
/*
.pru_send = gre_send,
.pru_abort = rip_abort,
.pru_control = in_control,
+ .pru_sockaddr = in_sockaddr,
};
int
-/* $OpenBSD: raw_ip.c,v 1.145 2022/09/02 13:12:32 mvs Exp $ */
+/* $OpenBSD: raw_ip.c,v 1.146 2022/09/03 18:48:50 mvs Exp $ */
/* $NetBSD: raw_ip.c,v 1.25 1996/02/18 18:58:33 christos Exp $ */
/*
.pru_send = rip_send,
.pru_abort = rip_abort,
.pru_control = in_control,
+ .pru_sockaddr = in_sockaddr,
};
/*
switch (req) {
- case PRU_SOCKADDR:
- in_setsockaddr(inp, nam);
- break;
-
case PRU_PEERADDR:
in_setpeeraddr(inp, nam);
break;
-/* $OpenBSD: tcp_usrreq.c,v 1.204 2022/09/02 13:12:32 mvs Exp $ */
+/* $OpenBSD: tcp_usrreq.c,v 1.205 2022/09/03 18:48:50 mvs Exp $ */
/* $NetBSD: tcp_usrreq.c,v 1.20 1996/02/13 23:44:16 christos Exp $ */
/*
.pru_rcvoob = tcp_rcvoob,
.pru_sendoob = tcp_sendoob,
.pru_control = in_control,
+ .pru_sockaddr = tcp_sockaddr,
};
#ifdef INET6
.pru_rcvoob = tcp_rcvoob,
.pru_sendoob = tcp_sendoob,
.pru_control = in6_control,
+ .pru_sockaddr = tcp_sockaddr,
};
#endif
switch (req) {
- case PRU_SOCKADDR:
-#ifdef INET6
- if (inp->inp_flags & INP_IPV6)
- in6_setsockaddr(inp, nam);
- else
-#endif
- in_setsockaddr(inp, nam);
- break;
-
case PRU_PEERADDR:
#ifdef INET6
if (inp->inp_flags & INP_IPV6)
return (error);
}
+int
+tcp_sockaddr(struct socket *so, struct mbuf *nam)
+{
+ struct inpcb *inp;
+ struct tcpcb *tp;
+ int error;
+
+ soassertlocked(so);
+
+ if ((error = tcp_sogetpcb(so, &inp, &tp)))
+ return (error);
+
+#ifdef INET6
+ if (inp->inp_flags & INP_IPV6)
+ in6_setsockaddr(inp, nam);
+ else
+#endif
+ in_setsockaddr(inp, nam);
+
+ if (so->so_options & SO_DEBUG)
+ tcp_trace(TA_USER, tp->t_state, tp, tp, NULL,
+ PRU_SOCKADDR, 0);
+ return (0);
+}
/*
* Initiate (or continue) disconnect.
-/* $OpenBSD: tcp_var.h,v 1.154 2022/09/02 13:12:32 mvs Exp $ */
+/* $OpenBSD: tcp_var.h,v 1.155 2022/09/03 18:48:50 mvs Exp $ */
/* $NetBSD: tcp_var.h,v 1.17 1996/02/13 23:44:24 christos Exp $ */
/*
int tcp_send(struct socket *, struct mbuf *, struct mbuf *,
struct mbuf *);
int tcp_abort(struct socket *);
+int tcp_sockaddr(struct socket *, struct mbuf *);
int tcp_sense(struct socket *, struct stat *);
int tcp_rcvoob(struct socket *, struct mbuf *, int);
int tcp_sendoob(struct socket *, struct mbuf *, struct mbuf *,
-/* $OpenBSD: udp_usrreq.c,v 1.299 2022/09/02 13:12:32 mvs Exp $ */
+/* $OpenBSD: udp_usrreq.c,v 1.300 2022/09/03 18:48:50 mvs Exp $ */
/* $NetBSD: udp_usrreq.c,v 1.28 1996/03/16 23:54:03 christos Exp $ */
/*
.pru_send = udp_send,
.pru_abort = udp_abort,
.pru_control = in_control,
+ .pru_sockaddr = in_sockaddr,
};
#ifdef INET6
.pru_send = udp_send,
.pru_abort = udp_abort,
.pru_control = in6_control,
+ .pru_sockaddr = in6_sockaddr,
};
#endif
*/
switch (req) {
- case PRU_SOCKADDR:
-#ifdef INET6
- if (inp->inp_flags & INP_IPV6)
- in6_setsockaddr(inp, addr);
- else
-#endif /* INET6 */
- in_setsockaddr(inp, addr);
- break;
-
case PRU_PEERADDR:
#ifdef INET6
if (inp->inp_flags & INP_IPV6)
-/* $OpenBSD: in6_pcb.c,v 1.121 2022/08/30 11:53:04 bluhm Exp $ */
+/* $OpenBSD: in6_pcb.c,v 1.122 2022/09/03 18:48:50 mvs Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
in6_recoverscope(sin6, &inp->inp_faddr6);
}
+int
+in6_sockaddr(struct socket *so, struct mbuf *nam)
+{
+ struct inpcb *in6p;
+
+ in6p = sotoinpcb(so);
+ in6_setsockaddr(in6p, nam);
+
+ return (0);
+}
+
/*
* Pass some notification to all connections of a protocol
* associated with address dst. The local address and/or port numbers
-/* $OpenBSD: ip6_divert.c,v 1.83 2022/09/02 13:12:32 mvs Exp $ */
+/* $OpenBSD: ip6_divert.c,v 1.84 2022/09/03 18:48:50 mvs Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
.pru_send = divert6_send,
.pru_abort = divert6_abort,
.pru_control = in6_control,
+ .pru_sockaddr = in6_sockaddr,
};
int divb6hashsize = DIVERTHASHSIZE;
}
switch (req) {
- case PRU_SOCKADDR:
- in6_setsockaddr(inp, addr);
- break;
-
case PRU_PEERADDR:
in6_setpeeraddr(inp, addr);
break;
-/* $OpenBSD: raw_ip6.c,v 1.166 2022/09/02 13:12:32 mvs Exp $ */
+/* $OpenBSD: raw_ip6.c,v 1.167 2022/09/03 18:48:50 mvs Exp $ */
/* $KAME: raw_ip6.c,v 1.69 2001/03/04 15:55:44 itojun Exp $ */
/*
.pru_send = rip6_send,
.pru_abort = rip6_abort,
.pru_control = in6_control,
+ .pru_sockaddr = in6_sockaddr,
};
/*
}
switch (req) {
- case PRU_SOCKADDR:
- in6_setsockaddr(in6p, nam);
- break;
-
case PRU_PEERADDR:
in6_setpeeraddr(in6p, nam);
break;
-/* $OpenBSD: protosw.h,v 1.52 2022/09/02 13:12:32 mvs Exp $ */
+/* $OpenBSD: protosw.h,v 1.53 2022/09/03 18:48:50 mvs Exp $ */
/* $NetBSD: protosw.h,v 1.10 1996/04/09 20:55:32 cgd Exp $ */
/*-
int (*pru_sendoob)(struct socket *, struct mbuf *, struct mbuf *,
struct mbuf *);
int (*pru_connect2)(struct socket *, struct socket *);
+ int (*pru_sockaddr)(struct socket *, struct mbuf *);
};
struct protosw {
static inline int
pru_sockaddr(struct socket *so, struct mbuf *addr)
{
- return (*so->so_proto->pr_usrreqs->pru_usrreq)(so,
- PRU_SOCKADDR, NULL, addr, NULL, curproc);
+ return (*so->so_proto->pr_usrreqs->pru_sockaddr)(so, addr);
}
static inline int
-/* $OpenBSD: unpcb.h,v 1.38 2022/09/01 18:21:23 mvs Exp $ */
+/* $OpenBSD: unpcb.h,v 1.39 2022/09/03 18:48:50 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_sockaddr(struct socket *, struct mbuf *);
int uipc_connect2(struct socket *, struct socket *);
void unp_init(void);