diff options
Diffstat (limited to 'nest/protocol.h')
-rw-r--r-- | nest/protocol.h | 45 |
1 files changed, 34 insertions, 11 deletions
diff --git a/nest/protocol.h b/nest/protocol.h index 8a22d76b..dd942c10 100644 --- a/nest/protocol.h +++ b/nest/protocol.h @@ -37,12 +37,31 @@ struct symbol; * Routing Protocol */ +enum protocol_class { + PROTOCOL_NONE, + PROTOCOL_BABEL, + PROTOCOL_BFD, + PROTOCOL_BGP, + PROTOCOL_DEVICE, + PROTOCOL_DIRECT, + PROTOCOL_KERNEL, + PROTOCOL_OSPF, + PROTOCOL_PIPE, + PROTOCOL_RADV, + PROTOCOL_RIP, + PROTOCOL_RPKI, + PROTOCOL_STATIC, + PROTOCOL__MAX +}; + +extern struct protocol *class_to_protocol[PROTOCOL__MAX]; + struct protocol { node n; char *name; char *template; /* Template for automatic generation of names */ int name_counter; /* Counter for automatic name generation */ - int attr_class; /* Attribute class known to this protocol */ + enum protocol_class class; /* Machine readable protocol class */ uint preference; /* Default protocol preference */ uint channel_mask; /* Mask of accepted channel types (NB_*) */ uint proto_size; /* Size of protocol data structure */ @@ -58,7 +77,7 @@ struct protocol { int (*shutdown)(struct proto *); /* Stop the instance */ void (*cleanup)(struct proto *); /* Called after shutdown when protocol became hungry/down */ void (*get_status)(struct proto *, byte *buf); /* Get instance status (for `show protocols' command) */ - void (*get_route_info)(struct rte *, byte *buf, struct ea_list *attrs); /* Get route information (for `show route' command) */ + void (*get_route_info)(struct rte *, byte *buf); /* Get route information (for `show route' command) */ int (*get_attr)(struct eattr *, byte *buf, int buflen); /* ASCIIfy dynamic attribute (returns GA_*) */ void (*show_proto_info)(struct proto *); /* Show protocol info (for `show protocols all' command) */ void (*copy_config)(struct proto_config *, struct proto_config *); /* Copy config from given protocol instance */ @@ -172,7 +191,7 @@ struct proto { * rt_notify Notify protocol about routing table updates. * neigh_notify Notify protocol about neighbor cache events. * make_tmp_attrs Construct ea_list from private attrs stored in rte. - * store_tmp_attrs Store private attrs back to the rte. + * store_tmp_attrs Store private attrs back to rta. The route MUST NOT be cached. * import_control Called as the first step of the route importing process. * It can construct a new rte, add private attributes and * decide whether the route shall be imported: 1=yes, -1=no, @@ -186,11 +205,11 @@ struct proto { void (*if_notify)(struct proto *, unsigned flags, struct iface *i); void (*ifa_notify)(struct proto *, unsigned flags, struct ifa *a); - void (*rt_notify)(struct proto *, struct channel *, struct network *net, struct rte *new, struct rte *old, struct ea_list *attrs); + void (*rt_notify)(struct proto *, struct channel *, struct network *net, struct rte *new, struct rte *old); void (*neigh_notify)(struct neighbor *neigh); struct ea_list *(*make_tmp_attrs)(struct rte *rt, struct linpool *pool); - void (*store_tmp_attrs)(struct rte *rt, struct ea_list *attrs); - int (*import_control)(struct proto *, struct rte **rt, struct ea_list **attrs, struct linpool *pool); + void (*store_tmp_attrs)(struct rte *rt); + int (*import_control)(struct proto *, struct rte **rt, struct linpool *pool); void (*reload_routes)(struct channel *); void (*feed_begin)(struct channel *, int initial); void (*feed_end)(struct channel *); @@ -273,12 +292,16 @@ proto_get_router_id(struct proto_config *pc) return pc->router_id ? pc->router_id : pc->global->router_id; } -static inline struct ea_list * -rte_make_tmp_attrs(struct rte *rt, struct linpool *pool) +static inline void +rte_make_tmp_attrs(struct rte **rt, struct linpool *pool) { struct ea_list *(*mta)(struct rte *rt, struct linpool *pool); - mta = rt->attrs->src->proto->make_tmp_attrs; - return mta ? mta(rt, pool) : NULL; + mta = (*rt)->attrs->src->proto->make_tmp_attrs; + if (!mta) return; + *rt = rte_cow_rta(*rt, pool); + struct ea_list *ea = mta(*rt, pool); + ea->next = (*rt)->attrs->eattrs; + (*rt)->attrs->eattrs = ea; } /* Moved from route.h to avoid dependency conflicts */ @@ -447,7 +470,7 @@ struct channel_class { void (*dump_attrs)(struct rte *); /* Dump protocol-dependent attributes */ void (*get_status)(struct proto *, byte *buf); /* Get instance status (for `show protocols' command) */ - void (*get_route_info)(struct rte *, byte *buf, struct ea_list *attrs); /* Get route information (for `show route' command) */ + void (*get_route_info)(struct rte *, byte *buf); /* Get route information (for `show route' command) */ int (*get_attr)(struct eattr *, byte *buf, int buflen); /* ASCIIfy dynamic attribute (returns GA_*) */ void (*show_proto_info)(struct proto *); /* Show protocol info (for `show protocols all' command) */ |