[quagga-dev 4142] Re: example libzebra zclient utility

Andrew J. Schorr aschorr at telemetry-investments.com
Mon May 15 17:36:22 BST 2006


On Mon, May 15, 2006 at 05:23:21PM +0100, Paul Jakma wrote:
> >That's precisely the patch that inspired my remark. :-)
> 
> Hehe, question is how to provide the string tailored for the client..

It may not be pretty, but how about something like, for example:

#define ROUTES_REDIST_BY_OSPF "kernel|connected|static|rip|bgp"
#define DESC_REDIST_BY_OSPF	\
	"Kernel routes\n"	\
	"Connected\n"	\
	"Static routes\n"	\
	"Routing Information Protocol (RIP)\n"	\
	"Border Gateway Protocol (BGP)\n"

By my count, those patterns appear 13 times in ospfd/ospf_vty.c.  And
I assume similar ugliness in other daemons.  So in return for a bit
of header file pain, the code would be much cleaner.

And similarly for the other daemons.  Then when a new protocol is
added, the developer just has to edit this header file carefully.
So the goal would be not to have to patch the other individual daemons,
but just to make changes to header files and some support code in the
lib directory.

Beyond that, we would need a centralized (canonical) library function
to convert these strings to route numbers.  The problem here is
that the shortest acceptable abbreviations may depend on exactly
which protocols are supported for that command.  So the function might
need to take the "redist" string as an argument, and parse it to figure
out the shortest abbreviations that are unique.  A bit annoying, but perhaps
worth doing right once so as to make the code easier to maintain
in the future.

Regards,
Andy



More information about the Quagga-dev mailing list