Source-Changes-HG archive

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

[src/trunk]: src/sys * update dccp_bind for struct mbuf * to struct sockaddr ...



details:   https://anonhg.NetBSD.org/src/rev/bc94a1d49b8e
branches:  trunk
changeset: 337140:bc94a1d49b8e
user:      rtr <rtr%NetBSD.org@localhost>
date:      Sat Apr 04 04:33:38 2015 +0000

description:
* update dccp_bind for struct mbuf * to struct sockaddr * parameter change
* pass NULL instead of casting 0 to a pointer when calling in_pcbbind()

diffstat:

 sys/netinet/dccp_usrreq.c   |  23 ++++++++++-------------
 sys/netinet6/dccp6_usrreq.c |  15 ++++++---------
 sys/netinet6/dccp6_var.h    |   4 ++--
 3 files changed, 18 insertions(+), 24 deletions(-)

diffs (156 lines):

diff -r 96eaa6ee97a6 -r bc94a1d49b8e sys/netinet/dccp_usrreq.c
--- a/sys/netinet/dccp_usrreq.c Sat Apr 04 02:51:10 2015 +0000
+++ b/sys/netinet/dccp_usrreq.c Sat Apr 04 04:33:38 2015 +0000
@@ -1,5 +1,5 @@
 /*     $KAME: dccp_usrreq.c,v 1.67 2005/11/03 16:05:04 nishida Exp $   */
-/*     $NetBSD: dccp_usrreq.c,v 1.1 2015/02/10 19:11:52 rjs Exp $ */
+/*     $NetBSD: dccp_usrreq.c,v 1.2 2015/04/04 04:33:38 rtr Exp $ */
 
 /*
  * Copyright (c) 2003 Joacim Häggmark, Magnus Erixzon, Nils-Erik Mattsson 
@@ -67,7 +67,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dccp_usrreq.c,v 1.1 2015/02/10 19:11:52 rjs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dccp_usrreq.c,v 1.2 2015/04/04 04:33:38 rtr Exp $");
 
 #include "opt_inet.h"
 #include "opt_dccp.h"
@@ -1820,12 +1820,11 @@
 }
 
 static int
-dccp_bind(struct socket *so, struct mbuf *m, struct lwp *l)
+dccp_bind(struct socket *so, struct sockaddr *nam, struct lwp *l)
 {
        struct inpcb *inp;
        int error;
-       struct sockaddr_in *sinp;
-       struct sockaddr *nam;
+       struct sockaddr_in *sin = (struct sockaddr_in *)nam;
 
        DCCP_DEBUG((LOG_INFO, "Entering dccp_bind!\n"));
        INP_INFO_WLOCK(&dccpbinfo);
@@ -1836,15 +1835,13 @@
        }
 
        /* Do not bind to multicast addresses! */
-       nam = mtod(m, struct sockaddr *);
-       sinp = (struct sockaddr_in *)nam;
-       if (sinp->sin_family == AF_INET &&
-           IN_MULTICAST(ntohl(sinp->sin_addr.s_addr))) {
+       if (sin->sin_family == AF_INET &&
+           IN_MULTICAST(ntohl(sin->sin_addr.s_addr))) {
                INP_INFO_WUNLOCK(&dccpbinfo);
                return EAFNOSUPPORT;
        }
        INP_LOCK(inp);
-       error = in_pcbbind(inp, m, l);
+       error = in_pcbbind(inp, sin, l);
        INP_UNLOCK(inp);
        INP_INFO_WUNLOCK(&dccpbinfo);
        return error;
@@ -1964,11 +1961,11 @@
 #ifdef INET6
                if (isipv6) {
                        DCCP_DEBUG((LOG_INFO, "Running in6_pcbbind!\n"));
-                       error = in6_pcbbind(in6p, (struct mbuf *)0, l);
+                       error = in6_pcbbind(in6p, NULL, l);
                } else
 #endif /* INET6 */
                {
-                       error = in_pcbbind(inp, (struct mbuf *)0, l);
+                       error = in_pcbbind(inp, NULL, l);
                }
                if (error) {
                        DCCP_DEBUG((LOG_INFO, "in_pcbbind=%d\n",error));
@@ -2260,7 +2257,7 @@
        INP_INFO_RUNLOCK(&dccpbinfo);
        dp = (struct dccpcb *)inp->inp_ppcb;
        if (inp->inp_lport == 0)
-               error = in_pcbbind(inp, (struct mbuf *)0, td);
+               error = in_pcbbind(inp, NULL, td);
        if (error == 0) {
                dp->state = DCCPS_LISTEN;
                dp->who = DCCP_LISTENER;
diff -r 96eaa6ee97a6 -r bc94a1d49b8e sys/netinet6/dccp6_usrreq.c
--- a/sys/netinet6/dccp6_usrreq.c       Sat Apr 04 02:51:10 2015 +0000
+++ b/sys/netinet6/dccp6_usrreq.c       Sat Apr 04 04:33:38 2015 +0000
@@ -1,5 +1,5 @@
 /*     $KAME: dccp6_usrreq.c,v 1.13 2005/07/27 08:42:56 nishida Exp $  */
-/*     $NetBSD: dccp6_usrreq.c,v 1.1 2015/02/10 19:11:52 rjs Exp $ */
+/*     $NetBSD: dccp6_usrreq.c,v 1.2 2015/04/04 04:33:39 rtr Exp $ */
 
 /*
  * Copyright (C) 2003 WIDE Project.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dccp6_usrreq.c,v 1.1 2015/02/10 19:11:52 rjs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dccp6_usrreq.c,v 1.2 2015/04/04 04:33:39 rtr Exp $");
 
 #include "opt_inet.h"
 #include "opt_dccp.h"
@@ -111,12 +111,11 @@
 }
 
 int
-dccp6_bind(struct socket *so, struct mbuf *m, struct lwp *td)
+dccp6_bind(struct socket *so, struct sockaddr *nam, struct lwp *td)
 {
        struct in6pcb *in6p;
-       struct sockaddr *nam;
        int error;
-       struct sockaddr_in6 *sin6p;
+       struct sockaddr_in6 *sin6p = (struct sockaddr_in6 *)nam;
 
        DCCP_DEBUG((LOG_INFO, "Entering dccp6_bind!\n"));
        INP_INFO_WLOCK(&dccpbinfo);
@@ -127,8 +126,6 @@
                return EINVAL;
        }
        /* Do not bind to multicast addresses! */
-       nam = mtod(m, struct sockaddr *);
-       sin6p = (struct sockaddr_in6 *)nam;
        if (sin6p->sin6_family == AF_INET6 &&
            IN6_IS_ADDR_MULTICAST(&sin6p->sin6_addr)) {
                INP_INFO_WUNLOCK(&dccpbinfo);
@@ -139,7 +136,7 @@
        in6todccpcb(in6p)->inp_vflag &= ~INP_IPV4;
        in6todccpcb(in6p)->inp_vflag |= INP_IPV6;
        
-       error = in6_pcbbind(in6p, m, td);
+       error = in6_pcbbind(in6p, sin6p, td);
        INP_UNLOCK(inp);
        INP_INFO_WUNLOCK(&dccpbinfo);
        return error;
@@ -253,7 +250,7 @@
        dp = in6todccpcb(in6p);
        DCCP_DEBUG((LOG_INFO, "Checking in6p->in6p_lport!\n"));
        if (in6p->in6p_lport == 0) {
-               error = in6_pcbbind(in6p, (struct mbuf *)0, l);
+               error = in6_pcbbind(in6p, NULL, l);
        }
        if (error == 0) {
                dp->state = DCCPS_LISTEN;
diff -r 96eaa6ee97a6 -r bc94a1d49b8e sys/netinet6/dccp6_var.h
--- a/sys/netinet6/dccp6_var.h  Sat Apr 04 02:51:10 2015 +0000
+++ b/sys/netinet6/dccp6_var.h  Sat Apr 04 04:33:38 2015 +0000
@@ -1,5 +1,5 @@
 /*     $KAME: dccp6_var.h,v 1.3 2003/11/18 04:55:43 ono Exp $  */
-/*     $NetBSD: dccp6_var.h,v 1.1 2015/02/10 19:11:52 rjs Exp $ */
+/*     $NetBSD: dccp6_var.h,v 1.2 2015/04/04 04:33:39 rtr Exp $ */
 
 /*
  * Copyright (c) 2003 Joacim Häggmark
@@ -43,7 +43,7 @@
 int    dccp6_input(struct mbuf **, int *, int);
 int    dccp6_usrreq(struct socket *, int, struct mbuf *, struct mbuf *,
                     struct mbuf *, struct lwp *);
-int    dccp6_bind(struct socket *, struct mbuf *, struct lwp *);
+int    dccp6_bind(struct socket *, struct sockaddr *, struct lwp *);
 int    dccp6_listen(struct socket *, struct lwp *);
 int    dccp6_connect(struct socket *, struct mbuf *, struct lwp *);
 int    dccp6_accept(struct socket *, struct mbuf *);



Home | Main Index | Thread Index | Old Index