Use sockaddr_in_init() and ifreq_setaddr() to initialize a sockaddr_in
and an ifreq.ifr_addr, respectively. Get rid of an extraneous cast---down the elevator shaft! Change 'ireq' to 'ifr', which is what the kernel calls a temporary struct ifreq virtually everywhere else.
This commit is contained in:
parent
353d6b2744
commit
bb04fc71fb
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: nfs_boot.c,v 1.68 2007/07/19 20:49:00 dyoung Exp $ */
|
/* $NetBSD: nfs_boot.c,v 1.69 2007/08/31 22:02:58 dyoung Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1995, 1997 The NetBSD Foundation, Inc.
|
* Copyright (c) 1995, 1997 The NetBSD Foundation, Inc.
|
||||||
|
@ -42,7 +42,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: nfs_boot.c,v 1.68 2007/07/19 20:49:00 dyoung Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: nfs_boot.c,v 1.69 2007/08/31 22:02:58 dyoung Exp $");
|
||||||
|
|
||||||
#include "opt_nfs.h"
|
#include "opt_nfs.h"
|
||||||
#include "opt_tftproot.h"
|
#include "opt_tftproot.h"
|
||||||
|
@ -306,8 +306,9 @@ nfs_boot_deladdress(ifp, lwp, addr)
|
||||||
u_int32_t addr;
|
u_int32_t addr;
|
||||||
{
|
{
|
||||||
struct socket *so;
|
struct socket *so;
|
||||||
struct ifreq ireq;
|
struct ifreq ifr;
|
||||||
struct sockaddr_in *sin;
|
struct sockaddr_in sin;
|
||||||
|
struct in_addr ia = {.s_addr = addr};
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -320,15 +321,13 @@ nfs_boot_deladdress(ifp, lwp, addr)
|
||||||
return (error);
|
return (error);
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(&ireq, 0, sizeof(ireq));
|
memset(&ifr, 0, sizeof(ifr));
|
||||||
memcpy(ireq.ifr_name, ifp->if_xname, IFNAMSIZ);
|
memcpy(ifr.ifr_name, ifp->if_xname, IFNAMSIZ);
|
||||||
|
|
||||||
sin = (struct sockaddr_in *)&ireq.ifr_addr;
|
sockaddr_in_init(&sin, &ia, 0);
|
||||||
sin->sin_len = sizeof(*sin);
|
ifreq_setaddr(SIOCDIFADDR, &ifr, sintocsa(&sin));
|
||||||
sin->sin_family = AF_INET;
|
|
||||||
sin->sin_addr.s_addr = addr;
|
|
||||||
|
|
||||||
error = ifioctl(so, SIOCDIFADDR, (void *)&ireq, lwp);
|
error = ifioctl(so, SIOCDIFADDR, &ifr, lwp);
|
||||||
if (error) {
|
if (error) {
|
||||||
printf("deladdress, error=%d\n", error);
|
printf("deladdress, error=%d\n", error);
|
||||||
goto out;
|
goto out;
|
||||||
|
|
Loading…
Reference in New Issue