diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2013-11-29 05:33:12 +0100 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2013-11-29 05:35:49 +0100 |
commit | 61349d3d273aa23935b0c413c5885005db2669db (patch) | |
tree | 9cbc05acb31476d45b48d4a51e9edca19328b8e8 /src/send.c | |
parent | c13fe36e4c0730037ae75d51f7f052d916486aac (diff) | |
download | fastd-61349d3d273aa23935b0c413c5885005db2669db.tar fastd-61349d3d273aa23935b0c413c5885005db2669db.zip |
Compile with -std=c99 and restructure some code to ensure there is no invalid aliasing (hopefully)
Diffstat (limited to 'src/send.c')
-rw-r--r-- | src/send.c | 13 |
1 files changed, 8 insertions, 5 deletions
@@ -42,8 +42,9 @@ static inline void add_pktinfo(struct msghdr *msg, const fastd_peer_address_t *l msg->msg_controllen += cmsg->cmsg_len; - struct in_pktinfo *pktinfo = (struct in_pktinfo*)CMSG_DATA(cmsg); - pktinfo->ipi_spec_dst = local_addr->in.sin_addr; + struct in_pktinfo pktinfo = {}; + pktinfo.ipi_spec_dst = local_addr->in.sin_addr; + memcpy(CMSG_DATA(cmsg), &pktinfo, sizeof(pktinfo)); return; } #endif @@ -55,11 +56,13 @@ static inline void add_pktinfo(struct msghdr *msg, const fastd_peer_address_t *l msg->msg_controllen += cmsg->cmsg_len; - struct in6_pktinfo *pktinfo = (struct in6_pktinfo*)CMSG_DATA(cmsg); - pktinfo->ipi6_addr = local_addr->in6.sin6_addr; + struct in6_pktinfo pktinfo = {}; + pktinfo.ipi6_addr = local_addr->in6.sin6_addr; if (IN6_IS_ADDR_LINKLOCAL(&local_addr->in6.sin6_addr)) - pktinfo->ipi6_ifindex = local_addr->in6.sin6_scope_id; + pktinfo.ipi6_ifindex = local_addr->in6.sin6_scope_id; + + memcpy(CMSG_DATA(cmsg), &pktinfo, sizeof(pktinfo)); } } |