Define 32bit version of SIOC[GS]IFADDRPREF32. We wouldn't need this to

if i386 actually aligned a uint64_t on a 64bit boundary but it doesn't.
So all that work in sockaddr_storage goes for naught.
This commit is contained in:
matt 2011-02-01 00:53:22 +00:00
parent a8f51619b3
commit 0f0d22769a
2 changed files with 50 additions and 3 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: netbsd32_ioctl.c,v 1.53 2011/01/22 20:51:21 matt Exp $ */
/* $NetBSD: netbsd32_ioctl.c,v 1.54 2011/02/01 00:53:22 matt Exp $ */
/*
* Copyright (c) 1998, 2001 Matthew R. Green
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: netbsd32_ioctl.c,v 1.53 2011/01/22 20:51:21 matt Exp $");
__KERNEL_RCSID(0, "$NetBSD: netbsd32_ioctl.c,v 1.54 2011/02/01 00:53:22 matt Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -85,6 +85,8 @@ static inline void netbsd32_to_oifreq(struct netbsd32_oifreq *, struct oifreq *,
u_long cmd);
static inline void netbsd32_to_ifreq(struct netbsd32_ifreq *, struct ifreq *,
u_long cmd);
static inline void netbsd32_to_if_addrprefreq(
const struct netbsd32_if_addrprefreq *, struct if_addrprefreq *, u_long);
static inline void netbsd32_to_ifconf(struct netbsd32_ifconf *,
struct ifconf *, u_long);
static inline void netbsd32_to_ifmediareq(struct netbsd32_ifmediareq *,
@ -102,6 +104,9 @@ static inline void netbsd32_from_format_op(struct format_op *,
struct netbsd32_format_op *,
u_long);
#endif
static inline void netbsd32_from_if_addrprefreq(const struct if_addrprefreq *,
struct netbsd32_if_addrprefreq *,
u_long);
static inline void netbsd32_from_ifreq(struct ifreq *,
struct netbsd32_ifreq *, u_long);
static inline void netbsd32_from_oifreq(struct oifreq *,
@ -172,6 +177,16 @@ netbsd32_to_oifreq(struct netbsd32_oifreq *s32p, struct oifreq *p, u_long cmd)
p->ifr_data = (void *)NETBSD32PTR64(s32p->ifr_data);
}
static inline void
netbsd32_to_if_addrprefreq(const struct netbsd32_if_addrprefreq *ifap32,
struct if_addrprefreq *ifap, u_long cmd)
{
strlcpy(ifap->ifap_name, ifap32->ifap_name, sizeof(ifap->ifap_name));
ifap->ifap_preference = ifap32->ifap_preference;
memcpy(&ifap->ifap_addr, &ifap32->ifap_addr,
max(ifap32->ifap_addr.ss_len, _SS_MAXSIZE));
}
static inline void
netbsd32_to_ifconf(struct netbsd32_ifconf *s32p, struct ifconf *p, u_long cmd)
{
@ -321,6 +336,16 @@ netbsd32_from_oifreq(struct oifreq *p, struct netbsd32_oifreq *s32p, u_long cmd)
NETBSD32PTR32(s32p->ifr_data, p->ifr_data);
}
static inline void
netbsd32_from_if_addrprefreq(const struct if_addrprefreq *ifap,
struct netbsd32_if_addrprefreq *ifap32, u_long cmd)
{
strlcpy(ifap32->ifap_name, ifap->ifap_name, sizeof(ifap32->ifap_name));
ifap32->ifap_preference = ifap->ifap_preference;
memcpy(&ifap32->ifap_addr, &ifap->ifap_addr,
max(ifap->ifap_addr.ss_len, _SS_MAXSIZE));
}
static inline void
netbsd32_from_ifconf(struct ifconf *p, struct netbsd32_ifconf *s32p, u_long cmd)
{
@ -674,6 +699,12 @@ netbsd32_ioctl(struct lwp *l, const struct netbsd32_ioctl_args *uap, register_t
case SIOCSIFFLAGS32:
IOCTL_STRUCT_CONV_TO(SIOCSIFFLAGS, ifreq);
case SIOCGIFADDRPREF32:
IOCTL_STRUCT_CONV_TO(SIOCGIFADDRPREF, if_addrprefreq);
case SIOCSIFADDRPREF32:
IOCTL_STRUCT_CONV_TO(SIOCSIFADDRPREF, if_addrprefreq);
case OSIOCGIFFLAGS32:
IOCTL_STRUCT_CONV_TO(OSIOCGIFFLAGS, oifreq);
case OSIOCSIFFLAGS32:

View File

@ -1,4 +1,4 @@
/* $NetBSD: netbsd32_ioctl.h,v 1.29 2010/09/24 13:12:53 njoly Exp $ */
/* $NetBSD: netbsd32_ioctl.h,v 1.30 2011/02/01 00:53:22 matt Exp $ */
/*
* Copyright (c) 1998, 2001 Matthew R. Green
@ -208,6 +208,19 @@ struct netbsd32_ifreq {
} ifru_b;
} ifr_ifru;
};
struct netbsd32_if_addrprefreq {
char ifap_name[IFNAMSIZ];
uint16_t ifap_preference;
struct {
__uint8_t ss_len; /* address length */
sa_family_t ss_family; /* address family */
char __ss_pad1[_SS_PAD1SIZE];
__int32_t __ss_align[2];
char __ss_pad2[_SS_PAD2SIZE];
} ifap_addr;
};
/* from <dev/pci/if_devar.h> */
#define SIOCGADDRROM32 _IOW('i', 240, struct netbsd32_ifreq) /* get 128 bytes of ROM */
#define SIOCGCHIPID32 _IOWR('i', 241, struct netbsd32_ifreq) /* get chipid */
@ -257,6 +270,9 @@ struct netbsd32_ifreq {
#define SIOCDIFADDR32 _IOW('i', 25, struct netbsd32_ifreq) /* delete IF addr */
#define OSIOCDIFADDR32 _IOW('i', 25, struct netbsd32_oifreq) /* delete IF addr */
#define SIOCSIFADDRPREF32 _IOW('i', 31, struct netbsd32_if_addrprefreq)
#define SIOCGIFADDRPREF32 _IOWR('i', 32, struct netbsd32_if_addrprefreq)
#define SIOCADDMULTI32 _IOW('i', 49, struct netbsd32_ifreq) /* add m'cast addr */
#define OSIOCADDMULTI32 _IOW('i', 49, struct netbsd32_oifreq) /* add m'cast addr */