line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
########################################################################## |
4
|
|
|
|
|
|
|
# Copyright (c) 2010-2012 Alexander Bluhm |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# Permission to use, copy, modify, and distribute this software for any |
7
|
|
|
|
|
|
|
# purpose with or without fee is hereby granted, provided that the above |
8
|
|
|
|
|
|
|
# copyright notice and this permission notice appear in all copies. |
9
|
|
|
|
|
|
|
# |
10
|
|
|
|
|
|
|
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
11
|
|
|
|
|
|
|
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
12
|
|
|
|
|
|
|
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
13
|
|
|
|
|
|
|
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
14
|
|
|
|
|
|
|
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
15
|
|
|
|
|
|
|
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
16
|
|
|
|
|
|
|
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
17
|
|
|
|
|
|
|
########################################################################## |
18
|
|
|
|
|
|
|
|
19
|
2
|
|
|
2
|
|
3677582
|
use strict; |
|
2
|
|
|
1
|
|
14
|
|
|
2
|
|
|
|
|
123
|
|
|
1
|
|
|
|
|
4782
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
20
|
2
|
|
|
2
|
|
22
|
use warnings; |
|
2
|
|
|
1
|
|
18
|
|
|
2
|
|
|
|
|
183
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
34
|
|
21
|
2
|
|
|
2
|
|
1751
|
use Getopt::Long qw(:config posix_default bundling); |
|
2
|
|
|
1
|
|
21353
|
|
|
2
|
|
|
|
|
10
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
7
|
|
22
|
2
|
|
|
2
|
|
1904
|
use OSPF::LSDB::ospfd; |
|
2
|
|
|
1
|
|
7
|
|
|
2
|
|
|
|
|
73
|
|
|
1
|
|
|
|
|
198
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
18
|
|
23
|
2
|
|
|
2
|
|
971
|
use OSPF::LSDB::ospf6d; |
|
2
|
|
|
1
|
|
7
|
|
|
2
|
|
|
|
|
120
|
|
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
16
|
|
24
|
2
|
|
|
2
|
|
866
|
use OSPF::LSDB::YAML; |
|
2
|
|
|
1
|
|
6
|
|
|
2
|
|
|
|
|
646
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
306
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub usage(@) { |
27
|
1
|
50
|
|
1
|
|
4
|
print STDERR "Error: @_\n" if @_; |
28
|
1
|
|
|
|
|
60
|
print STDERR <
|
29
|
|
|
|
|
|
|
Convert OpenBSD ospfd or ospf6d link state database to YAML file. |
30
|
|
|
|
|
|
|
If the ospfctl content files are not given on the command line, |
31
|
|
|
|
|
|
|
ospfctl is invoked on the local machine. |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
Usage: $0 [-46h] [-B boundary] [-E external] [-H user\@host] |
34
|
|
|
|
|
|
|
[-I selfid] [-N network] [-R router] [-S summary] [ospf.yaml] |
35
|
|
|
|
|
|
|
-4 use ospfd (default) |
36
|
|
|
|
|
|
|
-6 use ospf6d instead of ospfd |
37
|
|
|
|
|
|
|
-h help, print usage |
38
|
|
|
|
|
|
|
-B boundary file containg output of 'ospfctl show database asbr' |
39
|
|
|
|
|
|
|
-E external file containg output of 'ospfctl show database external' |
40
|
|
|
|
|
|
|
-H user\@host use ssh to login into user\@host to run ospfctl there |
41
|
|
|
|
|
|
|
-I selfid file containg output of 'ospfctl show summary' |
42
|
|
|
|
|
|
|
-L link file containg output of 'ospf6ctl show database link' |
43
|
|
|
|
|
|
|
-N network file containg output of 'ospfctl show database network' |
44
|
|
|
|
|
|
|
-P intra file containg output of 'ospf6ctl show database intra' |
45
|
|
|
|
|
|
|
-R router file containg output of 'ospfctl show database router' |
46
|
|
|
|
|
|
|
-S summary file containg output of 'ospfctl show database summary' |
47
|
|
|
|
|
|
|
ospf.yaml output file, default stdout |
48
|
|
|
|
|
|
|
EOF |
49
|
1
|
|
|
|
|
181
|
exit(2); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub main() { |
53
|
2
|
|
|
2
|
|
4
|
my %files; |
54
|
|
|
|
|
|
|
my $ipv6; |
55
|
2
|
|
|
|
|
0
|
my $ssh; |
56
|
|
|
|
|
|
|
GetOptions( |
57
|
0
|
|
|
0
|
|
0
|
'4' => sub { $ipv6 = 0 }, |
58
|
1
|
|
|
1
|
|
810
|
'6' => sub { $ipv6 = 1 }, |
59
|
1
|
|
|
1
|
|
872
|
'h' => sub { usage() }, |
60
|
|
|
|
|
|
|
'B=s' => \$files{boundary}, |
61
|
|
|
|
|
|
|
'E=s' => \$files{external}, |
62
|
|
|
|
|
|
|
'H=s' => \$ssh, |
63
|
|
|
|
|
|
|
'I=s' => \$files{selfid}, |
64
|
|
|
|
|
|
|
'L=s' => \$files{link}, |
65
|
|
|
|
|
|
|
'N=s' => \$files{network}, |
66
|
|
|
|
|
|
|
'P=s' => \$files{intra}, |
67
|
|
|
|
|
|
|
'R=s' => \$files{router}, |
68
|
|
|
|
|
|
|
'S=s' => \$files{summary}, |
69
|
2
|
50
|
|
|
|
26
|
) or usage("Bad option"); |
70
|
2
|
50
|
|
|
|
1847
|
usage("Only one arguments allowed") if @ARGV > 1; |
71
|
1
|
50
|
|
|
|
4
|
unless ($ipv6) { |
72
|
0
|
0
|
|
|
|
0
|
usage("Option -L also needs -6") if $files{link}; |
73
|
0
|
0
|
|
|
|
0
|
usage("Option -P also needs -6") if $files{intra}; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
1
|
50
|
|
|
|
3
|
my $class = $ipv6 ? 'OSPF::LSDB::ospf6d' : 'OSPF::LSDB::ospfd'; |
77
|
1
|
|
|
|
|
6
|
my $ospfd = $class->new(ssh => $ssh); |
78
|
1
|
|
|
|
|
7
|
$ospfd->parse(%files); |
79
|
|
|
|
|
|
|
|
80
|
1
|
|
|
|
|
10
|
my $yaml = OSPF::LSDB::YAML->new($ospfd); |
81
|
1
|
50
|
|
|
|
4
|
if (@ARGV > 0) { |
82
|
1
|
|
|
|
|
4
|
$yaml->DumpFile($ARGV[0]); |
83
|
|
|
|
|
|
|
} else { |
84
|
0
|
|
|
|
|
|
print $yaml->Dump(); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
main(); |