+static void usage_tos_exit (const char *arg, int status) /* {{{ */
+{
+ if (arg != 0)
+ fprintf (stderr, "Invalid ToS argument: \"%s\"\n\n", arg);
+
+ fprintf (stderr, "Valid ToS arguments (option \"-z\") are:\n"
+ "\n"
+ " lowdelay (%#04x) minimize delays\n"
+ " throughput (%#04x) optimize throughput\n"
+ " reliability (%#04x) optimize reliability\n"
+ " mincost (%#04x) minimize cost\n"
+ " 0x00 - 0xff specify manually\n"
+ "\n",
+ (unsigned int) IPTOS_LOWDELAY,
+ (unsigned int) IPTOS_THROUGHPUT,
+ (unsigned int) IPTOS_RELIABILITY,
+ (unsigned int) IPTOS_MINCOST);
+
+ exit (status);
+} /* }}} void usage_tos_exit */
+
+static int set_opt_send_tos (const char *opt) /* {{{ */
+{
+ if (opt == NULL)
+ return (EINVAL);
+
+ if (strcasecmp ("lowdelay", opt) == 0)
+ opt_send_tos = IPTOS_LOWDELAY;
+ else if (strcasecmp ("throughput", opt) == 0)
+ opt_send_tos = IPTOS_THROUGHPUT;
+ else if (strcasecmp ("reliability", opt) == 0)
+ opt_send_tos = IPTOS_RELIABILITY;
+ else if (strcasecmp ("mincost", opt) == 0)
+ opt_send_tos = IPTOS_MINCOST;
+ else if (strcasecmp ("help", opt) == 0)
+ usage_tos_exit (/* arg = */ NULL, /* status = */ EXIT_SUCCESS);
+ else
+ {
+ unsigned long value;
+ char *endptr;
+
+ errno = 0;
+ endptr = NULL;
+ value = strtoul (opt, &endptr, /* base = */ 0);
+ if ((errno != 0) || (endptr == opt)
+ || (endptr == NULL) || (*endptr != 0)
+ || (value >= 0xff))
+ usage_tos_exit (/* arg = */ opt, /* status = */ EXIT_FAILURE);
+
+ opt_send_tos = (uint8_t) value;
+ }
+
+ return (0);
+} /* }}} int set_opt_send_tos */
+