]> git.ipfire.org Git - thirdparty/bird.git/blobdiff - sysdep/bsd/sysio.h
The generalized TTL security mechanism (RFC 5082) support.
[thirdparty/bird.git] / sysdep / bsd / sysio.h
index 847ce2612e58701bc20820ce9f477d4e65c13317..95f7dcf467ada1b88021b774007e91244622270c 100644 (file)
@@ -237,3 +237,34 @@ sk_set_md5_auth_int(sock *s, sockaddr *sa, char *passwd)
 
   return rv;
 }
+
+
+#ifndef IPV6
+
+static int
+sk_set_min_ttl4(sock *s, int ttl)
+{
+  if (setsockopt(s->fd, IPPROTO_IP, IP_MINTTL, &ttl, sizeof(ttl)) < 0)
+  {
+    if (errno == ENOPROTOOPT)
+      log(L_ERR "Kernel does not support IPv4 TTL security");
+    else
+      log(L_ERR "sk_set_min_ttl4: setsockopt: %m");
+
+    return -1;
+  }
+
+  return 0;
+}
+
+#else
+
+static int
+sk_set_min_ttl6(sock *s, int ttl)
+{
+  log(L_ERR "IPv6 TTL security not supported");
+  return -1;
+}
+
+#endif
+