-/* $OpenBSD: uipc_usrreq.c,v 1.170 2022/08/21 17:30:21 mvs Exp $ */
+/* $OpenBSD: uipc_usrreq.c,v 1.171 2022/08/21 22:45:55 mvs Exp $ */
/* $NetBSD: uipc_usrreq.c,v 1.18 1996/02/09 19:00:50 christos Exp $ */
/*
.pru_detach = uipc_detach,
.pru_bind = uipc_bind,
.pru_listen = uipc_listen,
+ .pru_connect = uipc_connect,
};
void
switch (req) {
- case PRU_CONNECT:
- error = unp_connect(so, nam, p);
- break;
-
case PRU_CONNECT2:
error = unp_connect2(so, (struct socket *)nam);
if (!error) {
return (0);
}
+int
+uipc_connect(struct socket *so, struct mbuf *nam)
+{
+ return unp_connect(so, nam, curproc);
+}
+
int
uipc_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
size_t newlen)
-/* $OpenBSD: pfkeyv2.c,v 1.237 2022/08/21 17:30:21 mvs Exp $ */
+/* $OpenBSD: pfkeyv2.c,v 1.238 2022/08/21 22:45:55 mvs Exp $ */
/*
* @(#)COPYRIGHT 1.1 (NRL) 17 January 1995
switch (req) {
/* no connect, bind, accept. Socket is connected from the start */
- case PRU_CONNECT:
case PRU_CONNECT2:
case PRU_ACCEPT:
error = EOPNOTSUPP;
-/* $OpenBSD: rtsock.c,v 1.337 2022/08/21 17:30:21 mvs Exp $ */
+/* $OpenBSD: rtsock.c,v 1.338 2022/08/21 22:45:55 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_CONNECT:
case PRU_CONNECT2:
case PRU_ACCEPT:
error = EOPNOTSUPP;
-/* $OpenBSD: ip_divert.c,v 1.72 2022/08/21 17:30:21 mvs Exp $ */
+/* $OpenBSD: ip_divert.c,v 1.73 2022/08/21 22:45:55 mvs Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
case PRU_SENSE:
break;
- case PRU_CONNECT:
case PRU_CONNECT2:
case PRU_ACCEPT:
case PRU_DISCONNECT:
-/* $OpenBSD: ip_gre.c,v 1.76 2022/08/20 23:48:58 mvs Exp $ */
+/* $OpenBSD: ip_gre.c,v 1.77 2022/08/21 22:45:55 mvs Exp $ */
/* $NetBSD: ip_gre.c,v 1.9 1999/10/25 19:18:11 drochner Exp $ */
/*
.pru_attach = rip_attach,
.pru_detach = rip_detach,
.pru_bind = rip_bind,
+ .pru_connect = rip_connect,
};
int
-/* $OpenBSD: ip_var.h,v 1.98 2022/08/20 23:48:58 mvs Exp $ */
+/* $OpenBSD: ip_var.h,v 1.99 2022/08/21 22:45:55 mvs Exp $ */
/* $NetBSD: ip_var.h,v 1.16 1996/02/13 23:43:20 christos Exp $ */
/*
int rip_attach(struct socket *, int);
int rip_detach(struct socket *);
int rip_bind(struct socket *so, struct mbuf *, struct proc *);
+int rip_connect(struct socket *, struct mbuf *);
#ifdef MROUTING
extern struct socket *ip_mrouter[]; /* multicast routing daemon */
#endif
-/* $OpenBSD: raw_ip.c,v 1.132 2022/08/21 17:30:21 mvs Exp $ */
+/* $OpenBSD: raw_ip.c,v 1.133 2022/08/21 22:45:55 mvs Exp $ */
/* $NetBSD: raw_ip.c,v 1.25 1996/02/18 18:58:33 christos Exp $ */
/*
.pru_attach = rip_attach,
.pru_detach = rip_detach,
.pru_bind = rip_bind,
+ .pru_connect = rip_connect,
};
/*
in_pcbdetach(inp);
break;
- case PRU_CONNECT:
- {
- struct sockaddr_in *addr;
-
- if ((error = in_nam2sin(nam, &addr)))
- break;
- inp->inp_faddr = addr->sin_addr;
- soisconnected(so);
- break;
- }
-
case PRU_CONNECT2:
error = EOPNOTSUPP;
break;
return (0);
}
+
+int
+rip_connect(struct socket *so, struct mbuf *nam)
+{
+ struct inpcb *inp = sotoinpcb(so);
+ struct sockaddr_in *addr;
+ int error;
+
+ soassertlocked(so);
+
+ if ((error = in_nam2sin(nam, &addr)))
+ return (error);
+
+ inp->inp_faddr = addr->sin_addr;
+ soisconnected(so);
+
+ return (0);
+}
-/* $OpenBSD: tcp_usrreq.c,v 1.190 2022/08/21 17:30:21 mvs Exp $ */
+/* $OpenBSD: tcp_usrreq.c,v 1.191 2022/08/21 22:45:55 mvs Exp $ */
/* $NetBSD: tcp_usrreq.c,v 1.20 1996/02/13 23:44:16 christos Exp $ */
/*
.pru_detach = tcp_detach,
.pru_bind = tcp_bind,
.pru_listen = tcp_listen,
+ .pru_connect = tcp_connect,
};
static int pr_slowhz = PR_SLOWHZ;
switch (req) {
- /*
- * Initiate connection to peer.
- * Create a template for use in transmissions on this connection.
- * Enter SYN_SENT state, and mark socket as connecting.
- * Start keep-alive timer, and seed output sequence space.
- * Send initial segment on connection.
- */
- case PRU_CONNECT:
-#ifdef INET6
- if (inp->inp_flags & INP_IPV6) {
- struct sockaddr_in6 *sin6;
-
- if ((error = in6_nam2sin6(nam, &sin6)))
- break;
- if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr) ||
- IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr)) {
- error = EINVAL;
- break;
- }
- error = in6_pcbconnect(inp, nam);
- } else
-#endif /* INET6 */
- {
- struct sockaddr_in *sin;
-
- if ((error = in_nam2sin(nam, &sin)))
- break;
- if ((sin->sin_addr.s_addr == INADDR_ANY) ||
- (sin->sin_addr.s_addr == INADDR_BROADCAST) ||
- IN_MULTICAST(sin->sin_addr.s_addr) ||
- in_broadcast(sin->sin_addr, inp->inp_rtableid)) {
- error = EINVAL;
- break;
- }
- error = in_pcbconnect(inp, nam);
- }
- if (error)
- break;
-
- tp->t_template = tcp_template(tp);
- if (tp->t_template == 0) {
- in_pcbdisconnect(inp);
- error = ENOBUFS;
- break;
- }
-
- so->so_state |= SS_CONNECTOUT;
-
- /* Compute window scaling to request. */
- tcp_rscale(tp, sb_max);
-
- soisconnecting(so);
- tcpstat_inc(tcps_connattempt);
- tp->t_state = TCPS_SYN_SENT;
- TCP_TIMER_ARM(tp, TCPT_KEEP, tcptv_keep_init);
- tcp_set_iss_tsm(tp);
- tcp_sendseqinit(tp);
- tp->snd_last = tp->snd_una;
- error = tcp_output(tp);
- break;
-
/*
* Create a TCP connection between two sockets.
*/
return (error);
}
+/*
+ * Initiate connection to peer.
+ * Create a template for use in transmissions on this connection.
+ * Enter SYN_SENT state, and mark socket as connecting.
+ * Start keep-alive timer, and seed output sequence space.
+ * Send initial segment on connection.
+ */
+int
+tcp_connect(struct socket *so, struct mbuf *nam)
+{
+ struct inpcb *inp;
+ struct tcpcb *tp, *otp = NULL;
+ int error;
+ short ostate;
+
+ soassertlocked(so);
+
+ if ((error = tcp_sogetpcb(so, &inp, &tp)))
+ return (error);
+
+ if (so->so_options & SO_DEBUG) {
+ otp = tp;
+ ostate = tp->t_state;
+ }
+
+#ifdef INET6
+ if (inp->inp_flags & INP_IPV6) {
+ struct sockaddr_in6 *sin6;
+
+ if ((error = in6_nam2sin6(nam, &sin6)))
+ goto out;
+ if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr) ||
+ IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr)) {
+ error = EINVAL;
+ goto out;
+ }
+ error = in6_pcbconnect(inp, nam);
+ } else
+#endif /* INET6 */
+ {
+ struct sockaddr_in *sin;
+
+ if ((error = in_nam2sin(nam, &sin)))
+ goto out;
+ if ((sin->sin_addr.s_addr == INADDR_ANY) ||
+ (sin->sin_addr.s_addr == INADDR_BROADCAST) ||
+ IN_MULTICAST(sin->sin_addr.s_addr) ||
+ in_broadcast(sin->sin_addr, inp->inp_rtableid)) {
+ error = EINVAL;
+ goto out;
+ }
+ error = in_pcbconnect(inp, nam);
+ }
+ if (error)
+ goto out;
+
+ tp->t_template = tcp_template(tp);
+ if (tp->t_template == 0) {
+ in_pcbdisconnect(inp);
+ error = ENOBUFS;
+ goto out;
+ }
+
+ so->so_state |= SS_CONNECTOUT;
+
+ /* Compute window scaling to request. */
+ tcp_rscale(tp, sb_max);
+
+ soisconnecting(so);
+ tcpstat_inc(tcps_connattempt);
+ tp->t_state = TCPS_SYN_SENT;
+ TCP_TIMER_ARM(tp, TCPT_KEEP, tcptv_keep_init);
+ tcp_set_iss_tsm(tp);
+ tcp_sendseqinit(tp);
+ tp->snd_last = tp->snd_una;
+ error = tcp_output(tp);
+
+out:
+ if (otp)
+ tcp_trace(TA_USER, ostate, tp, otp, NULL, PRU_CONNECT, 0);
+ return (error);
+}
+
+
/*
* Initiate (or continue) disconnect.
* If embryonic state, just send reset (once).
-/* $OpenBSD: tcp_var.h,v 1.143 2022/08/21 17:30:21 mvs Exp $ */
+/* $OpenBSD: tcp_var.h,v 1.144 2022/08/21 22:45:55 mvs Exp $ */
/* $NetBSD: tcp_var.h,v 1.17 1996/02/13 23:44:24 christos Exp $ */
/*
int tcp_detach(struct socket *);
int tcp_bind(struct socket *, struct mbuf *, struct proc *);
int tcp_listen(struct socket *);
+int tcp_connect(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.284 2022/08/21 17:30:21 mvs Exp $ */
+/* $OpenBSD: udp_usrreq.c,v 1.285 2022/08/21 22:45:55 mvs Exp $ */
/* $NetBSD: udp_usrreq.c,v 1.28 1996/03/16 23:54:03 christos Exp $ */
/*
.pru_attach = udp_attach,
.pru_detach = udp_detach,
.pru_bind = udp_bind,
+ .pru_connect = udp_connect,
};
const struct sysctl_bounded_args udpctl_vars[] = {
*/
switch (req) {
- case PRU_CONNECT:
-#ifdef INET6
- if (inp->inp_flags & INP_IPV6) {
- if (!IN6_IS_ADDR_UNSPECIFIED(&inp->inp_faddr6)) {
- error = EISCONN;
- break;
- }
- error = in6_pcbconnect(inp, addr);
- } else
-#endif /* INET6 */
- {
- if (inp->inp_faddr.s_addr != INADDR_ANY) {
- error = EISCONN;
- break;
- }
- error = in_pcbconnect(inp, addr);
- }
-
- if (error == 0)
- soisconnected(so);
- break;
-
case PRU_CONNECT2:
error = EOPNOTSUPP;
break;
return in_pcbbind(inp, addr, p);
}
+int
+udp_connect(struct socket *so, struct mbuf *addr)
+{
+ struct inpcb *inp = sotoinpcb(so);
+ int error;
+
+ soassertlocked(so);
+
+#ifdef INET6
+ if (inp->inp_flags & INP_IPV6) {
+ if (!IN6_IS_ADDR_UNSPECIFIED(&inp->inp_faddr6))
+ return (EISCONN);
+ error = in6_pcbconnect(inp, addr);
+ } else
+#endif /* INET6 */
+ {
+ if (inp->inp_faddr.s_addr != INADDR_ANY)
+ return (EISCONN);
+ error = in_pcbconnect(inp, addr);
+ }
+
+ if (error)
+ return (error);
+
+ soisconnected(so);
+ return (0);
+}
+
/*
* Sysctl for udp variables.
*/
-/* $OpenBSD: udp_var.h,v 1.39 2022/08/20 23:48:58 mvs Exp $ */
+/* $OpenBSD: udp_var.h,v 1.40 2022/08/21 22:45:55 mvs Exp $ */
/* $NetBSD: udp_var.h,v 1.12 1996/02/13 23:44:41 christos Exp $ */
/*
int udp_attach(struct socket *, int);
int udp_detach(struct socket *);
int udp_bind(struct socket *, struct mbuf *, struct proc *);
+int udp_connect(struct socket *, struct mbuf *);
#endif /* _KERNEL */
#endif /* _NETINET_UDP_VAR_H_ */
-/* $OpenBSD: ip6_divert.c,v 1.71 2022/08/21 17:30:21 mvs Exp $ */
+/* $OpenBSD: ip6_divert.c,v 1.72 2022/08/21 22:45:55 mvs Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
case PRU_SENSE:
break;
- case PRU_CONNECT:
case PRU_CONNECT2:
case PRU_ACCEPT:
case PRU_DISCONNECT:
-/* $OpenBSD: ip6_var.h,v 1.96 2022/08/20 23:48:58 mvs Exp $ */
+/* $OpenBSD: ip6_var.h,v 1.97 2022/08/21 22:45:55 mvs Exp $ */
/* $KAME: ip6_var.h,v 1.33 2000/06/11 14:59:20 jinmei Exp $ */
/*
int rip6_attach(struct socket *, int);
int rip6_detach(struct socket *);
int rip6_bind(struct socket *, struct mbuf *, struct proc *);
+int rip6_connect(struct socket *, struct mbuf *);
int rip6_sysctl(int *, u_int, void *, size_t *, void *, size_t);
int dest6_input(struct mbuf **, int *, int, int);
-/* $OpenBSD: raw_ip6.c,v 1.152 2022/08/21 17:30:21 mvs Exp $ */
+/* $OpenBSD: raw_ip6.c,v 1.153 2022/08/21 22:45:55 mvs Exp $ */
/* $KAME: raw_ip6.c,v 1.69 2001/03/04 15:55:44 itojun Exp $ */
/*
.pru_attach = rip6_attach,
.pru_detach = rip6_detach,
.pru_bind = rip6_bind,
+ .pru_connect = rip6_connect,
};
/*
in_pcbdetach(in6p);
break;
- case PRU_CONNECT:
- {
- struct sockaddr_in6 *addr;
- struct in6_addr *in6a = NULL;
-
- if ((error = in6_nam2sin6(nam, &addr)))
- break;
- /* Source address selection. XXX: need pcblookup? */
- error = in6_pcbselsrc(&in6a, addr, in6p, in6p->inp_outputopts6);
- if (error)
- break;
- in6p->inp_laddr6 = *in6a;
- in6p->inp_faddr6 = addr->sin6_addr;
- soisconnected(so);
- break;
- }
-
case PRU_CONNECT2:
error = EOPNOTSUPP;
break;
return (0);
}
+int
+rip6_connect(struct socket *so, struct mbuf *nam)
+{
+ struct inpcb *in6p = sotoinpcb(so);
+ struct sockaddr_in6 *addr;
+ struct in6_addr *in6a = NULL;
+ int error;
+
+ soassertlocked(so);
+
+ if ((error = in6_nam2sin6(nam, &addr)))
+ return (error);
+
+ /* Source address selection. XXX: need pcblookup? */
+ error = in6_pcbselsrc(&in6a, addr, in6p, in6p->inp_outputopts6);
+ if (error)
+ return (error);
+
+ in6p->inp_laddr6 = *in6a;
+ in6p->inp_faddr6 = addr->sin6_addr;
+ soisconnected(so);
+ return (0);
+}
+
int
rip6_sysctl_rip6stat(void *oldp, size_t *oldplen, void *newp)
{
-/* $OpenBSD: protosw.h,v 1.39 2022/08/21 17:30:21 mvs Exp $ */
+/* $OpenBSD: protosw.h,v 1.40 2022/08/21 22:45:55 mvs Exp $ */
/* $NetBSD: protosw.h,v 1.10 1996/04/09 20:55:32 cgd Exp $ */
/*-
int (*pru_detach)(struct socket *);
int (*pru_bind)(struct socket *, struct mbuf *, struct proc *);
int (*pru_listen)(struct socket *);
+ int (*pru_connect)(struct socket *, struct mbuf *);
};
struct protosw {
static inline int
pru_connect(struct socket *so, struct mbuf *nam)
{
- return (*so->so_proto->pr_usrreqs->pru_usrreq)(so,
- PRU_CONNECT, NULL, nam, NULL, curproc);
+ if (so->so_proto->pr_usrreqs->pru_connect)
+ return (*so->so_proto->pr_usrreqs->pru_connect)(so, nam);
+ return (EOPNOTSUPP);
}
static inline int
-/* $OpenBSD: unpcb.h,v 1.29 2022/08/21 17:30:21 mvs Exp $ */
+/* $OpenBSD: unpcb.h,v 1.30 2022/08/21 22:45:55 mvs Exp $ */
/* $NetBSD: unpcb.h,v 1.6 1994/06/29 06:46:08 cgd Exp $ */
/*
int uipc_detach(struct socket *);
int uipc_bind(struct socket *, struct mbuf *, struct proc *);
int uipc_listen(struct socket *);
+int uipc_connect(struct socket *, struct mbuf *);
void unp_init(void);
int unp_bind(struct unpcb *, struct mbuf *, struct proc *);