summaryrefslogtreecommitdiffstats
path: root/src/socket.c
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-08-07 02:30:23 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-08-07 02:30:23 +0200
commit5ca89b31210b249f79a1a5cd1a258c85fdb7970e (patch)
treee08c894ab12d68c215713317d841ac6de552e619 /src/socket.c
parentae90406453eb894400a25e0557bb2c7bf19f06a4 (diff)
downloadfastd-5ca89b31210b249f79a1a5cd1a258c85fdb7970e.tar
fastd-5ca89b31210b249f79a1a5cd1a258c85fdb7970e.zip
Guard socket options not available on FreeBSD
Diffstat (limited to 'src/socket.c')
-rw-r--r--src/socket.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/socket.c b/src/socket.c
index c53695b..c5356f7 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -61,10 +61,13 @@ static int bind_socket(fastd_context_t *ctx, const fastd_bind_address_t *addr, b
fastd_setfl(ctx, fd, O_NONBLOCK, 0);
int one = 1;
+
+#ifdef USE_PKTINFO
if (setsockopt(fd, IPPROTO_IP, IP_PKTINFO, &one, sizeof(one))) {
pr_error_errno(ctx, "setsockopt: unable to set IP_PKTINFO");
goto error;
}
+#endif
if (af == AF_INET6) {
if (setsockopt(fd, IPPROTO_IPV6, IPV6_RECVPKTINFO, &one, sizeof(one))) {
@@ -73,6 +76,7 @@ static int bind_socket(fastd_context_t *ctx, const fastd_bind_address_t *addr, b
}
}
+#ifdef USE_BINDTODEVICE
if (addr->bindtodev) {
if (setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, addr->bindtodev, strlen(addr->bindtodev))) {
if (warn)
@@ -80,7 +84,9 @@ static int bind_socket(fastd_context_t *ctx, const fastd_bind_address_t *addr, b
goto error;
}
}
+#endif
+#ifdef USE_PMTU
if (ctx->conf->pmtu.set) {
int pmtu = ctx->conf->pmtu.state ? IP_PMTUDISC_DO : IP_PMTUDISC_DONT;
if (setsockopt(fd, IPPROTO_IP, IP_MTU_DISCOVER, &pmtu, sizeof(pmtu))) {
@@ -88,6 +94,7 @@ static int bind_socket(fastd_context_t *ctx, const fastd_bind_address_t *addr, b
goto error;
}
}
+#endif
fastd_peer_address_t bind_address = addr->addr;