You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
858 B
41 lines
858 B
#include <stdbool.h> |
|
#include <stdint.h> |
|
#include <stdio.h> |
|
#include <linux/ip.h> |
|
|
|
#ifndef IPTOS_NORMALSVC |
|
# define IPTOS_NORMALSVC 0 |
|
#endif |
|
|
|
struct tos_value_mask { |
|
uint8_t value, mask; |
|
}; |
|
|
|
static const struct tos_symbol_info { |
|
unsigned char value; |
|
const char *name; |
|
} tos_symbol_names[] = { |
|
{IPTOS_LOWDELAY, "Minimize-Delay"}, |
|
{IPTOS_THROUGHPUT, "Maximize-Throughput"}, |
|
{IPTOS_RELIABILITY, "Maximize-Reliability"}, |
|
{IPTOS_MINCOST, "Minimize-Cost"}, |
|
{IPTOS_NORMALSVC, "Normal-Service"}, |
|
{}, |
|
}; |
|
|
|
static bool tos_try_print_symbolic(const char *prefix, |
|
uint8_t value, uint8_t mask) |
|
{ |
|
const struct tos_symbol_info *symbol; |
|
|
|
if (mask != 0x3F) |
|
return false; |
|
|
|
for (symbol = tos_symbol_names; symbol->name != NULL; ++symbol) |
|
if (value == symbol->value) { |
|
printf(" %s%s", prefix, symbol->name); |
|
return true; |
|
} |
|
|
|
return false; |
|
}
|
|
|