[Olsr-dev] FreeBSD/arm alignment problem
John Hay
(spam-protected)
Sat Sep 29 13:18:08 CEST 2007
Hi,
It looks like from the last time I compiled olsr on FreeBSD/arm (about
March) the compiler and alignment rules changed. The stuff to and from
recvmsg() needs to be aligned. I had a look at how they did it in
src/lib/libc/rpc/clnt_vc.c and used that method.
I have also changed the bzero() call to memset() to be more consistent
with the rest of the file.
With these changes olsr do run on FreeBSD/arm.
John
--
John Hay -- (spam-protected) / (spam-protected)
--- src/bsd/net.c.orig 2007-09-07 14:05:15.000000000 +0200
+++ src/bsd/net.c 2007-09-27 14:22:35.000000000 +0200
@@ -727,6 +727,10 @@
{
struct msghdr mhdr;
struct iovec iov;
+ union {
+ struct cmsghdr cmsg;
+ unsigned char chdr[4096];
+ } cmu;
struct cmsghdr *cm;
struct sockaddr_dl *sdl;
struct sockaddr_in *sin = (struct sockaddr_in *) from; //XXX
@@ -736,20 +740,19 @@
struct interface *ifc;
char addrstr[INET6_ADDRSTRLEN];
char iname[IFNAMSIZ];
- unsigned char chdr[4096];
int count;
- bzero(&mhdr, sizeof(mhdr));
- bzero(&iov, sizeof(iov));
+ memset(&mhdr, 0, sizeof(mhdr));
+ memset(&iov, 0, sizeof(iov));
mhdr.msg_name = (caddr_t) from;
mhdr.msg_namelen = *fromlen;
mhdr.msg_iov = &iov;
mhdr.msg_iovlen = 1;
- mhdr.msg_control = (caddr_t) chdr;
- mhdr.msg_controllen = sizeof (chdr);
+ mhdr.msg_control = (caddr_t) &cmu;
+ mhdr.msg_controllen = sizeof (cmu);
- iov.iov_len = MAXMESSAGESIZE;
+ iov.iov_len = len;
iov.iov_base = buf;
count = recvmsg (s, &mhdr, MSG_DONTWAIT);
@@ -775,9 +778,9 @@
}
else
{
- cm = (struct cmsghdr *) chdr;
+ cm = &cmu.cmsg;
sdl = (struct sockaddr_dl *) CMSG_DATA (cm);
- bzero (iname, sizeof (iname));
+ memset (iname, 0, sizeof (iname));
memcpy (iname, sdl->sdl_data, sdl->sdl_nlen);
}
More information about the Olsr-dev
mailing list