Cleanup some of the comments, and reformat long lines.

Replace m_copy() with m_copypacket() where applicable.

Replace "if (a.s_addr ...)" with "if (a.s_addr != INADDR_ANY ...)"
to make it clear what the code means.

While at it, fix some function headers and remove 'register' from
variable declarations.

MFC after: 3 days
This commit is contained in:
Luigi Rizzo 2002-11-17 16:02:17 +00:00
parent 810c82e6c2
commit 4e8fe3210d

View File

@ -118,10 +118,10 @@ void (*ip_rsvp_force_done)(struct socket *);
*/
/*
* Initialize raw connection block q.
* Initialize raw connection block queue.
*/
void
rip_init()
rip_init(void)
{
INP_INFO_LOCK_INIT(&ripcbinfo, "rip");
LIST_INIT(&ripcb);
@ -138,19 +138,22 @@ rip_init()
uma_zone_set_max(ripcbinfo.ipi_zone, maxsockets);
}
/*
* XXX ripsrc is modified in rip_input, so we must be fix this
* when we want to make this code smp-friendly.
*/
static struct sockaddr_in ripsrc = { sizeof(ripsrc), AF_INET };
/*
* Setup generic address and protocol structures
* for raw_input routine, then pass them along with
* mbuf chain.
*/
void
rip_input(m, off)
struct mbuf *m;
int off;
rip_input(struct mbuf *m, int off)
{
register struct ip *ip = mtod(m, struct ip *);
register struct inpcb *inp;
struct ip *ip = mtod(m, struct ip *);
struct inpcb *inp;
struct inpcb *last = 0;
struct mbuf *opts = 0;
int proto = ip->ip_p;
@ -163,14 +166,14 @@ rip_input(m, off)
#endif
if (inp->inp_ip_p && inp->inp_ip_p != proto)
continue;
if (inp->inp_laddr.s_addr &&
inp->inp_laddr.s_addr != ip->ip_dst.s_addr)
if (inp->inp_laddr.s_addr != INADDR_ANY &&
inp->inp_laddr.s_addr != ip->ip_dst.s_addr)
continue;
if (inp->inp_faddr.s_addr &&
inp->inp_faddr.s_addr != ip->ip_src.s_addr)
if (inp->inp_faddr.s_addr != INADDR_ANY &&
inp->inp_faddr.s_addr != ip->ip_src.s_addr)
continue;
if (last) {
struct mbuf *n = m_copy(m, 0, (int)M_COPYALL);
struct mbuf *n = m_copypacket(m, M_DONTWAIT);
int policyfail = 0;
if (n != NULL) {
@ -265,13 +268,10 @@ rip_input(m, off)
* Tack on options user may have setup with control call.
*/
int
rip_output(m, so, dst)
struct mbuf *m;
struct socket *so;
u_long dst;
rip_output(struct mbuf *m, struct socket *so, u_long dst)
{
register struct ip *ip;
register struct inpcb *inp = sotoinpcb(so);
struct ip *ip;
struct inpcb *inp = sotoinpcb(so);
int flags = (so->so_options & SO_DONTROUTE) | IP_ALLOWBROADCAST;
#ifdef MAC
@ -330,9 +330,7 @@ rip_output(m, so, dst)
* Raw IP socket option processing.
*/
int
rip_ctloutput(so, sopt)
struct socket *so;
struct sockopt *sopt;
rip_ctloutput(struct socket *so, struct sockopt *sopt)
{
struct inpcb *inp = sotoinpcb(so);
int error, optval;
@ -460,10 +458,7 @@ rip_ctloutput(so, sopt)
* interface routes.
*/
void
rip_ctlinput(cmd, sa, vip)
int cmd;
struct sockaddr *sa;
void *vip;
rip_ctlinput(int cmd, struct sockaddr *sa, void *vip)
{
struct in_ifaddr *ia;
struct ifnet *ifp;
@ -521,7 +516,8 @@ SYSCTL_INT(_net_inet_raw, OID_AUTO, maxdgram, CTLFLAG_RW,
SYSCTL_INT(_net_inet_raw, OID_AUTO, recvspace, CTLFLAG_RW,
&rip_recvspace, 0, "Maximum incoming raw IP datagram size");
SYSCTL_INT(_net_inet_raw, OID_AUTO, olddiverterror, CTLFLAG_RW,
&rip_olddiverterror, 0, "Return an error when creating an 'old' DIVERT socket");
&rip_olddiverterror, 0,
"Return an error when creating an 'old' DIVERT socket");
static int
rip_attach(struct socket *so, int proto, struct thread *td)
@ -540,7 +536,9 @@ rip_attach(struct socket *so, int proto, struct thread *td)
/* To be removed before 5.2 */
if (rip_olddiverterror && proto == IPPROTO_OLD_DIVERT) {
printf("Old IPDIVERT program needs to be recompiled, or new IP proto 254 user needs sysctl net.inet.raw.olddiverterror=0\n");
printf("Old IPDIVERT program needs to be recompiled, "
"or new IP proto 254 user needs "
"sysctl net.inet.raw.olddiverterror=0\n");
return EPROTONOSUPPORT;
}
@ -603,7 +601,7 @@ rip_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
if (TAILQ_EMPTY(&ifnet) || ((addr->sin_family != AF_INET) &&
(addr->sin_family != AF_IMPLINK)) ||
(addr->sin_addr.s_addr &&
(addr->sin_addr.s_addr != INADDR_ANY &&
ifa_ifwithaddr((struct sockaddr *)addr) == 0))
return EADDRNOTAVAIL;
inp->inp_laddr = addr->sin_addr;
@ -640,7 +638,7 @@ rip_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam,
struct mbuf *control, struct thread *td)
{
struct inpcb *inp = sotoinpcb(so);
register u_long dst;
u_long dst;
if (so->so_state & SS_ISCONNECTED) {
if (nam) {