mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-11-09 12:48:43 +00:00
Allow EA type to be set to 'undefined' which overrides all further definitons
of that EA in the same list and causes ea_find() to fail unless you add EA_ALLOW_UNDEF to the second argument. ea_sort (resp. ea_do_prune()) removes all undef'd attributes from the list. I hope this works :)
This commit is contained in:
parent
f31156ca21
commit
8d24b6899d
@ -265,12 +265,16 @@ typedef struct eattr {
|
|||||||
#define EA_PROTO(ea) ((ea) >> 8)
|
#define EA_PROTO(ea) ((ea) >> 8)
|
||||||
#define EA_ID(ea) ((ea) & 0xff)
|
#define EA_ID(ea) ((ea) & 0xff)
|
||||||
|
|
||||||
|
#define EA_CODE_MASK 0xffff
|
||||||
|
#define EA_ALLOW_UNDEF 0x10000 /* ea_find: allow EAF_TYPE_UNDEF */
|
||||||
|
|
||||||
#define EAF_TYPE_MASK 0x0f /* Mask with this to get type */
|
#define EAF_TYPE_MASK 0x0f /* Mask with this to get type */
|
||||||
#define EAF_TYPE_INT 0x01 /* 32-bit signed integer number */
|
#define EAF_TYPE_INT 0x01 /* 32-bit signed integer number */
|
||||||
#define EAF_TYPE_OPAQUE 0x02 /* Opaque byte string (not filterable) */
|
#define EAF_TYPE_OPAQUE 0x02 /* Opaque byte string (not filterable) */
|
||||||
#define EAF_TYPE_IP_ADDRESS 0x04 /* IP address [FIXME: embed at least for IPv4?] */
|
#define EAF_TYPE_IP_ADDRESS 0x04 /* IP address [FIXME: embed at least for IPv4?] */
|
||||||
#define EAF_TYPE_AS_PATH 0x06 /* BGP AS path [FIXME: define storage layout] */
|
#define EAF_TYPE_AS_PATH 0x06 /* BGP AS path [FIXME: define storage layout] */
|
||||||
#define EAF_TYPE_INT_SET 0x0a /* Set of integers (e.g., a community list) */
|
#define EAF_TYPE_INT_SET 0x0a /* Set of integers (e.g., a community list) */
|
||||||
|
#define EAF_TYPE_UNDEF 0x0f /* `force undefined' entry */
|
||||||
#define EAF_EMBEDDED 0x01 /* Data stored in eattr.u.data (part of type spec) */
|
#define EAF_EMBEDDED 0x01 /* Data stored in eattr.u.data (part of type spec) */
|
||||||
#define EAF_VAR_LENGTH 0x02 /* Attribute length is variable */
|
#define EAF_VAR_LENGTH 0x02 /* Attribute length is variable */
|
||||||
#define EAF_INLINE 0x80 /* Copy of an attribute inlined in rte (temporary ea_lists only) */
|
#define EAF_INLINE 0x80 /* Copy of an attribute inlined in rte (temporary ea_lists only) */
|
||||||
|
@ -27,8 +27,8 @@ static pool *rta_pool;
|
|||||||
* Extended Attributes
|
* Extended Attributes
|
||||||
*/
|
*/
|
||||||
|
|
||||||
eattr *
|
static inline eattr *
|
||||||
ea_find(ea_list *e, unsigned id)
|
ea__find(ea_list *e, unsigned id)
|
||||||
{
|
{
|
||||||
eattr *a;
|
eattr *a;
|
||||||
int l, r, m;
|
int l, r, m;
|
||||||
@ -60,6 +60,17 @@ ea_find(ea_list *e, unsigned id)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
eattr *
|
||||||
|
ea_find(ea_list *e, unsigned id)
|
||||||
|
{
|
||||||
|
eattr *a = ea__find(e, id & EA_CODE_MASK);
|
||||||
|
|
||||||
|
if (a && (a->type & EAF_TYPE_MASK) == EAF_TYPE_UNDEF &&
|
||||||
|
!(id & EA_ALLOW_UNDEF))
|
||||||
|
return NULL;
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
ea_do_sort(ea_list *e)
|
ea_do_sort(ea_list *e)
|
||||||
{
|
{
|
||||||
@ -107,17 +118,24 @@ ea_do_sort(ea_list *e)
|
|||||||
static inline void
|
static inline void
|
||||||
ea_do_prune(ea_list *e)
|
ea_do_prune(ea_list *e)
|
||||||
{
|
{
|
||||||
eattr *s, *d;
|
eattr *s, *d, *l;
|
||||||
int i;
|
int i = 0;
|
||||||
|
|
||||||
/* Discard duplicates. Do you remember sorting was stable? */
|
/* Discard duplicates and undefs. Do you remember sorting was stable? */
|
||||||
s = d = e->attrs + 1;
|
s = d = e->attrs;
|
||||||
for(i=1; i<e->count; i++)
|
l = e->attrs + e->count;
|
||||||
if (s->id != d[-1].id)
|
while (s < l)
|
||||||
*d++ = *s++;
|
{
|
||||||
else
|
if ((s->type & EAF_TYPE_MASK) != EAF_TYPE_UNDEF)
|
||||||
|
{
|
||||||
|
*d++ = *s;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
s++;
|
s++;
|
||||||
e->count = d - e->attrs;
|
while (s < l && s->id == s[-1].id)
|
||||||
|
s++;
|
||||||
|
}
|
||||||
|
e->count = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user