summaryrefslogtreecommitdiff
path: root/nest
diff options
context:
space:
mode:
Diffstat (limited to 'nest')
-rw-r--r--nest/route.h3
-rw-r--r--nest/rt-table.c33
2 files changed, 36 insertions, 0 deletions
diff --git a/nest/route.h b/nest/route.h
index 8dfbb376..3e835bb1 100644
--- a/nest/route.h
+++ b/nest/route.h
@@ -308,6 +308,8 @@ void rte_free(rte *);
rte *rte_do_cow(rte *);
static inline rte * rte_cow(rte *r) { return (r->flags & REF_COW) ? rte_do_cow(r) : r; }
rte *rte_cow_rta(rte *r, linpool *lp);
+void rte_make_tmp_attr(struct rte *r, struct ea_list *e, uint id, uint type, u32 val);
+uint rte_store_tmp_attr(struct rte *r, uint id);
void rt_dump(rtable *);
void rt_dump_all(void);
int rt_feed_channel(struct channel *c);
@@ -481,6 +483,7 @@ typedef struct eattr {
#define EA_CODE(proto,id) (((proto) << 8) | (id))
#define EA_ID(ea) ((ea) & 0xff)
#define EA_PROTO(ea) ((ea) >> 8)
+#define EA_ID_FLAG(ea) (1 << EA_ID(ea))
#define EA_CUSTOM(id) ((id) | EA_CUSTOM_BIT)
#define EA_IS_CUSTOM(ea) ((ea) & EA_CUSTOM_BIT)
#define EA_CUSTOM_ID(ea) ((ea) & ~EA_CUSTOM_BIT)
diff --git a/nest/rt-table.c b/nest/rt-table.c
index 6bf07a09..7990fca3 100644
--- a/nest/rt-table.c
+++ b/nest/rt-table.c
@@ -325,6 +325,39 @@ rte_cow_rta(rte *r, linpool *lp)
return r;
}
+
+/* Note that rte_make_tmp_attr() requires free eattr in ea_list */
+void
+rte_make_tmp_attr(rte *r, ea_list *e, uint id, uint type, u32 val)
+{
+ if (r->pflags & EA_ID_FLAG(id))
+ {
+ eattr *a = &e->attrs[e->count++];
+ a->id = id;
+ a->type = type | EAF_TEMP;
+ a->flags = 0;
+ a->u.data = val;
+ }
+}
+
+/* Note that rte has to be writable */
+uint
+rte_store_tmp_attr(rte *r, uint id)
+{
+ eattr *a;
+ if (a = ea_find(r->attrs->eattrs, id))
+ {
+ r->pflags |= EA_ID_FLAG(id);
+ return a->u.data;
+ }
+ else
+ {
+ r->pflags &= ~EA_ID_FLAG(id);
+ return 0;
+ }
+}
+
+
static int /* Actually better or at least as good as */
rte_better(rte *new, rte *old)
{