Hi,
I got a good progress for those filters. Now are stable and the code is
very small.
I've created new functions for output like: vprintf_filter,
vfprintf_filter, etc which are passing the arguments to a filter function.
Examples:
quagga-router# show running-config | section router
hostname quagga-router
!
router bgp 65535
bgp router-id 10.100.101.2
network 10.20.30.0/24
network 172.16.0.0/24
redistribute connected
neighbor 10.0.0.1 remote-as 11111
maximum-paths 3
!
address-family vpnv4
neighbor 10.0.0.1 activate
exit-address-family
!
address-family encap
neighbor 10.0.0.1 activate
exit-address-family
exit
!
quagga-router# show running-config | include bond
!
interface bond0
interface bond0.100
ip route 1.1.1.1/32 bond0.100
ip route 1.1.1.1/32 bond0
quagga-router# show running-config | exclude link-detect
Building configuration...
Current configuration:
!
hostname quagga-router
!
service integrated-vtysh-config
!
interface bond0
ipv6 nd suppress-ra
!
interface bond0.100
ipv6 nd suppress-ra
!
interface eth0
ipv6 nd suppress-ra
!
interface eth1
ipv6 nd suppress-ra
!
interface lo
!
interface vpn
ipv6 nd suppress-ra
!
Now I need some help if is possible to tell me where should I add those
function.
In this moment I've used command.c and command.h files to add the new
functions because command.h is command for most of the files.
Is better to move out to a new files like vty_output_filters.c and
vty_output_filter.h ?
The next stage is to change other show commands in daemons to use new
output filters functions.
Kind regards,
Adrian
On 9/7/2016 12:19 AM, Adrian Ban wrote:
Hi all,
I started few days ago to develop some functions to have posibility
from CLI to change the output of the information.
Taking in account that for example in BGP you have a lot of prefixes
received and you want to filter the output for a particular match, or
a big config from which you need a specific part of it I decided to
modify Quagga sources to add those output modifiers like CIsco IOS.
For the moment only the include filter is done and the next one will
be exclude because is the reverse of include.
Here is an example for the first command modified:
quagga-router# show running-config | include interface
Building configuration...
Current configuration:
!
interface bond0
interface bond0.100
interface eth0
interface eth1
interface lo
interface vpn
end
quagga-router# show running-config | include link-detect
Building configuration...
Current configuration:
!
no link-detect
no link-detect
no link-detect
no link-detect
no link-detect
no link-detect
end
quagga-router# exit
The idea was like this:
1. Changed the format_parser_handle_pipe function in lib to permit the
pipe outside the keywords and multiple.
2. Adding 2 fields to vty structure
3. Adding a macro which is parsing the output modifiers and is calling
the original function like this
DEFUN (vtysh_write_terminal,
vtysh_write_terminal_cmd,
"write terminal",
"Write running configuration to memory, network, or terminal\n"
"Write to terminal\n")
{
..
}
ALIAS (vtysh_write_terminal,
vtysh_show_running_config_cmd,
"show running-config",
SHOW_STR
"Current operating configuration\n")
ALIAS_FILTER (vtysh_write_terminal_cmd,
vtysh_write_terminal_config_filter,
vtysh_show_running_config_filter_cmd,
"show running-config | (include|exclude|section) .LINE",
SHOW_STR
"Current operating configuration\n"
"Output modifiers\n"
"Include lines that match\n"
"Exclude lines that match\n"
"Regular Expression\n")
4. Changing the original function to accept or not the output modifiers.
I've tried to be minimum invasive in the lib source codes and I think
I success to do it. The rest of the work (the filtering of the output)
is done in the daemon/vtysh.
What I need to know if is OK for developers to add this feature to the
Quagga after I will add the output modifiers to the all daemons and I
will release the final version.
I'm not a very experienced programmer so my code perhaps will not be
so clean and optimized.
--
This mail was scanned by BitDefender
For more information please visit http://www.bitdefender.com/
_______________________________________________
Quagga-dev mailing list
[email protected]
https://lists.quagga.net/mailman/listinfo/quagga-dev