summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThomas Graf <tgraf@suug.ch>2010-10-28 22:14:34 (GMT)
committerThomas Graf <tgraf@suug.ch>2010-10-28 22:14:34 (GMT)
commit0fe5b29423c1ad97012a865f1cd8b4f7ff37f143 (patch)
tree2776ab0e83cea83f4582b0f2313901a7c4c918be /src
parent65e386c8ba490d405f539322a12e1f1c7ea2eb5c (diff)
downloadlibnl-0fe5b29423c1ad97012a865f1cd8b4f7ff37f143.zip
libnl-0fe5b29423c1ad97012a865f1cd8b4f7ff37f143.tar.gz
libnl-0fe5b29423c1ad97012a865f1cd8b4f7ff37f143.tar.bz2
Extended pktloc to support nbyte locations for ipv6, etc.
The alignment column/field now also takes a number, specifying the length in bytes of the field described by the location
Diffstat (limited to 'src')
-rw-r--r--src/nl-pktloc-lookup.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/nl-pktloc-lookup.c b/src/nl-pktloc-lookup.c
index dc6154f..0f9831a 100644
--- a/src/nl-pktloc-lookup.c
+++ b/src/nl-pktloc-lookup.c
@@ -52,6 +52,9 @@ static const char *layer_txt[] = {
static void dump_u32_style(struct rtnl_pktloc *loc, uint32_t value)
{
+ if (loc->align > 4)
+ nl_cli_fatal(EINVAL, "u32 only supports alignments u8|u16|u32.");
+
if (loc->layer == TCF_LAYER_LINK)
nl_cli_fatal(EINVAL, "u32 does not support link "
"layer locations.");
@@ -63,19 +66,30 @@ static void dump_u32_style(struct rtnl_pktloc *loc, uint32_t value)
loc->offset);
}
+static char *get_align_txt(struct rtnl_pktloc *loc)
+{
+ static char buf[16];
+
+ if (loc->align <= 4)
+ strcpy(buf, align_txt[loc->align]);
+ else
+ snprintf(buf, sizeof(buf), "%u", loc->align);
+
+ return buf;
+}
+
static void dump_loc(struct rtnl_pktloc *loc)
{
printf("%s = %s at %s+%u %#x\n",
- loc->name, align_txt[loc->align],
- layer_txt[loc->layer], loc->offset, loc->mask);
+ loc->name, get_align_txt(loc), layer_txt[loc->layer],
+ loc->offset, loc->mask);
}
static void list_cb(struct rtnl_pktloc *loc, void *arg)
{
printf("%-26s %-5s %3s+%-4u %#-10x %u\n",
- loc->name, align_txt[loc->align],
- layer_txt[loc->layer], loc->offset,
- loc->mask, loc->refcnt);
+ loc->name, get_align_txt(loc), layer_txt[loc->layer],
+ loc->offset, loc->mask, loc->refcnt);
}
static void do_list(void)