diff options
Diffstat (limited to 'lib/sockunion.c')
-rw-r--r-- | lib/sockunion.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/sockunion.c b/lib/sockunion.c index f6c060f5..5de3bcfc 100644 --- a/lib/sockunion.c +++ b/lib/sockunion.c @@ -528,6 +528,30 @@ sockopt_ttl (int family, int sock, int ttl) } int +sockopt_v6only (int family, int sock) +{ + int ret, on = 1; + +#ifdef HAVE_IPV6 +#ifdef IPV6_V6ONLY + if (family == AF_INET6) + { + ret = setsockopt (sock, IPPROTO_IPV6, IPV6_V6ONLY, + (void *) &on, sizeof (int)); + if (ret < 0) + { + zlog (NULL, LOG_WARNING, "can't set sockopt IPV6_V6ONLY " + "to socket %d", sock); + return -1; + } + return 0; + } +#endif /* IPV6_V6ONLY */ +#endif /* HAVE_IPV6 */ + return 0; +} + +int sockopt_cork (int sock, int onoff) { #ifdef TCP_CORK |