]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Special attribute types for enums
authorMaria Matejka <mq@ucw.cz>
Sat, 26 Mar 2022 11:37:41 +0000 (12:37 +0100)
committerMaria Matejka <mq@ucw.cz>
Wed, 4 May 2022 13:37:41 +0000 (15:37 +0200)
filter/config.Y
filter/f-inst.c
nest/route.h
nest/rt-attr.c
proto/bgp/attrs.c
proto/bgp/config.Y
proto/radv/config.Y

index 67bd04b429ab2e7252ecc43cdc592223e8143b9c..fb331c16733c8f36c7ff9724192ee5d7fc8ec20d 100644 (file)
@@ -165,7 +165,7 @@ f_generate_empty(struct f_dynamic_attr dyn)
 {
   struct f_val empty;
 
-  switch (dyn.type & EAF_TYPE_MASK) {
+  switch (dyn.type) {
     case EAF_TYPE_AS_PATH:
       empty = f_const_empty_path;
       break;
index 8bfec479e3ce83e5d2c27d6f5ba42acd9c8722a3..11ca1e28eeb18402f947dfa958a09fd8eb8c00e7 100644 (file)
        break;
       }
 
-      switch (e->type & EAF_TYPE_MASK) {
+      switch (e->type) {
       case EAF_TYPE_INT:
        RESULT_(da.f_type, i, e->u.data);
        break;
index 7557bf9318e3039ec4a3e7058f1326e62e21c842..d2f60f4144314f11c4e4332a49863c72eab9e367 100644 (file)
@@ -540,6 +540,9 @@ const char *ea_custom_name(uint ea);
 #define EAF_TYPE_EC_SET 0x0e           /* Set of pairs of u32's - ext. community list */
 #define EAF_TYPE_LC_SET 0x08           /* Set of triplets of u32's - large community list */
 #define EAF_TYPE_IFACE 0x0c            /* Interface pointer stored in adata */
+#define EAF_TYPE_BGP_ORIGIN 0x11       /* BGP Origin enum */
+#define EAF_TYPE_RA_PREFERENCE 0x13    /* RA Preference enum */
+
 #define EAF_EMBEDDED 0x01              /* Data stored in eattr.u.data (part of type spec) */
                                        /* Otherwise, attribute data is adata */
 
index abda5d82f04190fe68c8c5ba4fdc94fbec0c6fc8..25548dca8058cbf2c731971399dea267f4e6fb40 100644 (file)
@@ -948,7 +948,7 @@ ea_show(struct cli *c, const eattr *e)
       if (e->undef)
        bsprintf(pos, "undefined");
       else
-      switch (e->type & EAF_TYPE_MASK)
+      switch (e->type)
        {
        case EAF_TYPE_INT:
          bsprintf(pos, "%u", e->u.data);
@@ -1008,7 +1008,10 @@ ea_dump(ea_list *e)
        {
          eattr *a = &e->attrs[i];
          debug(" %02x:%02x.%02x", EA_PROTO(a->id), EA_ID(a->id), a->flags);
-         debug("=%c", "?iO?I?P???S?????" [a->type & EAF_TYPE_MASK]);
+         debug("=%c",
+             "?iO?IRP???S??pE?"
+             "??L???N?????????"
+             "?o???r??????????" [a->type]);
          if (a->originated)
            debug("o");
          if (a->type & EAF_EMBEDDED)
index a7c49be592e4baba7776100d7211a8ba11e2d3d5..b514f1b98b011ab283aa02e5d86e4fba00fd9c1f 100644 (file)
@@ -987,7 +987,7 @@ bgp_decode_unknown(struct bgp_parse_state *s, uint code, uint flags, byte *data,
 static const struct bgp_attr_desc bgp_attr_table[] = {
   [BA_ORIGIN] = {
     .name = "origin",
-    .type = EAF_TYPE_INT,
+    .type = EAF_TYPE_BGP_ORIGIN,
     .flags = BAF_TRANSITIVE,
     .export = bgp_export_origin,
     .encode = bgp_encode_u8,
index 241aa7c294ee6b82ed4c954607a16ad933916391..04920941c9fd331ff984cb3dee6b54e2b68ea9c6 100644 (file)
@@ -318,7 +318,7 @@ bgp_proto_channel: bgp_channel_start bgp_channel_opt_list bgp_channel_end;
 
 
 dynamic_attr: BGP_ORIGIN
-       { $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_ENUM_BGP_ORIGIN, EA_CODE(PROTOCOL_BGP, BA_ORIGIN)); } ;
+       { $$ = f_new_dynamic_attr(EAF_TYPE_BGP_ORIGIN, T_ENUM_BGP_ORIGIN, EA_CODE(PROTOCOL_BGP, BA_ORIGIN)); } ;
 dynamic_attr: BGP_PATH
        { $$ = f_new_dynamic_attr(EAF_TYPE_AS_PATH, T_PATH, EA_CODE(PROTOCOL_BGP, BA_AS_PATH)); } ;
 dynamic_attr: BGP_NEXT_HOP
index 8d4a3ab94221bbbe0b760a0f3b479d00d0111982..f16b897df8113931a5adb48ba90dfec6f3b881d1 100644 (file)
@@ -336,7 +336,7 @@ radv_sensitive:
  | SENSITIVE bool { $$ = $2; }
  ;
 
-dynamic_attr: RA_PREFERENCE { $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_ENUM_RA_PREFERENCE, EA_RA_PREFERENCE); } ;
+dynamic_attr: RA_PREFERENCE { $$ = f_new_dynamic_attr(EAF_TYPE_RA_PREFERENCE, T_ENUM_RA_PREFERENCE, EA_RA_PREFERENCE); } ;
 dynamic_attr: RA_LIFETIME { $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_RA_LIFETIME); } ;
 
 CF_CODE