+/*
+ * Set the TOS of a socket protocol independently.
+ */
+static int ping_set_tos (pinghost_t *ph, unsigned tos)
+{
+ int ret = -2;
+
+ if (ph->addrfamily == AF_INET)
+ {
+ dprintf ("Setting TP_TOS to %i\n", ttl);
+ ret = setsockopt (ph->fd, IPPROTO_IP, IP_TOS,
+ &tos, sizeof (tos));
+ }
+ else if (ph->addrfamily == AF_INET6)
+ {
+ dprintf ("Setting IPV6_TCLASS to %i\n", ttl);
+ ret = setsockopt (ph->fd, IPPROTO_IPV6, IPV6_TCLASS,
+ &tos, sizeof (tos));
+ }
+
+ return (ret);
+}
+