-/* $OpenBSD: ip6_divert.c,v 1.90 2023/09/16 09:33:27 mpi Exp $ */
+/* $OpenBSD: ip6_divert.c,v 1.91 2024/01/01 18:52:09 bluhm Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
#include <netinet/ip.h>
#include <netinet/ip_var.h>
#include <netinet/in_pcb.h>
+#include <netinet/ip_divert.h>
#include <netinet/ip6.h>
#include <netinet6/in6_var.h>
#include <netinet6/ip6_divert.h>
const struct pr_usrreqs divert6_usrreqs = {
.pru_attach = divert6_attach,
- .pru_detach = divert6_detach,
- .pru_lock = divert6_lock,
- .pru_unlock = divert6_unlock,
- .pru_bind = divert6_bind,
- .pru_shutdown = divert6_shutdown,
+ .pru_detach = divert_detach,
+ .pru_lock = divert_lock,
+ .pru_unlock = divert_unlock,
+ .pru_bind = divert_bind,
+ .pru_shutdown = divert_shutdown,
.pru_send = divert6_send,
.pru_control = in6_control,
.pru_sockaddr = in6_sockaddr,
if (so->so_pcb != NULL)
return EINVAL;
-
if ((so->so_state & SS_PRIV) == 0)
return EACCES;
error = soreserve(so, divert6_sendspace, divert6_recvspace);
if (error)
return (error);
- sotoinpcb(so)->inp_flags |= INP_HDRINCL;
- return (0);
-}
-
-int
-divert6_detach(struct socket *so)
-{
- struct inpcb *inp = sotoinpcb(so);
-
- soassertlocked(so);
-
- if (inp == NULL)
- return (EINVAL);
-
- in_pcbdetach(inp);
-
- return (0);
-}
-
-void
-divert6_lock(struct socket *so)
-{
- struct inpcb *inp = sotoinpcb(so);
-
- NET_ASSERT_LOCKED();
- mtx_enter(&inp->inp_mtx);
-}
-
-void
-divert6_unlock(struct socket *so)
-{
- struct inpcb *inp = sotoinpcb(so);
-
- NET_ASSERT_LOCKED();
- mtx_leave(&inp->inp_mtx);
-}
-
-int
-divert6_bind(struct socket *so, struct mbuf *addr, struct proc *p)
-{
- struct inpcb *inp = sotoinpcb(so);
-
- soassertlocked(so);
- return in_pcbbind(inp, addr, p);
-}
-
-int
-divert6_shutdown(struct socket *so)
-{
- soassertlocked(so);
- socantsendmore(so);
return (0);
}
-/* $OpenBSD: ip6_divert.h,v 1.22 2022/10/17 14:49:02 mvs Exp $ */
+/* $OpenBSD: ip6_divert.h,v 1.23 2024/01/01 18:52:09 bluhm Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
void divert6_packet(struct mbuf *, int, u_int16_t);
int divert6_sysctl(int *, u_int, void *, size_t *, void *, size_t);
int divert6_attach(struct socket *, int, int);
-int divert6_detach(struct socket *);
-void divert6_lock(struct socket *);
-void divert6_unlock(struct socket *);
-int divert6_bind(struct socket *, struct mbuf *, struct proc *);
-int divert6_shutdown(struct socket *);
int divert6_send(struct socket *, struct mbuf *, struct mbuf *,
struct mbuf *);
#endif /* _KERNEL */