[Olsr-dev] olsrd dynamic hna

Vasilis Tsiligiannis (spam-protected)
Wed Jun 30 02:23:44 CEST 2010


On Monday 28 of June 2010 15:53:35 Gioacchino Mazzurco wrote:
> how to reach this socket and where i can find the syntax to talk with the
> plugin from a bash script?
>

OLSRd Quagga plugin _reads_ commands from an existing UNIX or TCP socket. It 
doesn't create a listening socket itself. The 'elegant' way is to write a 
program (perl, python, C, etc.) which creates and handles such a socket. 
The 'quick and dirty' way is to use netcat and some bash scripting. I have 
used the 'quick and dirty' way (awk and netcat) for debugging.

If you want to use netcat then first you have to create a pipe:
$ mkfifo /var/run/zebra_pipe

and then tail the pipe to netcat running on listening mode:
$ tail -f /var/run/zebra_pipe | nc -l -p 12345 localhost > /dev/null &

Configure OLSRd Quagga plugin as follows:
LoadPlugin "olsrd_quagga.so.0.2.2"
{
        PlParam "Version" "1"
        PlParam "Redistribute" "system"
        PlParam "Port" "12345"
}

Use the following script to add or delete HNA routes:
Start of redistribute-debug.sh
-----
#!/bin/sh
#
# This is a bash script used for debugging OLSRd Quagga plugin
# redistribution functions
#
# Copyright (C) 2010 Vasilis Tsiligiannis <(spam-protected)>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
# USA.

packet=$(awk \
'BEGIN {
	if (ARGC < 2) exit;
	command_s = ARGV[1];
	prefix_s = ARGV[2];

	# Evaluate command
	if (command_s == "add") command = 7;
	else if (command_s == "del") command = 8;
	else exit;

	# Evaluate prefix length
	n = split (prefix_s, tokens, "/");
	if ((n != 2) || (tokens[2] < 1) || (tokens[2] > 32))
		exit;
	prefix_length = tokens[2];

	# Evaluate prefix
	if (split (tokens[1], prefix, ".") != 4)
		exit;
	prefix_size = int ((prefix_length + 7) / 8);
	for (i = 1; i <= prefix_size; i++)
		if ((prefix[i] > 255) || (prefix[i] < 0))
			exit;

	printf (" %02x %02x", 0, 19 + prefix_size);	# Packet length
	printf (" %02x", 255);				# Header marker
	printf (" %02x", 1);				# Version
	printf (" %02x %02x", 0, command);		# Command
	printf (" %02x", 0);				# Route type
	printf (" %02x", 0);				# Route flags
	printf (" %02x", 1);				# Message
	printf (" %02x", prefix_length);		# Prefix length
	for (i = 1; i <= prefix_size; i++)
		printf (" %02x", prefix[i]);		# Prefix octets
	printf (" %02x", 1); 				# Nexthop count
	printf (" %02x %02x %02x %02x", 0, 0, 0, 0);	# Nexthop
	printf (" %02x %02x %02x %02x", 0, 0, 0, 1);	# Metric
	
}' "$1" "$2" | sed -e 's/ /\\x/g')

echo -ne "$packet"
-----
End of redistribute-debug.sh

The syntax to add or delete HNAs is:
$ ./redistribute-debug.sh add 10.20.30.40/24
$ ./redistribute-debug.sh del 10.20.30.40/24

I hope this helps.. If necessary, you can adjust the script to better fit your 
needs.

Best Regards,
-- 
Vasilis Tsiligiannis
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.olsr.org/pipermail/olsr-dev/attachments/20100630/7399c130/attachment.sig>


More information about the Olsr-dev mailing list