-/* $OpenBSD: uipc_usrreq.c,v 1.184 2022/09/03 18:48:49 mvs Exp $ */
+/* $OpenBSD: uipc_usrreq.c,v 1.185 2022/09/03 22:43:38 mvs Exp $ */
/* $NetBSD: uipc_usrreq.c,v 1.18 1996/02/09 19:00:50 christos Exp $ */
/*
int unp_gcing; /* [G] GC task currently running */
const struct pr_usrreqs uipc_usrreqs = {
- .pru_usrreq = uipc_usrreq,
.pru_attach = uipc_attach,
.pru_detach = uipc_detach,
.pru_bind = uipc_bind,
.pru_abort = uipc_abort,
.pru_sense = uipc_sense,
.pru_sockaddr = uipc_sockaddr,
+ .pru_peeraddr = uipc_peeraddr,
.pru_connect2 = uipc_connect2,
};
}
}
-int
-uipc_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam,
- struct mbuf *control, struct proc *p)
-{
- struct unpcb *unp = sotounpcb(so);
- struct socket *so2;
- int error = 0;
-
- if (req != PRU_SEND && control && control->m_len) {
- error = EOPNOTSUPP;
- goto release;
- }
- if (unp == NULL) {
- error = EINVAL;
- goto release;
- }
-
- switch (req) {
-
- case PRU_PEERADDR:
- so2 = unp_solock_peer(so);
- uipc_setaddr(unp->unp_conn, nam);
- if (so2 != NULL && so2 != so)
- sounlock(so2);
- break;
-
- case PRU_SLOWTIMO:
- break;
-
- default:
- panic("uipc_usrreq");
- }
-release:
- if (req != PRU_RCVD && req != PRU_RCVOOB && req != PRU_SENSE) {
- m_freem(control);
- m_freem(m);
- }
- return (error);
-}
-
/*
* Both send and receive buffers are allocated PIPSIZ bytes of buffering
* for stream sockets, although the total for sender and receiver is
return (0);
}
+int
+uipc_peeraddr(struct socket *so, struct mbuf *nam)
+{
+ struct unpcb *unp = sotounpcb(so);
+ struct socket *so2;
+
+ so2 = unp_solock_peer(so);
+ uipc_setaddr(unp->unp_conn, nam);
+ if (so2 != NULL && so2 != so)
+ sounlock(so2);
+ return (0);
+}
+
int
uipc_connect2(struct socket *so, struct socket *so2)
{
-/* $OpenBSD: pfkeyv2.c,v 1.251 2022/09/03 18:48:50 mvs Exp $ */
+/* $OpenBSD: pfkeyv2.c,v 1.252 2022/09/03 22:43:38 mvs Exp $ */
/*
* @(#)COPYRIGHT 1.1 (NRL) 17 January 1995
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_peeraddr(struct socket *, struct mbuf *);
int pfkeyv2_output(struct mbuf *, struct socket *);
int pfkey_sendup(struct pkpcb *, struct mbuf *, int);
int pfkeyv2_sa_flush(struct tdb *, void *, int);
}
const struct pr_usrreqs pfkeyv2_usrreqs = {
- .pru_usrreq = pfkeyv2_usrreq,
.pru_attach = pfkeyv2_attach,
.pru_detach = pfkeyv2_detach,
.pru_disconnect = pfkeyv2_disconnect,
.pru_send = pfkeyv2_send,
.pru_abort = pfkeyv2_abort,
.pru_sockaddr = pfkeyv2_sockaddr,
+ .pru_peeraddr = pfkeyv2_peeraddr,
};
const struct protosw pfkeysw[] = {
}
int
-pfkeyv2_usrreq(struct socket *so, int req, struct mbuf *m,
- struct mbuf *nam, struct mbuf *control, struct proc *p)
+pfkeyv2_peeraddr(struct socket *so, struct mbuf *nam)
{
- struct pkpcb *kp;
- int error = 0;
-
- soassertlocked(so);
-
- if (control && control->m_len) {
- error = EOPNOTSUPP;
- goto release;
- }
-
- kp = sotokeycb(so);
- if (kp == NULL) {
- error = EINVAL;
- goto release;
- }
-
- switch (req) {
/* minimal support, just implement a fake peer address */
- case PRU_PEERADDR:
- bcopy(&pfkey_addr, mtod(nam, caddr_t), pfkey_addr.sa_len);
- nam->m_len = pfkey_addr.sa_len;
- break;
-
- default:
- panic("pfkeyv2_usrreq");
- }
-
- release:
- if (req != PRU_RCVD && req != PRU_RCVOOB && req != PRU_SENSE) {
- m_freem(control);
- m_freem(m);
- }
- return (error);
+ bcopy(&pfkey_addr, mtod(nam, caddr_t), pfkey_addr.sa_len);
+ nam->m_len = pfkey_addr.sa_len;
+ return (0);
}
int
-/* $OpenBSD: rtsock.c,v 1.352 2022/09/03 18:48:50 mvs Exp $ */
+/* $OpenBSD: rtsock.c,v 1.353 2022/09/03 22:43:38 mvs Exp $ */
/* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */
/*
void rcb_unref(void *, void *);
int route_output(struct mbuf *, struct socket *);
int route_ctloutput(int, struct socket *, int, int, struct mbuf *);
-int route_usrreq(struct socket *, int, struct mbuf *, struct mbuf *,
- struct mbuf *, struct proc *);
int route_disconnect(struct socket *);
int route_shutdown(struct socket *);
int route_rcvd(struct socket *);
struct mbuf *);
int route_abort(struct socket *);
int route_sockaddr(struct socket *, struct mbuf *);
+int route_peeraddr(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);
refcnt_rele_wake(&rop->rop_refcnt);
}
-int
-route_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam,
- struct mbuf *control, struct proc *p)
-{
- struct rtpcb *rop;
- int error = 0;
-
- soassertlocked(so);
-
- if (control && control->m_len) {
- error = EOPNOTSUPP;
- goto release;
- }
-
- rop = sotortpcb(so);
- if (rop == NULL) {
- error = EINVAL;
- goto release;
- }
-
- switch (req) {
- /* minimal support, just implement a fake peer address */
- case PRU_PEERADDR:
- bcopy(&route_src, mtod(nam, caddr_t), route_src.sa_len);
- nam->m_len = route_src.sa_len;
- break;
-
- default:
- panic("route_usrreq");
- }
-
- release:
- if (req != PRU_RCVD && req != PRU_RCVOOB && req != PRU_SENSE) {
- m_freem(control);
- m_freem(m);
- }
- return (error);
-}
-
int
route_attach(struct socket *so, int proto)
{
return (EINVAL);
}
+int
+route_peeraddr(struct socket *so, struct mbuf *nam)
+{
+ /* minimal support, just implement a fake peer address */
+ bcopy(&route_src, mtod(nam, caddr_t), route_src.sa_len);
+ nam->m_len = route_src.sa_len;
+ return (0);
+}
+
int
route_ctloutput(int op, struct socket *so, int level, int optname,
struct mbuf *m)
*/
const struct pr_usrreqs route_usrreqs = {
- .pru_usrreq = route_usrreq,
.pru_attach = route_attach,
.pru_detach = route_detach,
.pru_disconnect = route_disconnect,
.pru_send = route_send,
.pru_abort = route_abort,
.pru_sockaddr = route_sockaddr,
+ .pru_peeraddr = route_peeraddr,
};
const struct protosw routesw[] = {
-/* $OpenBSD: in_pcb.c,v 1.274 2022/09/03 18:48:50 mvs Exp $ */
+/* $OpenBSD: in_pcb.c,v 1.275 2022/09/03 22:43:38 mvs Exp $ */
/* $NetBSD: in_pcb.c,v 1.25 1996/02/13 23:41:53 christos Exp $ */
/*
return (0);
}
+int
+in_peeraddr(struct socket *so, struct mbuf *nam)
+{
+ struct inpcb *inp;
+
+ inp = sotoinpcb(so);
+ in_setpeeraddr(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.133 2022/09/03 18:48:50 mvs Exp $ */
+/* $OpenBSD: in_pcb.h,v 1.134 2022/09/03 22:43:38 mvs Exp $ */
/* $NetBSD: in_pcb.h,v 1.14 1996/02/13 23:42:00 christos Exp $ */
/*
void in6_setsockaddr(struct inpcb *, struct mbuf *);
void in6_setpeeraddr(struct inpcb *, struct mbuf *);
int in6_sockaddr(struct socket *, struct mbuf *);
+int in6_peeraddr(struct socket *, struct mbuf *);
#endif /* INET6 */
void in_pcbinit(struct inpcbtable *, int);
struct inpcb *
void in_setpeeraddr(struct inpcb *, struct mbuf *);
void in_setsockaddr(struct inpcb *, struct mbuf *);
int in_sockaddr(struct socket *, struct mbuf *);
+int in_peeraddr(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.85 2022/09/03 18:48:50 mvs Exp $ */
+/* $OpenBSD: ip_divert.c,v 1.86 2022/09/03 22:43:38 mvs Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
};
const struct pr_usrreqs divert_usrreqs = {
- .pru_usrreq = divert_usrreq,
.pru_attach = divert_attach,
.pru_detach = divert_detach,
.pru_bind = divert_bind,
.pru_abort = divert_abort,
.pru_control = in_control,
.pru_sockaddr = in_sockaddr,
+ .pru_peeraddr = in_peeraddr,
};
int divbhashsize = DIVERTHASHSIZE;
m_freem(m);
}
-/*ARGSUSED*/
-int
-divert_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *addr,
- struct mbuf *control, struct proc *p)
-{
- struct inpcb *inp = sotoinpcb(so);
- int error = 0;
-
- soassertlocked(so);
-
- if (inp == NULL) {
- error = EINVAL;
- goto release;
- }
- switch (req) {
-
- case PRU_PEERADDR:
- in_setpeeraddr(inp, addr);
- break;
-
- case PRU_FASTTIMO:
- case PRU_SLOWTIMO:
- case PRU_PROTORCV:
- case PRU_PROTOSEND:
- error = EOPNOTSUPP;
- break;
-
- default:
- panic("divert_usrreq");
- }
-
-release:
- if (req != PRU_RCVD && req != PRU_RCVOOB && req != PRU_SENSE) {
- m_freem(control);
- m_freem(m);
- }
- return (error);
-}
-
int
divert_attach(struct socket *so, int proto)
{
-/* $OpenBSD: ip_divert.h,v 1.20 2022/08/28 18:44:16 mvs Exp $ */
+/* $OpenBSD: ip_divert.h,v 1.21 2022/09/03 22:43:38 mvs Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
void divert_init(void);
void divert_packet(struct mbuf *, int, u_int16_t);
int divert_sysctl(int *, u_int, void *, size_t *, void *, size_t);
-int divert_usrreq(struct socket *,
- int, struct mbuf *, struct mbuf *, struct mbuf *, struct proc *);
int divert_attach(struct socket *, int);
int divert_detach(struct socket *);
int divert_bind(struct socket *, struct mbuf *, struct proc *);
-/* $OpenBSD: ip_gre.c,v 1.83 2022/09/03 18:48:50 mvs Exp $ */
+/* $OpenBSD: ip_gre.c,v 1.84 2022/09/03 22:43:38 mvs Exp $ */
/* $NetBSD: ip_gre.c,v 1.9 1999/10/25 19:18:11 drochner Exp $ */
/*
#endif
const struct pr_usrreqs gre_usrreqs = {
- .pru_usrreq = gre_usrreq,
.pru_attach = rip_attach,
.pru_detach = rip_detach,
.pru_bind = rip_bind,
.pru_abort = rip_abort,
.pru_control = in_control,
.pru_sockaddr = in_sockaddr,
+ .pru_peeraddr = in_peeraddr,
};
-int
-gre_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam,
- struct mbuf *control, struct proc *p)
-{
- return rip_usrreq(so, req, m, nam, control, p);
-}
-
int
gre_send(struct socket *so, struct mbuf *m, struct mbuf *nam,
struct mbuf *control)
-/* $OpenBSD: ip_var.h,v 1.103 2022/08/28 18:44:16 mvs Exp $ */
+/* $OpenBSD: ip_var.h,v 1.104 2022/09/03 22:43:38 mvs Exp $ */
/* $NetBSD: ip_var.h,v 1.16 1996/02/13 23:43:20 christos Exp $ */
/*
int rip_input(struct mbuf **, int *, int, int);
int rip_output(struct mbuf *, struct socket *, struct sockaddr *,
struct mbuf *);
-int rip_usrreq(struct socket *,
- int, struct mbuf *, struct mbuf *, struct mbuf *, struct proc *);
int rip_attach(struct socket *, int);
int rip_detach(struct socket *);
int rip_bind(struct socket *so, struct mbuf *, struct proc *);
-/* $OpenBSD: raw_ip.c,v 1.146 2022/09/03 18:48:50 mvs Exp $ */
+/* $OpenBSD: raw_ip.c,v 1.147 2022/09/03 22:43:38 mvs Exp $ */
/* $NetBSD: raw_ip.c,v 1.25 1996/02/18 18:58:33 christos Exp $ */
/*
*/
const struct pr_usrreqs rip_usrreqs = {
- .pru_usrreq = rip_usrreq,
.pru_attach = rip_attach,
.pru_detach = rip_detach,
.pru_bind = rip_bind,
.pru_abort = rip_abort,
.pru_control = in_control,
.pru_sockaddr = in_sockaddr,
+ .pru_peeraddr = in_peeraddr,
};
/*
u_long rip_sendspace = RIPSNDQ;
u_long rip_recvspace = RIPRCVQ;
-/*ARGSUSED*/
-int
-rip_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam,
- struct mbuf *control, struct proc *p)
-{
- struct inpcb *inp;
- int error = 0;
-
- soassertlocked(so);
-
- inp = sotoinpcb(so);
- if (inp == NULL) {
- error = EINVAL;
- goto release;
- }
-
- switch (req) {
-
- case PRU_PEERADDR:
- in_setpeeraddr(inp, nam);
- break;
-
- default:
- panic("rip_usrreq");
- }
-release:
- if (req != PRU_RCVD && req != PRU_RCVOOB && req != PRU_SENSE) {
- m_freem(control);
- m_freem(m);
- }
- return (error);
-}
-
int
rip_attach(struct socket *so, int proto)
{
-/* $OpenBSD: tcp_usrreq.c,v 1.206 2022/09/03 19:22:19 bluhm Exp $ */
+/* $OpenBSD: tcp_usrreq.c,v 1.207 2022/09/03 22:43:38 mvs Exp $ */
/* $NetBSD: tcp_usrreq.c,v 1.20 1996/02/13 23:44:16 christos Exp $ */
/*
u_int tcp_autorcvbuf_inc = 16 * 1024;
const struct pr_usrreqs tcp_usrreqs = {
- .pru_usrreq = tcp_usrreq,
.pru_attach = tcp_attach,
.pru_detach = tcp_detach,
.pru_bind = tcp_bind,
.pru_sendoob = tcp_sendoob,
.pru_control = in_control,
.pru_sockaddr = tcp_sockaddr,
+ .pru_peeraddr = tcp_peeraddr,
};
#ifdef INET6
const struct pr_usrreqs tcp6_usrreqs = {
- .pru_usrreq = tcp_usrreq,
.pru_attach = tcp_attach,
.pru_detach = tcp_detach,
.pru_bind = tcp_bind,
.pru_sendoob = tcp_sendoob,
.pru_control = in6_control,
.pru_sockaddr = tcp_sockaddr,
+ .pru_peeraddr = tcp_peeraddr,
};
#endif
return 0;
}
-/*
- * Process a TCP user request for TCP tb. If this is a send request
- * then m is the mbuf chain of send data. If this is a timer expiration
- * (called from the software clock routine), then timertype tells which timer.
- */
-/*ARGSUSED*/
-int
-tcp_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam,
- struct mbuf *control, struct proc *p)
-{
- struct inpcb *inp;
- struct tcpcb *otp = NULL, *tp;
- int error = 0;
- short ostate;
-
- soassertlocked(so);
-
- if (control && control->m_len) {
- error = EINVAL;
- goto release;
- }
-
- if ((error = tcp_sogetpcb(so, &inp, &tp)))
- goto release;
-
- if (so->so_options & SO_DEBUG) {
- otp = tp;
- ostate = tp->t_state;
- }
-
- switch (req) {
-
- case PRU_PEERADDR:
-#ifdef INET6
- if (inp->inp_flags & INP_IPV6)
- in6_setpeeraddr(inp, nam);
- else
-#endif
- in_setpeeraddr(inp, nam);
- break;
-
- default:
- panic("tcp_usrreq");
- }
- if (otp)
- tcp_trace(TA_USER, ostate, tp, otp, NULL, req, 0);
- return (error);
-
- release:
- if (req != PRU_RCVD && req != PRU_RCVOOB && req != PRU_SENSE) {
- m_freem(control);
- m_freem(m);
- }
- return (error);
-}
-
/*
* Export internal TCP state information via a struct tcp_info without
* leaking any sensitive information. Sequence numbers are reported
return (0);
}
+int
+tcp_peeraddr(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_setpeeraddr(inp, nam);
+ else
+#endif
+ in_setpeeraddr(inp, nam);
+
+ if (so->so_options & SO_DEBUG)
+ tcp_trace(TA_USER, tp->t_state, tp, tp, NULL,
+ PRU_PEERADDR, 0);
+ return (0);
+}
+
/*
* Initiate (or continue) disconnect.
* If embryonic state, just send reset (once).
-/* $OpenBSD: tcp_var.h,v 1.156 2022/09/03 19:22:19 bluhm Exp $ */
+/* $OpenBSD: tcp_var.h,v 1.157 2022/09/03 22:43:38 mvs Exp $ */
/* $NetBSD: tcp_var.h,v 1.17 1996/02/13 23:44:24 christos Exp $ */
/*
struct tcpcb *
tcp_usrclosed(struct tcpcb *);
int tcp_sysctl(int *, u_int, void *, size_t *, void *, size_t);
-int tcp_usrreq(struct socket *,
- int, struct mbuf *, struct mbuf *, struct mbuf *, struct proc *);
int tcp_attach(struct socket *, int);
int tcp_detach(struct socket *);
int tcp_bind(struct socket *, struct mbuf *, struct proc *);
struct mbuf *);
int tcp_abort(struct socket *);
int tcp_sockaddr(struct socket *, struct mbuf *);
+int tcp_peeraddr(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.300 2022/09/03 18:48:50 mvs Exp $ */
+/* $OpenBSD: udp_usrreq.c,v 1.301 2022/09/03 22:43:38 mvs Exp $ */
/* $NetBSD: udp_usrreq.c,v 1.28 1996/03/16 23:54:03 christos Exp $ */
/*
/* 40 1K datagrams */
const struct pr_usrreqs udp_usrreqs = {
- .pru_usrreq = udp_usrreq,
.pru_attach = udp_attach,
.pru_detach = udp_detach,
.pru_bind = udp_bind,
.pru_abort = udp_abort,
.pru_control = in_control,
.pru_sockaddr = in_sockaddr,
+ .pru_peeraddr = in_peeraddr,
};
#ifdef INET6
const struct pr_usrreqs udp6_usrreqs = {
- .pru_usrreq = udp_usrreq,
.pru_attach = udp_attach,
.pru_detach = udp_detach,
.pru_bind = udp_bind,
.pru_abort = udp_abort,
.pru_control = in6_control,
.pru_sockaddr = in6_sockaddr,
+ .pru_peeraddr = in6_peeraddr,
};
#endif
goto bail;
}
-/*ARGSUSED*/
-int
-udp_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *addr,
- struct mbuf *control, struct proc *p)
-{
- struct inpcb *inp;
- int error = 0;
-
- soassertlocked(so);
-
- inp = sotoinpcb(so);
- if (inp == NULL) {
- error = EINVAL;
- goto release;
- }
-
- /*
- * Note: need to block udp_input while changing
- * the udp pcb queue and/or pcb addresses.
- */
- switch (req) {
-
- case PRU_PEERADDR:
-#ifdef INET6
- if (inp->inp_flags & INP_IPV6)
- in6_setpeeraddr(inp, addr);
- else
-#endif /* INET6 */
- in_setpeeraddr(inp, addr);
- break;
-
- case PRU_FASTTIMO:
- case PRU_SLOWTIMO:
- case PRU_PROTORCV:
- case PRU_PROTOSEND:
- error = EOPNOTSUPP;
- break;
-
- default:
- panic("udp_usrreq");
- }
-release:
- if (req != PRU_RCVD && req != PRU_RCVOOB && req != PRU_SENSE) {
- m_freem(control);
- m_freem(m);
- }
- return (error);
-}
-
int
udp_attach(struct socket *so, int proto)
{
-/* $OpenBSD: udp_var.h,v 1.45 2022/09/02 13:12:32 mvs Exp $ */
+/* $OpenBSD: udp_var.h,v 1.46 2022/09/03 22:43:38 mvs Exp $ */
/* $NetBSD: udp_var.h,v 1.12 1996/02/13 23:44:41 christos Exp $ */
/*
struct mbuf *);
#endif /* INET6 */
int udp_sysctl(int *, u_int, void *, size_t *, void *, size_t);
-int udp_usrreq(struct socket *,
- int, struct mbuf *, struct mbuf *, struct mbuf *, struct proc *);
int udp_attach(struct socket *, int);
int udp_detach(struct socket *);
int udp_bind(struct socket *, struct mbuf *, struct proc *);
-/* $OpenBSD: in6_pcb.c,v 1.122 2022/09/03 18:48:50 mvs Exp $ */
+/* $OpenBSD: in6_pcb.c,v 1.123 2022/09/03 22:43:38 mvs Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
return (0);
}
+int
+in6_peeraddr(struct socket *so, struct mbuf *nam)
+{
+ struct inpcb *in6p;
+
+ in6p = sotoinpcb(so);
+ in6_setpeeraddr(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.84 2022/09/03 18:48:50 mvs Exp $ */
+/* $OpenBSD: ip6_divert.c,v 1.85 2022/09/03 22:43:38 mvs Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
};
const struct pr_usrreqs divert6_usrreqs = {
- .pru_usrreq = divert6_usrreq,
.pru_attach = divert6_attach,
.pru_detach = divert6_detach,
.pru_bind = divert6_bind,
.pru_abort = divert6_abort,
.pru_control = in6_control,
.pru_sockaddr = in6_sockaddr,
+ .pru_peeraddr = in6_peeraddr,
};
int divb6hashsize = DIVERTHASHSIZE;
m_freem(m);
}
-/*ARGSUSED*/
-int
-divert6_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *addr,
- struct mbuf *control, struct proc *p)
-{
- struct inpcb *inp = sotoinpcb(so);
- int error = 0;
-
- soassertlocked(so);
-
- if (inp == NULL) {
- error = EINVAL;
- goto release;
- }
- switch (req) {
-
- case PRU_PEERADDR:
- in6_setpeeraddr(inp, addr);
- break;
-
- case PRU_FASTTIMO:
- case PRU_SLOWTIMO:
- case PRU_PROTORCV:
- case PRU_PROTOSEND:
- error = EOPNOTSUPP;
- break;
-
- default:
- panic("%s", __func__);
- }
-
-release:
- if (req != PRU_RCVD && req != PRU_RCVOOB && req != PRU_SENSE) {
- m_freem(control);
- m_freem(m);
- }
- return (error);
-}
-
int
divert6_attach(struct socket *so, int proto)
{
-/* $OpenBSD: ip6_divert.h,v 1.18 2022/08/28 18:44:17 mvs Exp $ */
+/* $OpenBSD: ip6_divert.h,v 1.19 2022/09/03 22:43:38 mvs Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
void divert6_init(void);
void divert6_packet(struct mbuf *, int, u_int16_t);
int divert6_sysctl(int *, u_int, void *, size_t *, void *, size_t);
-int divert6_usrreq(struct socket *,
- int, struct mbuf *, struct mbuf *, struct mbuf *, struct proc *);
int divert6_attach(struct socket *, int);
int divert6_detach(struct socket *);
int divert6_bind(struct socket *, struct mbuf *, struct proc *);
-/* $OpenBSD: ip6_var.h,v 1.101 2022/08/28 18:44:17 mvs Exp $ */
+/* $OpenBSD: ip6_var.h,v 1.102 2022/09/03 22:43:38 mvs Exp $ */
/* $KAME: ip6_var.h,v 1.33 2000/06/11 14:59:20 jinmei Exp $ */
/*
int rip6_ctloutput(int, struct socket *, int, int, struct mbuf *);
int rip6_output(struct mbuf *, struct socket *, struct sockaddr *,
struct mbuf *);
-int rip6_usrreq(struct socket *,
- int, struct mbuf *, struct mbuf *, struct mbuf *, struct proc *);
int rip6_attach(struct socket *, int);
int rip6_detach(struct socket *);
int rip6_bind(struct socket *, struct mbuf *, struct proc *);
-/* $OpenBSD: raw_ip6.c,v 1.167 2022/09/03 18:48:50 mvs Exp $ */
+/* $OpenBSD: raw_ip6.c,v 1.168 2022/09/03 22:43:38 mvs Exp $ */
/* $KAME: raw_ip6.c,v 1.69 2001/03/04 15:55:44 itojun Exp $ */
/*
struct cpumem *rip6counters;
const struct pr_usrreqs rip6_usrreqs = {
- .pru_usrreq = rip6_usrreq,
.pru_attach = rip6_attach,
.pru_detach = rip6_detach,
.pru_bind = rip6_bind,
.pru_abort = rip6_abort,
.pru_control = in6_control,
.pru_sockaddr = in6_sockaddr,
+ .pru_peeraddr = in6_peeraddr,
};
/*
extern u_long rip6_sendspace;
extern u_long rip6_recvspace;
-int
-rip6_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam,
- struct mbuf *control, struct proc *p)
-{
- struct inpcb *in6p;
- int error = 0;
-
- soassertlocked(so);
-
- in6p = sotoinpcb(so);
- if (in6p == NULL) {
- error = EINVAL;
- goto release;
- }
-
- switch (req) {
- case PRU_PEERADDR:
- in6_setpeeraddr(in6p, nam);
- break;
-
- default:
- panic("%s", __func__);
- }
-release:
- if (req != PRU_RCVD && req != PRU_RCVOOB && req != PRU_SENSE) {
- m_freem(control);
- m_freem(m);
- }
- return (error);
-}
-
int
rip6_attach(struct socket *so, int proto)
{
-/* $OpenBSD: protosw.h,v 1.53 2022/09/03 18:48:50 mvs Exp $ */
+/* $OpenBSD: protosw.h,v 1.54 2022/09/03 22:43:39 mvs Exp $ */
/* $NetBSD: protosw.h,v 1.10 1996/04/09 20:55:32 cgd Exp $ */
/*-
struct ifnet;
struct pr_usrreqs {
- /* user request: see list below */
- int (*pru_usrreq)(struct socket *, int, struct mbuf *,
- struct mbuf *, struct mbuf *, struct proc *);
-
int (*pru_attach)(struct socket *, int);
int (*pru_detach)(struct socket *);
int (*pru_bind)(struct socket *, struct mbuf *, struct proc *);
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 *);
int (*pru_sockaddr)(struct socket *, struct mbuf *);
+ int (*pru_peeraddr)(struct socket *, struct mbuf *);
+ int (*pru_connect2)(struct socket *, struct socket *);
};
struct protosw {
static inline int
pru_peeraddr(struct socket *so, struct mbuf *addr)
{
- return (*so->so_proto->pr_usrreqs->pru_usrreq)(so,
- PRU_PEERADDR, NULL, addr, NULL, curproc);
+ return (*so->so_proto->pr_usrreqs->pru_peeraddr)(so, addr);
}
static inline int
-/* $OpenBSD: unpcb.h,v 1.39 2022/09/03 18:48:50 mvs Exp $ */
+/* $OpenBSD: unpcb.h,v 1.40 2022/09/03 22:43:39 mvs Exp $ */
/* $NetBSD: unpcb.h,v 1.6 1994/06/29 06:46:08 cgd Exp $ */
/*
extern const struct pr_usrreqs uipc_usrreqs;
-int uipc_usrreq(struct socket *, int , struct mbuf *,
- struct mbuf *, struct mbuf *, struct proc *);
int uipc_attach(struct socket *, int);
int uipc_detach(struct socket *);
int uipc_bind(struct socket *, struct mbuf *, struct proc *);
int uipc_abort(struct socket *);
int uipc_sense(struct socket *, struct stat *);
int uipc_sockaddr(struct socket *, struct mbuf *);
+int uipc_peeraddr(struct socket *, struct mbuf *);
int uipc_connect2(struct socket *, struct socket *);
void unp_init(void);