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
|
|
3419752
|
use strict; |
|
2
|
|
|
1
|
|
16
|
|
|
2
|
|
|
|
|
104
|
|
|
1
|
|
|
|
|
4434
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
22
|
|
20
|
2
|
|
|
2
|
|
16
|
use warnings; |
|
2
|
|
|
1
|
|
3
|
|
|
2
|
|
|
|
|
134
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
21
|
2
|
|
|
2
|
|
1208
|
use Getopt::Long qw(:config posix_default bundling); |
|
2
|
|
|
1
|
|
17325
|
|
|
2
|
|
|
|
|
11
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
22
|
2
|
|
|
2
|
|
2205
|
use OSPF::LSDB::ospfd; |
|
2
|
|
|
1
|
|
8
|
|
|
2
|
|
|
|
|
62
|
|
|
1
|
|
|
|
|
233
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
16
|
|
23
|
2
|
|
|
2
|
|
777
|
use OSPF::LSDB::ospf6d; |
|
2
|
|
|
1
|
|
6
|
|
|
2
|
|
|
|
|
72
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
14
|
|
24
|
2
|
|
|
2
|
|
634
|
use OSPF::LSDB::YAML; |
|
2
|
|
|
1
|
|
5
|
|
|
2
|
|
|
|
|
573
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
275
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub usage(@) { |
27
|
1
|
50
|
|
1
|
|
4
|
print STDERR "Error: @_\n" if @_; |
28
|
1
|
|
|
|
|
53
|
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
|
|
|
|
|
144
|
exit(2); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub main() { |
53
|
2
|
|
|
2
|
|
5
|
my %files; |
54
|
|
|
|
|
|
|
my $ipv6; |
55
|
2
|
|
|
|
|
0
|
my $ssh; |
56
|
|
|
|
|
|
|
GetOptions( |
57
|
0
|
|
|
0
|
|
0
|
'4' => sub { $ipv6 = 0 }, |
58
|
1
|
|
|
1
|
|
712
|
'6' => sub { $ipv6 = 1 }, |
59
|
1
|
|
|
1
|
|
729
|
'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
|
|
|
|
22
|
) or usage("Bad option"); |
70
|
2
|
50
|
|
|
|
1526
|
usage("Only one arguments allowed") if @ARGV > 1; |
71
|
1
|
50
|
|
|
|
2
|
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
|
|
|
|
|
6
|
$ospfd->parse(%files); |
79
|
|
|
|
|
|
|
|
80
|
1
|
|
|
|
|
15
|
my $yaml = OSPF::LSDB::YAML->new($ospfd); |
81
|
1
|
50
|
|
|
|
5
|
if (@ARGV > 0) { |
82
|
1
|
|
|
|
|
7
|
$yaml->DumpFile($ARGV[0]); |
83
|
|
|
|
|
|
|
} else { |
84
|
0
|
|
|
|
|
|
print $yaml->Dump(); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
main(); |