[Xorp-hackers] XORP CLI

Pavlin Radoslavov pavlin at icir.org
Thu Mar 15 13:32:49 PDT 2007


> If CLI questions are not expected to this list, please either discard or
> redirect me to the proper mailing list.  Thanks.
> 
>  
> 
> The XORP CLI looks quite nice and I would like to get it out for another
> project.  However, I got myself lost in the way how it works with the
> XRL thing when I tried to scope the work since XORP CLI is also a
> process, as the other router processes and looks like every router
> process handles its own CLI command suits.
> 
>  
> 
> What I need is only the CLI part, which parses the template file and
> constructs the tree, then read user input/configuration files.  I would
> like to get rid of the router manager, module manager, XRL ....  Anybody
> can give me a hint on where to start?  I took a look at cli/test_cli.cc,
> but did not figure out how to see the added commands.
> 
>  
> 
> CLI development documentation will be a great help too.

Ruke,

At the very heart of the CLI is libtecla. We have a local (slightly
modified) copy inside xorp/cli/libtecla, but it is not the most
recent version.
Libtecla provides the command editing, command-line completion, help
strings, etc.

The XORP CLI library (xorp/cli) builds on top of libtecla.
It gives the XORP-like look, adds supports for pipes, keeps
various internal data like the command tree, etc.

The CLI library is used in two ways: as an attachment to a process
(legacy stuff), and as part of xorpsh.

What you see in cli/test_cli.cc is a variation of the first method
which shouldn't be used anymore. Though, if you curious about
test_cli, then start it as a stand alone program and use
"telnet localhost 12000" to connect to it.

Xorpsh itself builds on top of libcli. It adds all the XORP CLI
commands (edit, set, etc) and the corresponding XRLs, parses the
template files, communicates with the XORP rtrmgr, etc.

Personally, if your project has nothing to do with XORP and you have
the development resources, I'd recommend to use only libtecla and
add the stuff you need on top of it.
There are lots of hacks inside libcli so it is better to avoid it.

However, it seems that you want to reuse the XORP template and
configuration mechanism hence you need to use libcli and part of
xorpsh.
In that case you might want to look at the "XORP Router Manager
Process (rtrmgr)" design document available from
http://www.xorp.org/design_docs.html .
The second part of this document is about xorpsh, but you might want
to read the whole document to get a feeling about the operational
and configuration modes in xorpsh, the interaction between xorpsh
and the rtrmgr, etc.

Note that in operational mode xorpsh invokes external programs for
each CLI operational command (i.e., no XRLs by xorpsh itself).
In configuration mode the xorpsh uses XRLs to interact with the
rtrmgr to send/receive the configuration changes, etc.
If you take the rtrmgr out of the picture (along with the module
manager which is part of it) and modify xorpsh accordingly not to
expect/communicate with the rtrmgr, then this xorpsh process will be
able to read the operational and configuration templates and execute
external commands (when in operational mode). In configuration mode
xorpsh should be able to construct/modify the configuration tree,
and then you need to add your hooks what to do with that
configuration.

Unfortunately there is no clean cut to separate xorpsh from the
rtrmgr. Please have a look at the xorpsh_SOURCES variable inside
rtrmgr/Makefile.am. It contains all xorpsh source files. The main
files to start looking at are rtrmgr/xorpsh_main.cc, rtrmgr/cli.cc
and rtrmgr/xrl_xorpsh_interface.cc. You can remove
SlaveModuleManager which is needed to monitor the state of XORP
processes and add or remove the operational commands associated with
each process.

Hopefully this will give you a starting point. Please let us know if
you have any other questions.

Regards,
Pavlin



More information about the Xorp-hackers mailing list