From a7f23f581f5e3efe92ec97dfca7d01c66f31ab04 Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Mon, 7 Nov 2011 00:31:23 +0100 Subject: Implements protocol templates. Based on the patch from Alexander V. Chernikov. Extended to support almost all protocols. Uses 'protocol bgp NAME from TEMPLATE { ... }' syntax. --- nest/protocol.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'nest/protocol.h') diff --git a/nest/protocol.h b/nest/protocol.h index f95905a..a7518c2 100644 --- a/nest/protocol.h +++ b/nest/protocol.h @@ -53,6 +53,7 @@ struct protocol { void (*get_route_info)(struct rte *, byte *buf, struct ea_list *attrs); /* 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 */ }; void protos_build(void); @@ -85,12 +86,15 @@ struct proto_config { struct proto *proto; /* Instance we've created */ char *name; char *dsc; + int class; /* SYM_PROTO or SYM_TEMPLATE */ u32 debug, mrtdump; /* Debugging bitfields, both use D_* constants */ unsigned preference, disabled; /* Generic parameters */ u32 router_id; /* Protocol specific router ID */ struct rtable_config *table; /* Table we're attached to */ struct filter *in_filter, *out_filter; /* Attached filters */ + /* Check proto_reconfigure() and proto_copy_config() after changing struct proto_config */ + /* Protocol-specific data follow... */ }; @@ -203,9 +207,14 @@ struct proto_spec { void *proto_new(struct proto_config *, unsigned size); -void *proto_config_new(struct protocol *, unsigned size); +void *proto_config_new(struct protocol *, unsigned size, int class); +void proto_copy_config(struct proto_config *dest, struct proto_config *src); void proto_request_feeding(struct proto *p); +static inline void +proto_copy_rest(struct proto_config *dest, struct proto_config *src, unsigned size) +{ memcpy(dest + 1, src + 1, size - sizeof(struct proto_config)); } + void proto_cmd_show(struct proto *, unsigned int, int); void proto_cmd_disable(struct proto *, unsigned int, int); void proto_cmd_enable(struct proto *, unsigned int, int); -- cgit v1.2.3