summaryrefslogtreecommitdiff
path: root/lib/route.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/route.h')
-rw-r--r--lib/route.h37
1 files changed, 23 insertions, 14 deletions
diff --git a/lib/route.h b/lib/route.h
index 3f6fc5a9..1b2f4de6 100644
--- a/lib/route.h
+++ b/lib/route.h
@@ -16,19 +16,21 @@ struct network;
struct proto;
struct cli;
+
typedef struct rte {
- struct rte *next;
- struct network *net; /* Network this RTE belongs to */
- struct rte_src *src; /* Route source that created the route */
- struct channel *sender; /* Channel used to send the route to the routing table */
struct ea_list *attrs; /* Attributes of this route */
+ const net_addr *net; /* Network this RTE belongs to */
+ struct rte_src *src; /* Route source that created the route */
+ struct rt_import_hook *sender; /* Import hook used to send the route to the routing table */
+ btime lastmod; /* Last modified (set by table) */
u32 id; /* Table specific route id */
- byte flags; /* Flags (REF_...) */
+ byte flags; /* Table-specific flags */
byte pflags; /* Protocol-specific flags */
- btime lastmod; /* Last modified */
+ u8 generation; /* If this route import is based on other previously exported route,
+ this value should be 1 + MAX(generation of the parent routes).
+ Otherwise the route is independent and this value is zero. */
} rte;
-#define REF_COW 1 /* Copy this rte on write */
#define REF_FILTERED 2 /* Route is rejected by import filter */
#define REF_STALE 4 /* Route is stale in a refresh cycle */
#define REF_DISCARD 8 /* Route is scheduled for discard */
@@ -317,7 +319,7 @@ static inline u32 rt_get_preference(rte *rt)
/* IGP metric: second-order comparison */
extern struct ea_class ea_gen_igp_metric;
-u32 rt_get_igp_metric(rte *rt);
+u32 rt_get_igp_metric(const rte *rt);
#define IGP_METRIC_UNKNOWN 0x80000000 /* Default igp_metric used when no other
protocol-specific metric is availabe */
@@ -327,16 +329,23 @@ extern struct ea_class ea_gen_from;
/* Source: An old method to devise the route source protocol and kind.
* To be superseded in a near future by something more informative. */
extern struct ea_class ea_gen_source;
-static inline u32 rt_get_source_attr(rte *rt)
+static inline u32 rt_get_source_attr(const rte *rt)
{ return ea_get_int(rt->attrs, &ea_gen_source, 0); }
/* Flowspec validation result */
-#define FLOWSPEC_UNKNOWN 0
-#define FLOWSPEC_VALID 1
-#define FLOWSPEC_INVALID 2
+enum flowspec_valid {
+ FLOWSPEC_UNKNOWN = 0,
+ FLOWSPEC_VALID = 1,
+ FLOWSPEC_INVALID = 2,
+ FLOWSPEC__MAX,
+};
+
+extern const char * flowspec_valid_names[FLOWSPEC__MAX];
+static inline const char *flowspec_valid_name(enum flowspec_valid v)
+{ return (v < FLOWSPEC__MAX) ? flowspec_valid_names[v] : "???"; }
extern struct ea_class ea_gen_flowspec_valid;
-static inline u32 rt_get_flowspec_valid(rte *rt)
+static inline enum flowspec_valid rt_get_flowspec_valid(rte *rt)
{ return ea_get_int(rt->attrs, &ea_gen_flowspec_valid, FLOWSPEC_UNKNOWN); }
/* Next hop: For now, stored as adata */
@@ -398,7 +407,7 @@ static inline int nhea_dest(eattr *nhea)
return nhad->dest;
}
-static inline int rte_dest(rte *r)
+static inline int rte_dest(const rte *r)
{
return nhea_dest(ea_find(r->attrs, &ea_gen_nexthop));
}