summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authordyoung <dyoung@NetBSD.org>2007-09-01 04:32:50 +0000
committerdyoung <dyoung@NetBSD.org>2007-09-01 04:32:50 +0000
commit2fc102750d6426cd49a560ec309d16d3a5022ae4 (patch)
tree01dc34a21ce59dbdc60bb7af17db129cbcbcbd36 /sys
parentf9794c16db838731ee2eb7afc0dd94697f414bf1 (diff)
Use ifreq_setaddr(), ifreq_getaddr(), sockaddr_in_init(), and
sockaddr_copy(). Constify. Compare pointers with NULL, not 0. Don't "test truth" of pointers, but compare with NULL.
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/ic/hd64570.c6
-rw-r--r--sys/dev/ic/midway.c6
-rw-r--r--sys/dev/ic/smc90cx6.c6
-rw-r--r--sys/dev/ppbus/if_plip.c6
-rw-r--r--sys/net/if_loop.c6
-rw-r--r--sys/net/if_ppp.c8
-rw-r--r--sys/net/if_sl.c6
-rw-r--r--sys/net/if_stf.c7
-rw-r--r--sys/net/if_strip.c6
-rw-r--r--sys/net/if_tun.c6
-rw-r--r--sys/netatalk/at_control.c80
-rw-r--r--sys/netinet/in.c36
-rw-r--r--sys/netinet/in_var.h4
13 files changed, 95 insertions, 88 deletions
diff --git a/sys/dev/ic/hd64570.c b/sys/dev/ic/hd64570.c
index d16497edb61..9c2725511bd 100644
--- a/sys/dev/ic/hd64570.c
+++ b/sys/dev/ic/hd64570.c
@@ -1,4 +1,4 @@
-/* $NetBSD: hd64570.c,v 1.36 2007/03/04 06:01:55 christos Exp $ */
+/* $NetBSD: hd64570.c,v 1.37 2007/09/01 04:32:50 dyoung Exp $ */
/*
* Copyright (c) 1999 Christian E. Hopps
@@ -65,7 +65,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hd64570.c,v 1.36 2007/03/04 06:01:55 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hd64570.c,v 1.37 2007/09/01 04:32:50 dyoung Exp $");
#include "bpfilter.h"
#include "opt_inet.h"
@@ -981,7 +981,7 @@ sca_ioctl(ifp, cmd, addr)
error = EAFNOSUPPORT; /* XXX */
break;
}
- switch (ifr->ifr_addr.sa_family) {
+ switch (ifreq_getaddr(cmd, ifr)->sa_family) {
#ifdef INET
case AF_INET:
break;
diff --git a/sys/dev/ic/midway.c b/sys/dev/ic/midway.c
index faea82099be..a32e1f0fc40 100644
--- a/sys/dev/ic/midway.c
+++ b/sys/dev/ic/midway.c
@@ -1,4 +1,4 @@
-/* $NetBSD: midway.c,v 1.75 2007/03/04 06:01:58 christos Exp $ */
+/* $NetBSD: midway.c,v 1.76 2007/09/01 04:32:50 dyoung Exp $ */
/* (sync'd to midway.c 1.68) */
/*
@@ -68,7 +68,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: midway.c,v 1.75 2007/03/04 06:01:58 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: midway.c,v 1.76 2007/09/01 04:32:50 dyoung Exp $");
#include "opt_natm.h"
@@ -1275,7 +1275,7 @@ void *data;
error = EAFNOSUPPORT; /* XXX */
break;
}
- switch (ifr->ifr_addr.sa_family) {
+ switch (ifreq_getaddr(cmd, ifr)->sa_family) {
#ifdef INET
case AF_INET:
break;
diff --git a/sys/dev/ic/smc90cx6.c b/sys/dev/ic/smc90cx6.c
index 60d9be9efe6..1434ed49c35 100644
--- a/sys/dev/ic/smc90cx6.c
+++ b/sys/dev/ic/smc90cx6.c
@@ -1,4 +1,4 @@
-/* $NetBSD: smc90cx6.c,v 1.48 2007/07/11 19:15:02 he Exp $ */
+/* $NetBSD: smc90cx6.c,v 1.49 2007/09/01 04:32:50 dyoung Exp $ */
/*-
* Copyright (c) 1994, 1995, 1998 The NetBSD Foundation, Inc.
@@ -42,7 +42,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: smc90cx6.c,v 1.48 2007/07/11 19:15:02 he Exp $");
+__KERNEL_RCSID(0, "$NetBSD: smc90cx6.c,v 1.49 2007/09/01 04:32:50 dyoung Exp $");
/* #define BAHSOFTCOPY */
#define BAHRETRANSMIT /**/
@@ -964,7 +964,7 @@ bah_ioctl(ifp, command, data)
case SIOCADDMULTI:
case SIOCDELMULTI:
- switch (ifr->ifr_addr.sa_family) {
+ switch (ifreq_getaddr(cmd, ifr)->sa_family) {
case AF_INET:
case AF_INET6:
error = 0;
diff --git a/sys/dev/ppbus/if_plip.c b/sys/dev/ppbus/if_plip.c
index 956133e9ad0..ee7d4746d65 100644
--- a/sys/dev/ppbus/if_plip.c
+++ b/sys/dev/ppbus/if_plip.c
@@ -1,4 +1,4 @@
-/* $NetBSD: if_plip.c,v 1.13 2007/04/04 16:31:05 drochner Exp $ */
+/* $NetBSD: if_plip.c,v 1.14 2007/09/01 04:32:50 dyoung Exp $ */
/*-
* Copyright (c) 1997 Poul-Henning Kamp
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_plip.c,v 1.13 2007/04/04 16:31:05 drochner Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_plip.c,v 1.14 2007/09/01 04:32:50 dyoung Exp $");
/*
* Parallel port TCP/IP interfaces added. I looked at the driver from
@@ -445,7 +445,7 @@ lpioctl (struct ifnet *ifp, u_long cmd, void *data)
error = EAFNOSUPPORT; /* XXX */
break;
}
- switch (ifr->ifr_addr.sa_family) {
+ switch (ifreq_getaddr(cmd, ifr)->sa_family) {
case AF_INET:
break;
default:
diff --git a/sys/net/if_loop.c b/sys/net/if_loop.c
index 08e824ef8f0..838cad0e305 100644
--- a/sys/net/if_loop.c
+++ b/sys/net/if_loop.c
@@ -1,4 +1,4 @@
-/* $NetBSD: if_loop.c,v 1.64 2007/03/04 06:03:16 christos Exp $ */
+/* $NetBSD: if_loop.c,v 1.65 2007/09/01 04:32:50 dyoung Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -65,7 +65,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_loop.c,v 1.64 2007/03/04 06:03:16 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_loop.c,v 1.65 2007/09/01 04:32:50 dyoung Exp $");
#include "opt_inet.h"
#include "opt_atalk.h"
@@ -445,7 +445,7 @@ loioctl(struct ifnet *ifp, u_long cmd, void *data)
error = EAFNOSUPPORT; /* XXX */
break;
}
- switch (ifr->ifr_addr.sa_family) {
+ switch (ifreq_getaddr(cmd, ifr)->sa_family) {
#ifdef INET
case AF_INET:
diff --git a/sys/net/if_ppp.c b/sys/net/if_ppp.c
index 4bf94a4fe0c..45d2ba57a8b 100644
--- a/sys/net/if_ppp.c
+++ b/sys/net/if_ppp.c
@@ -1,4 +1,4 @@
-/* $NetBSD: if_ppp.c,v 1.116 2007/07/14 21:02:40 ad Exp $ */
+/* $NetBSD: if_ppp.c,v 1.117 2007/09/01 04:32:50 dyoung Exp $ */
/* Id: if_ppp.c,v 1.6 1997/03/04 03:33:00 paulus Exp */
/*
@@ -102,7 +102,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.116 2007/07/14 21:02:40 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.117 2007/09/01 04:32:50 dyoung Exp $");
#include "ppp.h"
@@ -810,11 +810,11 @@ pppsioctl(struct ifnet *ifp, u_long cmd, void *data)
case SIOCADDMULTI:
case SIOCDELMULTI:
- if (ifr == 0) {
+ if (ifr == NULL) {
error = EAFNOSUPPORT;
break;
}
- switch (ifr->ifr_addr.sa_family) {
+ switch (ifreq_getaddr(cmd, ifr)->sa_family) {
#ifdef INET
case AF_INET:
break;
diff --git a/sys/net/if_sl.c b/sys/net/if_sl.c
index 18dff755be2..ffb847fca3f 100644
--- a/sys/net/if_sl.c
+++ b/sys/net/if_sl.c
@@ -1,4 +1,4 @@
-/* $NetBSD: if_sl.c,v 1.106 2007/07/14 21:02:41 ad Exp $ */
+/* $NetBSD: if_sl.c,v 1.107 2007/09/01 04:32:50 dyoung Exp $ */
/*
* Copyright (c) 1987, 1989, 1992, 1993
@@ -60,7 +60,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_sl.c,v 1.106 2007/07/14 21:02:41 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_sl.c,v 1.107 2007/09/01 04:32:50 dyoung Exp $");
#include "opt_inet.h"
#include "bpfilter.h"
@@ -1017,7 +1017,7 @@ slioctl(struct ifnet *ifp, u_long cmd, void *data)
error = EAFNOSUPPORT; /* XXX */
break;
}
- switch (ifr->ifr_addr.sa_family) {
+ switch (ifreq_getaddr(cmd, ifr)->sa_family) {
#ifdef INET
case AF_INET:
diff --git a/sys/net/if_stf.c b/sys/net/if_stf.c
index 7772718e982..e8782e068c7 100644
--- a/sys/net/if_stf.c
+++ b/sys/net/if_stf.c
@@ -1,4 +1,4 @@
-/* $NetBSD: if_stf.c,v 1.60 2007/05/02 20:40:23 dyoung Exp $ */
+/* $NetBSD: if_stf.c,v 1.61 2007/09/01 04:32:51 dyoung Exp $ */
/* $KAME: if_stf.c,v 1.62 2001/06/07 22:32:16 itojun Exp $ */
/*
@@ -75,7 +75,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_stf.c,v 1.60 2007/05/02 20:40:23 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_stf.c,v 1.61 2007/09/01 04:32:51 dyoung Exp $");
#include "opt_inet.h"
@@ -703,7 +703,8 @@ stf_ioctl(struct ifnet *ifp, u_long cmd, void *data)
case SIOCADDMULTI:
case SIOCDELMULTI:
ifr = (struct ifreq *)data;
- if (ifr != NULL && ifr->ifr_addr.sa_family == AF_INET6)
+ if (ifr != NULL &&
+ ifreq_getaddr(cmd, ifr)->sa_family == AF_INET6)
;
else
error = EAFNOSUPPORT;
diff --git a/sys/net/if_strip.c b/sys/net/if_strip.c
index 8dc66b9667a..5b6b41e7c7e 100644
--- a/sys/net/if_strip.c
+++ b/sys/net/if_strip.c
@@ -1,4 +1,4 @@
-/* $NetBSD: if_strip.c,v 1.80 2007/08/27 14:57:47 dyoung Exp $ */
+/* $NetBSD: if_strip.c,v 1.81 2007/09/01 04:32:51 dyoung Exp $ */
/* from: NetBSD: if_sl.c,v 1.38 1996/02/13 22:00:23 christos Exp $ */
/*
@@ -87,7 +87,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_strip.c,v 1.80 2007/08/27 14:57:47 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_strip.c,v 1.81 2007/09/01 04:32:51 dyoung Exp $");
#include "opt_inet.h"
#include "bpfilter.h"
@@ -1301,7 +1301,7 @@ stripioctl(struct ifnet *ifp, u_long cmd, void *data)
error = EAFNOSUPPORT; /* XXX */
break;
}
- switch (ifr->ifr_addr.sa_family) {
+ switch (ifreq_getaddr(cmd, ifr)->sa_family) {
#ifdef INET
case AF_INET:
diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c
index caaa2fc0404..93455b691bf 100644
--- a/sys/net/if_tun.c
+++ b/sys/net/if_tun.c
@@ -1,4 +1,4 @@
-/* $NetBSD: if_tun.c,v 1.97 2007/03/04 06:03:17 christos Exp $ */
+/* $NetBSD: if_tun.c,v 1.98 2007/09/01 04:32:51 dyoung Exp $ */
/*
* Copyright (c) 1988, Julian Onions <jpo@cs.nott.ac.uk>
@@ -15,7 +15,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_tun.c,v 1.97 2007/03/04 06:03:17 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_tun.c,v 1.98 2007/09/01 04:32:51 dyoung Exp $");
#include "opt_inet.h"
@@ -457,7 +457,7 @@ tun_ioctl(struct ifnet *ifp, u_long cmd, void *data)
error = EAFNOSUPPORT; /* XXX */
break;
}
- switch (ifr->ifr_addr.sa_family) {
+ switch (ifreq_getaddr(cmd, ifr)->sa_family) {
#ifdef INET
case AF_INET:
break;
diff --git a/sys/netatalk/at_control.c b/sys/netatalk/at_control.c
index d8309e5ae39..a1fee69979e 100644
--- a/sys/netatalk/at_control.c
+++ b/sys/netatalk/at_control.c
@@ -1,4 +1,4 @@
-/* $NetBSD: at_control.c,v 1.19 2007/07/09 21:11:01 ad Exp $ */
+/* $NetBSD: at_control.c,v 1.20 2007/09/01 04:32:51 dyoung Exp $ */
/*
* Copyright (c) 1990,1994 Regents of The University of Michigan.
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: at_control.c,v 1.19 2007/07/09 21:11:01 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: at_control.c,v 1.20 2007/09/01 04:32:51 dyoung Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -51,19 +51,19 @@ __KERNEL_RCSID(0, "$NetBSD: at_control.c,v 1.19 2007/07/09 21:11:01 ad Exp $");
#include <netatalk/phase2.h>
#include <netatalk/at_extern.h>
-static int aa_dorangeroute __P((struct ifaddr * ifa,
- u_int first, u_int last, int cmd));
-static int aa_addsingleroute __P((struct ifaddr * ifa,
- struct at_addr * addr, struct at_addr * mask));
-static int aa_delsingleroute __P((struct ifaddr * ifa,
- struct at_addr * addr, struct at_addr * mask));
-static int aa_dosingleroute __P((struct ifaddr * ifa, struct at_addr * addr,
- struct at_addr * mask, int cmd, int flags));
-static int at_scrub __P((struct ifnet * ifp, struct at_ifaddr * aa));
-static int at_ifinit __P((struct ifnet * ifp, struct at_ifaddr * aa,
- struct sockaddr_at * sat));
+static int aa_dorangeroute(struct ifaddr * ifa,
+ u_int first, u_int last, int cmd);
+static int aa_addsingleroute(struct ifaddr * ifa,
+ struct at_addr * addr, struct at_addr * mask);
+static int aa_delsingleroute(struct ifaddr * ifa,
+ struct at_addr * addr, struct at_addr * mask);
+static int aa_dosingleroute(struct ifaddr * ifa, struct at_addr * addr,
+ struct at_addr * mask, int cmd, int flags);
+static int at_scrub(struct ifnet * ifp, struct at_ifaddr * aa);
+static int at_ifinit(struct ifnet *, struct at_ifaddr *,
+ const struct sockaddr_at *);
#if 0
-static void aa_clean __P((void));
+static void aa_clean(void);
#endif
#define sateqaddr(a,b) ((a)->sat_len == (b)->sat_len && \
@@ -79,8 +79,9 @@ at_control(cmd, data, ifp, l)
struct lwp *l;
{
struct ifreq *ifr = (struct ifreq *) data;
- struct sockaddr_at *sat;
+ const struct sockaddr_at *csat;
struct netrange *nr;
+ const struct netrange *cnr;
struct at_aliasreq *ifra = (struct at_aliasreq *) data;
struct at_ifaddr *aa0;
struct at_ifaddr *aa = 0;
@@ -134,9 +135,9 @@ at_control(cmd, data, ifp, l)
NULL) != 0)
return (EPERM);
- sat = satosat(&ifr->ifr_addr);
- nr = (struct netrange *) sat->sat_zero;
- if (nr->nr_phase == 1) {
+ csat = satocsat(ifreq_getaddr(cmd, ifr));
+ cnr = (const struct netrange *)csat->sat_zero;
+ if (cnr->nr_phase == 1) {
/*
* Look for a phase 1 address on this interface.
* This may leave aa pointing to the first address on
@@ -221,7 +222,7 @@ at_control(cmd, data, ifp, l)
/*
* Set/clear the phase 2 bit.
*/
- if (nr->nr_phase == 1)
+ if (cnr->nr_phase == 1)
aa->aa_flags &= ~AFA_PHASE2;
else
aa->aa_flags |= AFA_PHASE2;
@@ -240,9 +241,9 @@ at_control(cmd, data, ifp, l)
break;
case SIOCGIFADDR:
- sat = satosat(&ifr->ifr_addr);
- nr = (struct netrange *) sat->sat_zero;
- if (nr->nr_phase == 1) {
+ csat = satocsat(ifreq_getaddr(cmd, ifr));
+ cnr = (const struct netrange *)csat->sat_zero;
+ if (cnr->nr_phase == 1) {
/*
* If the request is specifying phase 1, then
* only look at a phase one address
@@ -252,7 +253,7 @@ at_control(cmd, data, ifp, l)
(aa->aa_flags & AFA_PHASE2) == 0)
break;
}
- } else if (nr->nr_phase == 2) {
+ } else if (cnr->nr_phase == 2) {
/*
* If the request is specifying phase 2, then
* only look at a phase two address
@@ -282,34 +283,37 @@ at_control(cmd, data, ifp, l)
* the "aa" pointer is valid when needed.
*/
switch (cmd) {
- case SIOCGIFADDR:
+ case SIOCGIFADDR: {
+ union {
+ struct sockaddr sa;
+ struct sockaddr_at sat;
+ } u;
/*
* copy the contents of the sockaddr blindly.
*/
- sat = (struct sockaddr_at *) & ifr->ifr_addr;
- *sat = aa->aa_addr;
-
+ sockaddr_copy(&u.sa, sizeof(u),
+ (const struct sockaddr *)&aa->aa_addr);
/*
* and do some cleanups
*/
- ((struct netrange *) &sat->sat_zero)->nr_phase =
- (aa->aa_flags & AFA_PHASE2) ? 2 : 1;
- ((struct netrange *) &sat->sat_zero)->nr_firstnet =
- aa->aa_firstnet;
- ((struct netrange *) &sat->sat_zero)->nr_lastnet =
- aa->aa_lastnet;
+ nr = (struct netrange *)&u.sat.sat_zero;
+ nr->nr_phase = (aa->aa_flags & AFA_PHASE2) ? 2 : 1;
+ nr->nr_firstnet = aa->aa_firstnet;
+ nr->nr_lastnet = aa->aa_lastnet;
+ ifreq_setaddr(cmd, ifr, &u.sa);
break;
+ }
case SIOCSIFADDR:
- return (at_ifinit(ifp, aa,
- (struct sockaddr_at *) &ifr->ifr_addr));
+ return at_ifinit(ifp, aa,
+ (const struct sockaddr_at *)ifreq_getaddr(cmd, ifr));
case SIOCAIFADDR:
if (sateqaddr(&ifra->ifra_addr, &aa->aa_addr))
return 0;
- return (at_ifinit(ifp, aa,
- (struct sockaddr_at *) &ifr->ifr_addr));
+ return at_ifinit(ifp, aa,
+ (const struct sockaddr_at *)ifreq_getaddr(cmd, ifr));
case SIOCDIFADDR:
at_purgeaddr((struct ifaddr *) aa, ifp);
@@ -396,7 +400,7 @@ static int
at_ifinit(ifp, aa, sat)
struct ifnet *ifp;
struct at_ifaddr *aa;
- struct sockaddr_at *sat;
+ const struct sockaddr_at *sat;
{
struct netrange nr, onr;
struct sockaddr_at oldaddr;
diff --git a/sys/netinet/in.c b/sys/netinet/in.c
index 9e77ac9c4cc..537bb829c75 100644
--- a/sys/netinet/in.c
+++ b/sys/netinet/in.c
@@ -1,4 +1,4 @@
-/* $NetBSD: in.c,v 1.117 2007/04/15 06:15:58 dyoung Exp $ */
+/* $NetBSD: in.c,v 1.118 2007/09/01 04:32:51 dyoung Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -98,7 +98,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in.c,v 1.117 2007/04/15 06:15:58 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in.c,v 1.118 2007/09/01 04:32:51 dyoung Exp $");
#include "opt_inet.h"
#include "opt_inet_conf.h"
@@ -451,30 +451,30 @@ in_control(struct socket *so, u_long cmd, void *data, struct ifnet *ifp,
switch (cmd) {
case SIOCGIFADDR:
- *satosin(&ifr->ifr_addr) = ia->ia_addr;
+ ifreq_setaddr(cmd, ifr, sintocsa(&ia->ia_addr));
break;
case SIOCGIFBRDADDR:
if ((ifp->if_flags & IFF_BROADCAST) == 0)
return (EINVAL);
- *satosin(&ifr->ifr_dstaddr) = ia->ia_broadaddr;
+ ifreq_setdstaddr(cmd, ifr, sintocsa(&ia->ia_broadaddr));
break;
case SIOCGIFDSTADDR:
if ((ifp->if_flags & IFF_POINTOPOINT) == 0)
return (EINVAL);
- *satosin(&ifr->ifr_dstaddr) = ia->ia_dstaddr;
+ ifreq_setdstaddr(cmd, ifr, sintocsa(&ia->ia_dstaddr));
break;
case SIOCGIFNETMASK:
- *satosin(&ifr->ifr_addr) = ia->ia_sockmask;
+ ifreq_setaddr(cmd, ifr, sintocsa(&ia->ia_sockmask));
break;
case SIOCSIFDSTADDR:
if ((ifp->if_flags & IFF_POINTOPOINT) == 0)
return (EINVAL);
oldaddr = ia->ia_dstaddr;
- ia->ia_dstaddr = *satosin(&ifr->ifr_dstaddr);
+ ia->ia_dstaddr = *satocsin(ifreq_getdstaddr(cmd, ifr));
if (ifp->if_ioctl != NULL &&
(error = (*ifp->if_ioctl)(ifp, SIOCSIFDSTADDR,
(void *)ia)) != 0) {
@@ -492,11 +492,12 @@ in_control(struct socket *so, u_long cmd, void *data, struct ifnet *ifp,
case SIOCSIFBRDADDR:
if ((ifp->if_flags & IFF_BROADCAST) == 0)
return EINVAL;
- ia->ia_broadaddr = *satosin(&ifr->ifr_broadaddr);
+ ia->ia_broadaddr = *satocsin(ifreq_getbroadaddr(cmd, ifr));
break;
case SIOCSIFADDR:
- error = in_ifinit(ifp, ia, satosin(&ifr->ifr_addr), 1);
+ error = in_ifinit(ifp, ia, satocsin(ifreq_getaddr(cmd, ifr)),
+ 1);
#ifdef PFIL_HOOKS
if (error == 0)
(void)pfil_run_hooks(&if_pfil,
@@ -506,7 +507,7 @@ in_control(struct socket *so, u_long cmd, void *data, struct ifnet *ifp,
case SIOCSIFNETMASK:
in_ifscrub(ifp, ia);
- ia->ia_sockmask = *satosin(&ifr->ifr_addr);
+ ia->ia_sockmask = *satocsin(ifreq_getaddr(cmd, ifr));
ia->ia_subnetmask = ia->ia_sockmask.sin_addr.s_addr;
error = in_ifinit(ifp, ia, NULL, 0);
break;
@@ -885,13 +886,13 @@ in_ifscrub(struct ifnet *ifp, struct in_ifaddr *ia)
*/
int
in_ifinit(struct ifnet *ifp, struct in_ifaddr *ia,
- struct sockaddr_in *sin, int scrub)
+ const struct sockaddr_in *sin, int scrub)
{
u_int32_t i;
struct sockaddr_in oldaddr;
int s = splnet(), flags = RTF_UP, error;
- if (!sin)
+ if (sin == NULL)
sin = &ia->ia_addr;
/*
@@ -1133,6 +1134,7 @@ in_broadcast(struct in_addr in, struct ifnet *ifp)
struct in_multi *
in_addmulti(struct in_addr *ap, struct ifnet *ifp)
{
+ struct sockaddr_in sin;
struct in_multi *inm;
struct ifreq ifr;
int s = splsoftnet();
@@ -1166,9 +1168,8 @@ in_addmulti(struct in_addr *ap, struct ifnet *ifp)
* Ask the network driver to update its multicast reception
* filter appropriately for the new address.
*/
- satosin(&ifr.ifr_addr)->sin_len = sizeof(struct sockaddr_in);
- satosin(&ifr.ifr_addr)->sin_family = AF_INET;
- satosin(&ifr.ifr_addr)->sin_addr = *ap;
+ sockaddr_in_init(&sin, ap, 0);
+ ifreq_setaddr(SIOCADDMULTI, &ifr, sintosa(&sin));
if ((ifp->if_ioctl == NULL) ||
(*ifp->if_ioctl)(ifp, SIOCADDMULTI,(void *)&ifr) != 0) {
LIST_REMOVE(inm, inm_list);
@@ -1197,6 +1198,7 @@ in_addmulti(struct in_addr *ap, struct ifnet *ifp)
void
in_delmulti(struct in_multi *inm)
{
+ struct sockaddr_in sin;
struct ifreq ifr;
int s = splsoftnet();
@@ -1215,8 +1217,8 @@ in_delmulti(struct in_multi *inm)
* Notify the network driver to update its multicast reception
* filter.
*/
- satosin(&ifr.ifr_addr)->sin_family = AF_INET;
- satosin(&ifr.ifr_addr)->sin_addr = inm->inm_addr;
+ sockaddr_in_init(&sin, &inm->inm_addr, 0);
+ ifreq_setaddr(SIOCDELMULTI, &ifr, sintosa(&sin));
(*inm->inm_ifp->if_ioctl)(inm->inm_ifp, SIOCDELMULTI,
(void *)&ifr);
pool_put(&inmulti_pool, inm);
diff --git a/sys/netinet/in_var.h b/sys/netinet/in_var.h
index cff6c7e977a..7e87b27a65f 100644
--- a/sys/netinet/in_var.h
+++ b/sys/netinet/in_var.h
@@ -1,4 +1,4 @@
-/* $NetBSD: in_var.h,v 1.58 2007/03/04 06:03:20 christos Exp $ */
+/* $NetBSD: in_var.h,v 1.59 2007/09/01 04:32:51 dyoung Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -293,7 +293,7 @@ struct in_multistep {
struct ifaddr;
int in_ifinit(struct ifnet *,
- struct in_ifaddr *, struct sockaddr_in *, int);
+ struct in_ifaddr *, const struct sockaddr_in *, int);
void in_savemkludge(struct in_ifaddr *);
void in_restoremkludge(struct in_ifaddr *, struct ifnet *);
void in_purgemkludge(struct ifnet *);