Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/netinet make rip_connect_pcb take sockaddr_in * instead ...



details:   https://anonhg.NetBSD.org/src/rev/fbf30378dc28
branches:  trunk
changeset: 807874:fbf30378dc28
user:      rtr <rtr%NetBSD.org@localhost>
date:      Sat Apr 25 15:19:54 2015 +0000

description:
make rip_connect_pcb take sockaddr_in * instead of mbuf *
make rip_connect_pcb static since it appears to be used only in raw_ip.c

moves m_len check to callers which is a small duplication of code
that will go away when the callers are converted to receive sockaddr *.

diffstat:

 sys/netinet/raw_ip.c |  19 ++++++++++---------
 1 files changed, 10 insertions(+), 9 deletions(-)

diffs (63 lines):

diff -r b18d3d276d36 -r fbf30378dc28 sys/netinet/raw_ip.c
--- a/sys/netinet/raw_ip.c      Sat Apr 25 14:56:05 2015 +0000
+++ b/sys/netinet/raw_ip.c      Sat Apr 25 15:19:54 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: raw_ip.c,v 1.148 2015/04/24 22:32:37 rtr Exp $ */
+/*     $NetBSD: raw_ip.c,v 1.149 2015/04/25 15:19:54 rtr Exp $ */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -65,7 +65,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: raw_ip.c,v 1.148 2015/04/24 22:32:37 rtr Exp $");
+__KERNEL_RCSID(0, "$NetBSD: raw_ip.c,v 1.149 2015/04/25 15:19:54 rtr Exp $");
 
 #include "opt_inet.h"
 #include "opt_compat_netbsd.h"
@@ -111,7 +111,7 @@
 
 int     rip_pcbnotify(struct inpcbtable *, struct in_addr,
     struct in_addr, int, int, void (*)(struct inpcb *, int));
-int     rip_connect_pcb(struct inpcb *, struct mbuf *);
+static int      rip_connect_pcb(struct inpcb *, struct sockaddr_in *);
 static void     rip_disconnect1(struct inpcb *);
 
 static void sysctl_net_inet_raw_setup(struct sysctllog **);
@@ -480,12 +480,9 @@
 }
 
 int
-rip_connect_pcb(struct inpcb *inp, struct mbuf *nam)
+rip_connect_pcb(struct inpcb *inp, struct sockaddr_in *addr)
 {
-       struct sockaddr_in *addr = mtod(nam, struct sockaddr_in *);
 
-       if (nam->m_len != sizeof(*addr))
-               return (EINVAL);
        if (IFNET_EMPTY())
                return (EADDRNOTAVAIL);
        if (addr->sin_family != AF_INET)
@@ -612,7 +609,9 @@
        KASSERT(nam != NULL);
 
        s = splsoftnet();
-       error = rip_connect_pcb(inp, nam);
+       if (nam->m_len != sizeof(struct sockaddr_in))
+               return EINVAL;
+       error = rip_connect_pcb(inp, mtod(nam, struct sockaddr_in *));
        if (! error)
                soisconnected(so);
        splx(s);
@@ -763,7 +762,9 @@
                        error = EISCONN;
                        goto die;
                }
-               error = rip_connect_pcb(inp, nam);
+               if (nam->m_len != sizeof(struct sockaddr_in))
+                       return EINVAL;
+               error = rip_connect_pcb(inp, mtod(nam, struct sockaddr_in *));
                if (error) {
                die:
                        m_freem(m);



Home | Main Index | Thread Index | Old Index