summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ac7d538)
raw | patch | inline | side by side (parent: ac7d538)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Tue, 26 Oct 2010 13:09:45 +0000 (15:09 +0200) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Tue, 26 Oct 2010 13:09:45 +0000 (15:09 +0200) |
src/liboping.c | patch | blob | history |
diff --git a/src/liboping.c b/src/liboping.c
index 139fa97ca72f37be4d3eb65622a960b99e27e2f2..b0a9e5bc8da5491d546a78631fd8ba6c5a1fcaee 100644 (file)
--- a/src/liboping.c
+++ b/src/liboping.c
/*
* Set the TOS of a socket protocol independently.
+ *
+ * Using SOL_SOCKET / SO_PRIORITY might be a protocol independent way to
+ * set this. See socket(7) for details.
*/
static int ping_set_tos (pinghost_t *ph, uint8_t tos)
{
if (ph->addrfamily == AF_INET)
{
- int opt = 1;
+ int opt;
+
+ /* Enable receiving the TOS field */
+ opt = 1;
+ setsockopt (ph->fd, IPPROTO_IP, IP_RECVTOS,
+ &opt, sizeof (opt));
+ /* Enable receiving the TTL field */
+ opt = 1;
setsockopt (ph->fd, IPPROTO_IP, IP_RECVTTL,
&opt, sizeof (opt));
}
-#if defined(IPPROTO_IPV6) && defined(IPV6_RECVHOPLIMIT)
+#if defined(IPV6_RECVHOPLIMIT) || defined(IPV6_RECVTCLASS)
else if (ph->addrfamily == AF_INET6)
{
- int opt = 1;
+ int opt;
+# if defined(IPV6_RECVHOPLIMIT)
+ /* For details see RFC 3542, section 6.3. */
+ opt = 1;
setsockopt (ph->fd, IPPROTO_IPV6, IPV6_RECVHOPLIMIT,
&opt, sizeof (opt));
+# endif /* IPV6_RECVHOPLIMIT */
+
+# if defined(IPV6_RECVTCLASS)
+ /* For details see RFC 3542, section 6.5. */
+ opt = 1;
+ setsockopt (ph->fd, IPPROTO_IPV6, IPV6_RECVTCLASS,
+ &opt, sizeof (opt));
+# endif /* IPV6_RECVTCLASS */
}
-#endif
+#endif /* IPV6_RECVHOPLIMIT || IPV6_RECVTCLASS */
break;
- }
+ } /* for (ai_ptr = ai_list; ai_ptr != NULL; ai_ptr = ai_ptr->ai_next) */
freeaddrinfo (ai_list);