summaryrefslogtreecommitdiffstats
path: root/src/tuntap.c
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-11-29 05:33:12 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-11-29 05:35:49 +0100
commit61349d3d273aa23935b0c413c5885005db2669db (patch)
tree9cbc05acb31476d45b48d4a51e9edca19328b8e8 /src/tuntap.c
parentc13fe36e4c0730037ae75d51f7f052d916486aac (diff)
downloadfastd-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/tuntap.c')
-rw-r--r--src/tuntap.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/tuntap.c b/src/tuntap.c
index b1820f9..1204049 100644
--- a/src/tuntap.c
+++ b/src/tuntap.c
@@ -310,15 +310,15 @@ fastd_buffer_t fastd_tuntap_read(fastd_context_t *ctx) {
void fastd_tuntap_write(fastd_context_t *ctx, fastd_buffer_t buffer) {
if (multiaf_tun && ctx->conf->mode == MODE_TUN) {
uint8_t version = *((uint8_t*)buffer.data) >> 4;
- int af;
+ uint32_t af;
switch (version) {
case 4:
- af = AF_INET;
+ af = htonl(AF_INET);
break;
case 6:
- af = AF_INET6;
+ af = htonl(AF_INET6);
break;
default:
@@ -327,7 +327,7 @@ void fastd_tuntap_write(fastd_context_t *ctx, fastd_buffer_t buffer) {
}
fastd_buffer_pull_head(ctx, &buffer, 4);
- *((uint32_t*)buffer.data) = htonl(af);
+ memcpy(buffer.data, &af, 4);
}
if (write(ctx->tunfd, buffer.data, buffer.len) < 0)