mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-11-13 05:41:26 +01:00
Convert raw IP from mondo-switch-statement-from-Hell to
pr_usrreqs. Collapse duplicates with udp_usrreq.c and tcp_usrreq.c (calling the generic routines in uipc_socket2.c and in_pcb.c). Calling sockaddr()_ or peeraddr() on a detached socket now traps, rather than harmlessly returning an error; this should never happen. Allow the raw IP buffer sizes to be controlled via sysctl.
This commit is contained in:
parent
d8392c6c39
commit
117bcae7c4
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=22900
@ -142,7 +142,7 @@ static int in_interfaces; /* number of external internet interfaces */
|
||||
int
|
||||
in_control(so, cmd, data, ifp)
|
||||
struct socket *so;
|
||||
u_long cmd;
|
||||
int cmd;
|
||||
caddr_t data;
|
||||
register struct ifnet *ifp;
|
||||
{
|
||||
|
@ -454,11 +454,21 @@ in_pcbdetach(inp)
|
||||
FREE(inp, M_PCB);
|
||||
}
|
||||
|
||||
void
|
||||
in_setsockaddr(inp, nam)
|
||||
register struct inpcb *inp;
|
||||
/*
|
||||
* The calling convention of in_setsockaddr() and in_setpeeraddr() was
|
||||
* modified to match the pru_sockaddr() and pru_peeraddr() entry points
|
||||
* in struct pr_usrreqs, so that protocols can just reference then directly
|
||||
* without the need for a wrapper function. The socket must have a valid
|
||||
* (i.e., non-nil) PCB, but it should be impossible to get an invalid one
|
||||
* except through a kernel programming error, so it is acceptable to panic
|
||||
* (or in this case trap) if the PCB is invalid.
|
||||
*/
|
||||
int
|
||||
in_setsockaddr(so, nam)
|
||||
struct socket *so;
|
||||
struct mbuf *nam;
|
||||
{
|
||||
register struct inpcb *inp = sotoinpcb(so);
|
||||
register struct sockaddr_in *sin;
|
||||
|
||||
nam->m_len = sizeof (*sin);
|
||||
@ -468,13 +478,15 @@ in_setsockaddr(inp, nam)
|
||||
sin->sin_len = sizeof(*sin);
|
||||
sin->sin_port = inp->inp_lport;
|
||||
sin->sin_addr = inp->inp_laddr;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
in_setpeeraddr(inp, nam)
|
||||
struct inpcb *inp;
|
||||
int
|
||||
in_setpeeraddr(so, nam)
|
||||
struct socket *so;
|
||||
struct mbuf *nam;
|
||||
{
|
||||
struct inpcb *inp = sotoinpcb(so);
|
||||
register struct sockaddr_in *sin;
|
||||
|
||||
nam->m_len = sizeof (*sin);
|
||||
@ -484,6 +496,7 @@ in_setpeeraddr(inp, nam)
|
||||
sin->sin_len = sizeof(*sin);
|
||||
sin->sin_port = inp->inp_fport;
|
||||
sin->sin_addr = inp->inp_faddr;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -108,8 +108,8 @@ struct inpcb *
|
||||
void in_pcbnotify __P((struct inpcbhead *, struct sockaddr *,
|
||||
u_int, struct in_addr, u_int, int, void (*)(struct inpcb *, int)));
|
||||
void in_pcbrehash __P((struct inpcb *));
|
||||
void in_setpeeraddr __P((struct inpcb *, struct mbuf *));
|
||||
void in_setsockaddr __P((struct inpcb *, struct mbuf *));
|
||||
int in_setpeeraddr __P((struct socket *so, struct mbuf *nam));
|
||||
int in_setsockaddr __P((struct socket *so, struct mbuf *nam));
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)in_proto.c 8.2 (Berkeley) 2/9/95
|
||||
* $FreeBSD$
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -118,27 +118,33 @@ struct protosw inetsw[] = {
|
||||
},
|
||||
{ SOCK_RAW, &inetdomain, IPPROTO_RAW, PR_ATOMIC|PR_ADDR,
|
||||
rip_input, 0, rip_ctlinput, rip_ctloutput,
|
||||
rip_usrreq,
|
||||
0,
|
||||
0, 0, 0, 0,
|
||||
&rip_usrreqs
|
||||
},
|
||||
{ SOCK_RAW, &inetdomain, IPPROTO_ICMP, PR_ATOMIC|PR_ADDR,
|
||||
icmp_input, 0, 0, rip_ctloutput,
|
||||
rip_usrreq
|
||||
0,
|
||||
0, 0, 0, 0,
|
||||
&rip_usrreqs
|
||||
},
|
||||
{ SOCK_RAW, &inetdomain, IPPROTO_IGMP, PR_ATOMIC|PR_ADDR,
|
||||
igmp_input, 0, 0, rip_ctloutput,
|
||||
rip_usrreq,
|
||||
igmp_init, igmp_fasttimo, igmp_slowtimo
|
||||
0,
|
||||
igmp_init, igmp_fasttimo, igmp_slowtimo, 0,
|
||||
&rip_usrreqs
|
||||
},
|
||||
{ SOCK_RAW, &inetdomain, IPPROTO_RSVP, PR_ATOMIC|PR_ADDR,
|
||||
rsvp_input, 0, 0, rip_ctloutput,
|
||||
rip_usrreq,
|
||||
0,
|
||||
0, 0, 0, 0,
|
||||
&rip_usrreqs
|
||||
},
|
||||
{ SOCK_RAW, &inetdomain, IPPROTO_IPIP, PR_ATOMIC|PR_ADDR,
|
||||
ipip_input, 0, 0, rip_ctloutput,
|
||||
rip_usrreq,
|
||||
0,
|
||||
0, 0, 0, 0,
|
||||
&rip_usrreqs
|
||||
},
|
||||
#ifdef IPDIVERT
|
||||
{ SOCK_RAW, &inetdomain, IPPROTO_DIVERT, PR_ATOMIC|PR_ADDR,
|
||||
@ -165,22 +171,25 @@ struct protosw inetsw[] = {
|
||||
#ifdef IPXIP
|
||||
{ SOCK_RAW, &inetdomain, IPPROTO_IDP, PR_ATOMIC|PR_ADDR,
|
||||
ipxip_input, 0, ipxip_ctlinput, 0,
|
||||
rip_usrreq,
|
||||
0,
|
||||
0, 0, 0, 0,
|
||||
&rip_usrreqs
|
||||
},
|
||||
#endif
|
||||
#ifdef NSIP
|
||||
{ SOCK_RAW, &inetdomain, IPPROTO_IDP, PR_ATOMIC|PR_ADDR,
|
||||
idpip_input, 0, nsip_ctlinput, 0,
|
||||
rip_usrreq,
|
||||
0,
|
||||
0, 0, 0, 0,
|
||||
&rip_usrreqs
|
||||
},
|
||||
#endif
|
||||
/* raw wildcard */
|
||||
{ SOCK_RAW, &inetdomain, 0, PR_ATOMIC|PR_ADDR,
|
||||
rip_input, 0, 0, rip_ctloutput,
|
||||
rip_usrreq,
|
||||
0,
|
||||
rip_init, 0, 0, 0,
|
||||
&rip_usrreqs
|
||||
},
|
||||
};
|
||||
|
||||
@ -202,6 +211,7 @@ SYSCTL_NODE(_net_inet, IPPROTO_ICMP, icmp, CTLFLAG_RW, 0, "ICMP");
|
||||
SYSCTL_NODE(_net_inet, IPPROTO_UDP, udp, CTLFLAG_RW, 0, "UDP");
|
||||
SYSCTL_NODE(_net_inet, IPPROTO_TCP, tcp, CTLFLAG_RW, 0, "TCP");
|
||||
SYSCTL_NODE(_net_inet, IPPROTO_IGMP, igmp, CTLFLAG_RW, 0, "IGMP");
|
||||
SYSCTL_NODE(_net_inet, IPPROTO_RAW, raw, CTLFLAG_RW, 0, "RAW");
|
||||
#ifdef IPDIVERT
|
||||
SYSCTL_NODE(_net_inet, IPPROTO_DIVERT, div, CTLFLAG_RW, 0, "DIVERT");
|
||||
#endif
|
||||
|
@ -216,7 +216,7 @@ do { \
|
||||
|
||||
struct in_multi *in_addmulti __P((struct in_addr *, struct ifnet *));
|
||||
void in_delmulti __P((struct in_multi *));
|
||||
int in_control __P((struct socket *, u_long, caddr_t, struct ifnet *));
|
||||
int in_control __P((struct socket *, int, caddr_t, struct ifnet *));
|
||||
void in_rtqdrain __P((void));
|
||||
void ip_input __P((struct mbuf *));
|
||||
int in_ifadown __P((struct ifaddr *ifa));
|
||||
|
@ -170,6 +170,7 @@ extern struct socket *ip_mrouter; /* multicast routing daemon */
|
||||
extern int (*legal_vif_num) __P((int));
|
||||
extern u_long (*ip_mcast_src) __P((int));
|
||||
extern int rsvp_on;
|
||||
extern struct pr_usrreqs rip_usrreqs;
|
||||
|
||||
int ip_ctloutput __P((int, struct socket *, int, int, struct mbuf **));
|
||||
void ip_drain __P((void));
|
||||
@ -190,8 +191,6 @@ void rip_ctlinput __P((int, struct sockaddr *, void *));
|
||||
void rip_init __P((void));
|
||||
void rip_input __P((struct mbuf *, int));
|
||||
int rip_output __P((struct mbuf *, struct socket *, u_long));
|
||||
int rip_usrreq __P((struct socket *,
|
||||
int, struct mbuf *, struct mbuf *, struct mbuf *));
|
||||
void ipip_input __P((struct mbuf *, int));
|
||||
void rsvp_input __P((struct mbuf *, int));
|
||||
int ip_rsvp_init __P((struct socket *));
|
||||
|
@ -31,18 +31,20 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)raw_ip.c 8.7 (Berkeley) 5/15/95
|
||||
* $Id$
|
||||
* $Id: raw_ip.c,v 1.41 1997/02/13 19:46:45 wollman Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/queue.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/errno.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/mbuf.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/protosw.h>
|
||||
#include <sys/queue.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/socketvar.h>
|
||||
#include <sys/errno.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/route.h>
|
||||
@ -376,166 +378,136 @@ rip_ctlinput(cmd, sa, vip)
|
||||
}
|
||||
}
|
||||
|
||||
static u_long rip_sendspace = RIPSNDQ; /* XXX sysctl ? */
|
||||
static u_long rip_recvspace = RIPRCVQ; /* XXX sysctl ? */
|
||||
static u_long rip_sendspace = RIPSNDQ;
|
||||
static u_long rip_recvspace = RIPRCVQ;
|
||||
|
||||
/*ARGSUSED*/
|
||||
int
|
||||
rip_usrreq(so, req, m, nam, control)
|
||||
register struct socket *so;
|
||||
int req;
|
||||
struct mbuf *m, *nam, *control;
|
||||
SYSCTL_INT(_net_inet_raw, OID_AUTO, maxdgram, CTLFLAG_RW, &rip_sendspace,
|
||||
0, "");
|
||||
SYSCTL_INT(_net_inet_raw, OID_AUTO, recvspace, CTLFLAG_RW, &rip_recvspace,
|
||||
0, "");
|
||||
|
||||
static int
|
||||
rip_attach(struct socket *so, int proto)
|
||||
{
|
||||
register int error = 0;
|
||||
register struct inpcb *inp = sotoinpcb(so);
|
||||
struct inpcb *inp;
|
||||
int error;
|
||||
|
||||
if (req == PRU_CONTROL)
|
||||
return (in_control(so, (u_long)m, (caddr_t)nam,
|
||||
(struct ifnet *)control));
|
||||
inp = sotoinpcb(so);
|
||||
if (inp)
|
||||
panic("rip_attach");
|
||||
if ((so->so_state & SS_PRIV) == 0)
|
||||
return EACCES;
|
||||
|
||||
switch (req) {
|
||||
|
||||
case PRU_ATTACH:
|
||||
if (inp)
|
||||
panic("rip_attach");
|
||||
if ((so->so_state & SS_PRIV) == 0) {
|
||||
error = EACCES;
|
||||
break;
|
||||
}
|
||||
if ((error = soreserve(so, rip_sendspace, rip_recvspace)) ||
|
||||
(error = in_pcballoc(so, &ripcbinfo)))
|
||||
break;
|
||||
inp = (struct inpcb *)so->so_pcb;
|
||||
inp->inp_ip.ip_p = (int)nam;
|
||||
break;
|
||||
|
||||
case PRU_DISCONNECT:
|
||||
if ((so->so_state & SS_ISCONNECTED) == 0) {
|
||||
error = ENOTCONN;
|
||||
break;
|
||||
}
|
||||
/* FALLTHROUGH */
|
||||
case PRU_ABORT:
|
||||
soisdisconnected(so);
|
||||
/* FALLTHROUGH */
|
||||
case PRU_DETACH:
|
||||
if (inp == 0)
|
||||
panic("rip_detach");
|
||||
if (so == ip_mrouter)
|
||||
ip_mrouter_done();
|
||||
ip_rsvp_force_done(so);
|
||||
if (so == ip_rsvpd)
|
||||
ip_rsvp_done();
|
||||
in_pcbdetach(inp);
|
||||
break;
|
||||
|
||||
case PRU_BIND:
|
||||
{
|
||||
struct sockaddr_in *addr = mtod(nam, struct sockaddr_in *);
|
||||
|
||||
if (nam->m_len != sizeof(*addr)) {
|
||||
error = EINVAL;
|
||||
break;
|
||||
}
|
||||
if (TAILQ_EMPTY(&ifnet) ||
|
||||
((addr->sin_family != AF_INET) &&
|
||||
(addr->sin_family != AF_IMPLINK)) ||
|
||||
(addr->sin_addr.s_addr &&
|
||||
ifa_ifwithaddr((struct sockaddr *)addr) == 0)) {
|
||||
error = EADDRNOTAVAIL;
|
||||
break;
|
||||
}
|
||||
inp->inp_laddr = addr->sin_addr;
|
||||
break;
|
||||
}
|
||||
case PRU_CONNECT:
|
||||
{
|
||||
struct sockaddr_in *addr = mtod(nam, struct sockaddr_in *);
|
||||
|
||||
if (nam->m_len != sizeof(*addr)) {
|
||||
error = EINVAL;
|
||||
break;
|
||||
}
|
||||
if (TAILQ_EMPTY(&ifnet)) {
|
||||
error = EADDRNOTAVAIL;
|
||||
break;
|
||||
}
|
||||
if ((addr->sin_family != AF_INET) &&
|
||||
(addr->sin_family != AF_IMPLINK)) {
|
||||
error = EAFNOSUPPORT;
|
||||
break;
|
||||
}
|
||||
inp->inp_faddr = addr->sin_addr;
|
||||
soisconnected(so);
|
||||
break;
|
||||
}
|
||||
|
||||
case PRU_CONNECT2:
|
||||
error = EOPNOTSUPP;
|
||||
break;
|
||||
|
||||
/*
|
||||
* Mark the connection as being incapable of further input.
|
||||
*/
|
||||
case PRU_SHUTDOWN:
|
||||
socantsendmore(so);
|
||||
break;
|
||||
|
||||
/*
|
||||
* Ship a packet out. The appropriate raw output
|
||||
* routine handles any massaging necessary.
|
||||
*/
|
||||
case PRU_SEND:
|
||||
{
|
||||
register u_long dst;
|
||||
|
||||
if (so->so_state & SS_ISCONNECTED) {
|
||||
if (nam) {
|
||||
error = EISCONN;
|
||||
break;
|
||||
}
|
||||
dst = inp->inp_faddr.s_addr;
|
||||
} else {
|
||||
if (nam == NULL) {
|
||||
error = ENOTCONN;
|
||||
break;
|
||||
}
|
||||
dst = mtod(nam, struct sockaddr_in *)->sin_addr.s_addr;
|
||||
}
|
||||
error = rip_output(m, so, dst);
|
||||
m = NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
case PRU_SENSE:
|
||||
/*
|
||||
* stat: don't bother with a blocksize.
|
||||
*/
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Not supported.
|
||||
*/
|
||||
case PRU_RCVOOB:
|
||||
case PRU_RCVD:
|
||||
case PRU_LISTEN:
|
||||
case PRU_ACCEPT:
|
||||
case PRU_SENDOOB:
|
||||
error = EOPNOTSUPP;
|
||||
break;
|
||||
|
||||
case PRU_SOCKADDR:
|
||||
in_setsockaddr(inp, nam);
|
||||
break;
|
||||
|
||||
case PRU_PEERADDR:
|
||||
in_setpeeraddr(inp, nam);
|
||||
break;
|
||||
|
||||
default:
|
||||
panic("rip_usrreq");
|
||||
}
|
||||
if (m != NULL)
|
||||
m_freem(m);
|
||||
return (error);
|
||||
if ((error = soreserve(so, rip_sendspace, rip_recvspace)) ||
|
||||
(error = in_pcballoc(so, &ripcbinfo)))
|
||||
return error;
|
||||
inp = (struct inpcb *)so->so_pcb;
|
||||
inp->inp_ip.ip_p = proto;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
rip_detach(struct socket *so)
|
||||
{
|
||||
struct inpcb *inp;
|
||||
|
||||
inp = sotoinpcb(so);
|
||||
if (inp == 0)
|
||||
panic("rip_detach");
|
||||
if (so == ip_mrouter)
|
||||
ip_mrouter_done();
|
||||
ip_rsvp_force_done(so);
|
||||
if (so == ip_rsvpd)
|
||||
ip_rsvp_done();
|
||||
in_pcbdetach(inp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
rip_abort(struct socket *so)
|
||||
{
|
||||
soisdisconnected(so);
|
||||
return rip_detach(so);
|
||||
}
|
||||
|
||||
static int
|
||||
rip_disconnect(struct socket *so)
|
||||
{
|
||||
if ((so->so_state & SS_ISCONNECTED) == 0)
|
||||
return ENOTCONN;
|
||||
return rip_abort(so);
|
||||
}
|
||||
|
||||
static int
|
||||
rip_bind(struct socket *so, struct mbuf *nam)
|
||||
{
|
||||
struct inpcb *inp = sotoinpcb(so);
|
||||
struct sockaddr_in *addr = mtod(nam, struct sockaddr_in *);
|
||||
|
||||
if (nam->m_len != sizeof(*addr))
|
||||
return EINVAL;
|
||||
|
||||
if (TAILQ_EMPTY(&ifnet) || ((addr->sin_family != AF_INET) &&
|
||||
(addr->sin_family != AF_IMPLINK)) ||
|
||||
(addr->sin_addr.s_addr &&
|
||||
ifa_ifwithaddr((struct sockaddr *)addr) == 0))
|
||||
return EADDRNOTAVAIL;
|
||||
inp->inp_laddr = addr->sin_addr;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
rip_connect(struct socket *so, struct mbuf *nam)
|
||||
{
|
||||
struct inpcb *inp = sotoinpcb(so);
|
||||
struct sockaddr_in *addr = mtod(nam, struct sockaddr_in *);
|
||||
|
||||
if (nam->m_len != sizeof(*addr))
|
||||
return EINVAL;
|
||||
if (TAILQ_EMPTY(&ifnet))
|
||||
return EADDRNOTAVAIL;
|
||||
if ((addr->sin_family != AF_INET) &&
|
||||
(addr->sin_family != AF_IMPLINK))
|
||||
return EAFNOSUPPORT;
|
||||
inp->inp_faddr = addr->sin_addr;
|
||||
soisconnected(so);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
rip_shutdown(struct socket *so)
|
||||
{
|
||||
socantsendmore(so);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
rip_send(struct socket *so, int flags, struct mbuf *m, struct mbuf *nam,
|
||||
struct mbuf *control)
|
||||
{
|
||||
struct inpcb *inp = sotoinpcb(so);
|
||||
register u_long dst;
|
||||
|
||||
if (so->so_state & SS_ISCONNECTED) {
|
||||
if (nam) {
|
||||
m_freem(m);
|
||||
return EISCONN;
|
||||
}
|
||||
dst = inp->inp_faddr.s_addr;
|
||||
} else {
|
||||
if (nam == NULL) {
|
||||
m_freem(m);
|
||||
return ENOTCONN;
|
||||
}
|
||||
dst = mtod(nam, struct sockaddr_in *)->sin_addr.s_addr;
|
||||
}
|
||||
return rip_output(m, so, dst);
|
||||
}
|
||||
|
||||
struct pr_usrreqs rip_usrreqs = {
|
||||
rip_abort, pru_accept_notsupp, rip_attach, rip_bind, rip_connect,
|
||||
pru_connect2_notsupp, in_control, rip_detach, rip_disconnect,
|
||||
pru_listen_notsupp, in_setpeeraddr, pru_rcvd_notsupp,
|
||||
pru_rcvoob_notsupp, rip_send, pru_sense_null, rip_shutdown,
|
||||
in_setsockaddr
|
||||
};
|
||||
|
@ -69,7 +69,7 @@
|
||||
/*
|
||||
* TCP protocol interface to socket abstraction.
|
||||
*/
|
||||
extern char *tcpstates[];
|
||||
extern char *tcpstates[]; /* XXX ??? */
|
||||
|
||||
static int tcp_attach __P((struct socket *));
|
||||
static int tcp_connect __P((struct tcpcb *, struct mbuf *));
|
||||
@ -288,7 +288,7 @@ tcp_usr_accept(struct socket *so, struct mbuf *nam)
|
||||
struct tcpcb *tp;
|
||||
|
||||
COMMON_START();
|
||||
in_setpeeraddr(inp, nam);
|
||||
in_setpeeraddr(so, nam);
|
||||
COMMON_END(PRU_ACCEPT);
|
||||
}
|
||||
|
||||
@ -414,19 +414,6 @@ tcp_usr_abort(struct socket *so)
|
||||
COMMON_END(PRU_ABORT);
|
||||
}
|
||||
|
||||
/*
|
||||
* Fill in st_bklsize for fstat() operations on a socket.
|
||||
*/
|
||||
static int
|
||||
tcp_usr_sense(struct socket *so, struct stat *sb)
|
||||
{
|
||||
int s = splnet();
|
||||
|
||||
sb->st_blksize = so->so_snd.sb_hiwat;
|
||||
splx(s);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Receive out-of-band data.
|
||||
*/
|
||||
@ -457,49 +444,13 @@ tcp_usr_rcvoob(struct socket *so, struct mbuf *m, int flags)
|
||||
COMMON_END(PRU_RCVOOB);
|
||||
}
|
||||
|
||||
static int
|
||||
tcp_usr_sockaddr(struct socket *so, struct mbuf *nam)
|
||||
{
|
||||
int s = splnet();
|
||||
int error = 0;
|
||||
struct inpcb *inp = sotoinpcb(so);
|
||||
struct tcpcb *tp;
|
||||
|
||||
COMMON_START();
|
||||
in_setsockaddr(inp, nam);
|
||||
COMMON_END(PRU_SOCKADDR);
|
||||
}
|
||||
|
||||
static int
|
||||
tcp_usr_peeraddr(struct socket *so, struct mbuf *nam)
|
||||
{
|
||||
int s = splnet();
|
||||
int error = 0;
|
||||
struct inpcb *inp = sotoinpcb(so);
|
||||
struct tcpcb *tp;
|
||||
|
||||
COMMON_START();
|
||||
in_setpeeraddr(inp, nam);
|
||||
COMMON_END(PRU_PEERADDR);
|
||||
}
|
||||
|
||||
/*
|
||||
* XXX - this should just be a call to in_control, but we need to get
|
||||
* the types worked out.
|
||||
*/
|
||||
static int
|
||||
tcp_usr_control(struct socket *so, int cmd, caddr_t arg, struct ifnet *ifp)
|
||||
{
|
||||
return in_control(so, cmd, arg, ifp);
|
||||
}
|
||||
|
||||
/* xxx - should be const */
|
||||
struct pr_usrreqs tcp_usrreqs = {
|
||||
tcp_usr_abort, tcp_usr_accept, tcp_usr_attach, tcp_usr_bind,
|
||||
tcp_usr_connect, pru_connect2_notsupp, tcp_usr_control, tcp_usr_detach,
|
||||
tcp_usr_disconnect, tcp_usr_listen, tcp_usr_peeraddr, tcp_usr_rcvd,
|
||||
tcp_usr_rcvoob, tcp_usr_send, tcp_usr_sense, tcp_usr_shutdown,
|
||||
tcp_usr_sockaddr
|
||||
tcp_usr_connect, pru_connect2_notsupp, in_control, tcp_usr_detach,
|
||||
tcp_usr_disconnect, tcp_usr_listen, in_setpeeraddr, tcp_usr_rcvd,
|
||||
tcp_usr_rcvoob, tcp_usr_send, pru_sense_null, tcp_usr_shutdown,
|
||||
in_setsockaddr
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)udp_usrreq.c 8.6 (Berkeley) 5/23/95
|
||||
* $Id$
|
||||
* $Id: udp_usrreq.c,v 1.33 1997/02/14 18:15:52 wollman Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -479,18 +479,6 @@ udp_abort(struct socket *so)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* XXX should be pru_accept_notsupp */
|
||||
static int
|
||||
udp_accept(struct socket *so, struct mbuf *nam)
|
||||
{
|
||||
struct inpcb *inp;
|
||||
|
||||
inp = sotoinpcb(so);
|
||||
if (inp == 0)
|
||||
return EINVAL;
|
||||
return EOPNOTSUPP;
|
||||
}
|
||||
|
||||
static int
|
||||
udp_attach(struct socket *so, int proto)
|
||||
{
|
||||
@ -582,54 +570,6 @@ udp_disconnect(struct socket *so)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* should be pru_listen_notsupp */
|
||||
static int
|
||||
udp_listen(struct socket *so)
|
||||
{
|
||||
struct inpcb *inp;
|
||||
|
||||
inp = sotoinpcb(so);
|
||||
if (inp == 0)
|
||||
return EINVAL;
|
||||
return EOPNOTSUPP;
|
||||
}
|
||||
|
||||
static int
|
||||
udp_peeraddr(struct socket *so, struct mbuf *nam)
|
||||
{
|
||||
struct inpcb *inp;
|
||||
|
||||
inp = sotoinpcb(so);
|
||||
if (inp == 0)
|
||||
return EINVAL;
|
||||
in_setpeeraddr(inp, nam);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* XXX should be pru_rcvd_notsupp */
|
||||
static int
|
||||
udp_rcvd(struct socket *so, int flags)
|
||||
{
|
||||
struct inpcb *inp;
|
||||
|
||||
inp = sotoinpcb(so);
|
||||
if (inp == 0)
|
||||
return EINVAL;
|
||||
return EOPNOTSUPP;
|
||||
}
|
||||
|
||||
/* XXX should be pru_rcvoob_notsupp */
|
||||
static int
|
||||
udp_rcvoob(struct socket *so, struct mbuf *m, int flags)
|
||||
{
|
||||
struct inpcb *inp;
|
||||
|
||||
inp = sotoinpcb(so);
|
||||
if (inp == 0)
|
||||
return EINVAL;
|
||||
return EOPNOTSUPP;
|
||||
}
|
||||
|
||||
static int
|
||||
udp_send(struct socket *so, int flags, struct mbuf *m, struct mbuf *addr,
|
||||
struct mbuf *control)
|
||||
@ -644,17 +584,6 @@ udp_send(struct socket *so, int flags, struct mbuf *m, struct mbuf *addr,
|
||||
return udp_output(inp, m, addr, control);
|
||||
}
|
||||
|
||||
static int
|
||||
udp_sense(struct socket *so, struct stat *sb)
|
||||
{
|
||||
struct inpcb *inp;
|
||||
|
||||
inp = sotoinpcb(so);
|
||||
if (inp == 0)
|
||||
return EINVAL;
|
||||
return 0; /* xxx do something useful */
|
||||
}
|
||||
|
||||
static int
|
||||
udp_shutdown(struct socket *so)
|
||||
{
|
||||
@ -667,28 +596,10 @@ udp_shutdown(struct socket *so)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
udp_sockaddr(struct socket *so, struct mbuf *nam)
|
||||
{
|
||||
struct inpcb *inp;
|
||||
|
||||
inp = sotoinpcb(so);
|
||||
if (inp == 0)
|
||||
return EINVAL;
|
||||
in_setsockaddr(inp, nam);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* XXX - should fix parameter types of in_control or of pru_control... */
|
||||
static int
|
||||
udp_control(struct socket *so, int cmd, caddr_t data, struct ifnet *ifp)
|
||||
{
|
||||
return in_control(so, cmd, data, ifp);
|
||||
}
|
||||
|
||||
struct pr_usrreqs udp_usrreqs = {
|
||||
udp_abort, udp_accept, udp_attach, udp_bind, udp_connect,
|
||||
pru_connect2_notsupp, udp_control, udp_detach, udp_disconnect,
|
||||
udp_listen, udp_peeraddr, udp_rcvd, udp_rcvoob, udp_send,
|
||||
udp_sense, udp_shutdown, udp_sockaddr
|
||||
udp_abort, pru_accept_notsupp, udp_attach, udp_bind, udp_connect,
|
||||
pru_connect2_notsupp, in_control, udp_detach, udp_disconnect,
|
||||
pru_listen_notsupp, in_setpeeraddr, pru_rcvd_notsupp,
|
||||
pru_rcvoob_notsupp, udp_send, pru_sense_null, udp_shutdown,
|
||||
in_setsockaddr
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user