summaryrefslogtreecommitdiff
path: root/nest/rt-attr.c
diff options
context:
space:
mode:
authorOndrej Zajicek <santiago@crfreenet.org>2015-05-09 18:50:15 +0200
committerOndrej Zajicek <santiago@crfreenet.org>2015-05-10 19:44:10 +0200
commit315f23a0470112ced04badbb117bc7854ee53e06 (patch)
treef9287d0ef699857f7b85798b7e832fa226abd0a1 /nest/rt-attr.c
parent77edab640925e8d1131f0d00b41de055129ff99f (diff)
Add bitfield route attribute type
Diffstat (limited to 'nest/rt-attr.c')
-rw-r--r--nest/rt-attr.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/nest/rt-attr.c b/nest/rt-attr.c
index 09691bf1..938b2b44 100644
--- a/nest/rt-attr.c
+++ b/nest/rt-attr.c
@@ -563,6 +563,32 @@ get_generic_attr(eattr *a, byte **buf, int buflen UNUSED)
return GA_UNKNOWN;
}
+void
+ea_format_bitfield(struct eattr *a, byte *buf, int bufsize, const char **names, int min, int max)
+{
+ byte *bound = buf + bufsize - 32;
+ u32 data = a->u.data;
+ int i;
+
+ for (i = min; i < max; i++)
+ if ((data & (1u << i)) && names[i])
+ {
+ if (buf > bound)
+ {
+ strcpy(buf, " ...");
+ return;
+ }
+
+ buf += bsprintf(buf, " %s", names[i]);
+ data &= ~(1u << i);
+ }
+
+ if (data)
+ bsprintf(buf, " %08x", data);
+
+ return;
+}
+
static inline void
opaque_format(struct adata *ad, byte *buf, unsigned int size)
{
@@ -665,6 +691,9 @@ ea_show(struct cli *c, eattr *e)
case EAF_TYPE_AS_PATH:
as_path_format(ad, pos, end - pos);
break;
+ case EAF_TYPE_BITFIELD:
+ bsprintf(pos, "%08x", e->u.data);
+ break;
case EAF_TYPE_INT_SET:
ea_show_int_set(c, ad, 1, pos, buf, end);
return;