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

Paul Jakma paul at clubi.ie
Mon May 15 17:56:32 BST 2006


On Mon, 15 May 2006, Andrew J. Schorr wrote:

> 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.

Yeah, that'd be an easily achievable improvement alright.

> 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.

Yep.

> 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.

Maybe.

Another solution is to just replace the problematic explicit list 
with 'WORD', nice and simple?

The help string then /could/ be easily computed by libzebra at daemon 
initialisation. It's constant for a daemon..

?

regards,
-- 
Paul Jakma	paul at clubi.ie	paul at jakma.org	Key ID: 64A2FF6A
Fortune:
Back when I was a boy, it was 40 miles to everywhere, uphill both ways
and it was always snowing.



More information about the Quagga-dev mailing list