| 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
|
|
751142
|
use strict; |
|
|
2
|
|
|
|
|
13
|
|
|
|
2
|
|
|
|
|
96
|
|
|
20
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
|
2
|
|
|
|
|
9
|
|
|
|
2
|
|
|
|
|
145
|
|
|
21
|
2
|
|
|
2
|
|
1311
|
use Getopt::Long qw(:config posix_default bundling); |
|
|
2
|
|
|
|
|
18588
|
|
|
|
2
|
|
|
|
|
9
|
|
|
22
|
2
|
|
|
2
|
|
1753
|
use OSPF::LSDB::gated; |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
79
|
|
|
23
|
2
|
|
|
2
|
|
879
|
use OSPF::LSDB::YAML; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
453
|
|
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub usage(@) { |
|
26
|
1
|
50
|
|
1
|
|
3
|
print STDERR "Error: @_\n" if @_; |
|
27
|
1
|
|
|
|
|
62
|
print STDERR <
|
|
28
|
|
|
|
|
|
|
Convert gated OSPF link state database to YAML file. If the gated |
|
29
|
|
|
|
|
|
|
dump content file is not given on the command line, gdc is invoked |
|
30
|
|
|
|
|
|
|
on the local machine. |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
Usage: $0 [-h] [-D dump] [-H user\@host] [-S skip] [ospf.yaml] |
|
33
|
|
|
|
|
|
|
-h help, print usage |
|
34
|
|
|
|
|
|
|
-D dump file containg output of 'gdc dump' |
|
35
|
|
|
|
|
|
|
-H user\@host use ssh to login into user\@host to run gdc there |
|
36
|
|
|
|
|
|
|
-S skip skip first number of gated entries in dump file |
|
37
|
|
|
|
|
|
|
ospf.yaml output file, default stdout |
|
38
|
|
|
|
|
|
|
EOF |
|
39
|
1
|
|
|
|
|
181
|
exit(2); |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub main() { |
|
43
|
2
|
|
|
2
|
|
4
|
my($file, $ssh, $skip); |
|
44
|
|
|
|
|
|
|
GetOptions( |
|
45
|
1
|
|
|
1
|
|
536
|
'h' => sub { usage() }, |
|
46
|
2
|
50
|
|
|
|
16
|
'D=s' => \$file, |
|
47
|
|
|
|
|
|
|
'H=s' => \$ssh, |
|
48
|
|
|
|
|
|
|
'S=i' => \$skip, |
|
49
|
|
|
|
|
|
|
) or usage("Bad option"); |
|
50
|
1
|
50
|
|
|
|
463
|
usage("Only one argument allowed") if @ARGV > 1; |
|
51
|
|
|
|
|
|
|
|
|
52
|
1
|
|
|
|
|
7
|
my $gated = OSPF::LSDB::gated->new(ssh => $ssh); |
|
53
|
1
|
|
|
|
|
4
|
my $ospf = $gated->parse(dump => !$file, file => $file, skip => $skip); |
|
54
|
|
|
|
|
|
|
|
|
55
|
1
|
|
|
|
|
16
|
my $yaml = OSPF::LSDB::YAML->new($gated); |
|
56
|
1
|
50
|
|
|
|
4
|
if (@ARGV > 0) { |
|
57
|
1
|
|
|
|
|
4
|
$yaml->DumpFile($ARGV[0]); |
|
58
|
|
|
|
|
|
|
} else { |
|
59
|
0
|
|
|
|
|
|
print $yaml->Dump(); |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
main(); |