[quagga-dev 8145] Re: adding new commands to quagga

bored to death bored_to_death85 at yahoo.com
Wed Aug 11 08:22:10 BST 2010


thank you for your replies.

first, about "http://www.quagga.net/zhh.html" document, i knew about it and 
tried to use it a while ago. it seemed like a good place to start, but the 
problem was, it's (i think) really outdated (it's published on  2001, February 
and it's written for zebra.) the result is many of functions, constants and 
variables are now different from what it says and you can't really follow the 
steps in the article because of this. plus, it focused on writing a new daemon 
and therefore, it doesn't say much about existing daemons and how to make 
changes in them. doesn't any newer version of this document exist?

second, about adding commands,  your posts gave me some hints about how to add 
commands to config. though i couldn't do what i want yet, but i keep on working 
on that. (there is no straight-forward path to do this it seems)

what i did is:
-i defined and registered "firewall disable".
-i added a struct to keep status of my configurations (right now, it has one 
member like "int firewall_disable" which can have one of two values :1 or 0, and 
this shows me if "firewall disable" command is executed or not. ( of course 
later i have to check if system really disabled my firewall or not before 
changing this member's value))
-i added some lines in "vtysh_config_write()" function in "vtysh_config.c" to 
send my command to "vtysh_config_parse_line()" if "firewall_disable" has value 
of 1.
-i added some lines in "vtysh_config_parse_line()" function to add line to 
config (config_add_line (config->line, line)) if input line is "firewall 

these steps makes my command to go to running-config whenever i execute my 
"firewall disable" command. but still, when i type "write" it's not being 
written to any of config files. i'm working on it to see what else should i do. 
(the "ip_forwarding" code helped, but i couldn't understand the role of 
FORWARDING_NODE and "config_write_forwarding()", and many other commands doesn't 
have these 2 parts.)

can anyone tell me what else should i do (for example what functions should i 
use), if i want my command to be added to config of an existing daemon (for 
example zebra)


From: Barry Friedman <barryf at google.com>
To: bored to death <bored_to_death85 at yahoo.com>
Cc: quagga devel <quagga-dev at lists.quagga.net>
Sent: Sun, August 8, 2010 8:50:24 PM
Subject: [quagga-dev 8140] Re: adding new commands to quagga

On Wed, Aug 4, 2010 at 9:57 AM, bored to death
<bored_to_death85 at yahoo.com> wrote:
> hi everybody,
> i'm using FreeBSD-8.0+quagga-0.99.15 for my office. for some reasons, i need
> to add some basic commands to quagga. what i do is defining the command with
> DEFUN and registering it with "install_element" and it works, but i'm
> stucked in finding a way to make my command go to config files to run in
> startup.
> for example, suppose i wanna add a very simple command to quagga to disable
> my ipfw firewall. here is what i do:
> i define my command:
> ...
> DEFUN (vtysh_firewall_disable,
>      vtysh_firewall_disable_cmd,
>      "firewall disable",
>      "Firewall service\n"
>      "Disable firewall\n")
> {
>   execute_command ("ipfw", 2, "disable", "firewall");
>   vty_out(vty, "Firewall Disabled!\n");
>   return CMD_SUCCESS;
> }
> ...
> then i register it to config node:
> ...
>   install_element (CONFIG_NODE, &vtysh_firewall_disable_cmd);
> ...
> and then i can disable (and enable) my firewall under quagga CLI. the only
> problem is, i can't find a way to add this command to quagga's
> running-config, so that if i type "write" and then restart my system, the
> command "firewall disable" is being executed automatically ,like other
> quagga commands.
> so here are my questions:
> 1- what else should i do, to make my new command be added to running-config
> and can then be written into config files(for example in zebra.conf).

The config commands are written out by config_write_xxx() functions,
each of which is registered to one of the command nodes defined in

For the command you have defined, I would look at the definition of
forwarding_node in the file zebra/zserv.c and the implementation of
the associated config_write_forwarding() function as a similar
example. You would need to have code to test whether the firewall has
been disabled in order to decide whether or not to write out the
command string. For example with the "ip forwarding" command, it
checks with the operating system to see if forwarding is enabled and
that triggers the writing out of the command.

> 2- oddly, i couldn't find a good book or fine document about quagga
> development in which these basic rules about quagga development are told.
> (for example, how to add nodes, how to add commands, etc) does anyone know
> any good material which i can use to help me with my first steps?



> any hints or helps would be great.
> thank you.
> cheers,
> _______________________________________________
> Quagga-dev mailing list
> Quagga-dev at lists.quagga.net
> http://lists.quagga.net/mailman/listinfo/quagga-dev
Quagga-dev mailing list
Quagga-dev at lists.quagga.net

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.quagga.net/pipermail/quagga-dev/attachments/20100811/df3f7e41/attachment-0001.html>

More information about the Quagga-dev mailing list