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
|
|
718670
|
use strict; |
|
2
|
|
|
|
|
13
|
|
|
2
|
|
|
|
|
104
|
|
20
|
2
|
|
|
2
|
|
18
|
use warnings; |
|
2
|
|
|
|
|
14
|
|
|
2
|
|
|
|
|
144
|
|
21
|
2
|
|
|
2
|
|
1397
|
use Getopt::Long qw(:config posix_default bundling); |
|
2
|
|
|
|
|
19323
|
|
|
2
|
|
|
|
|
21
|
|
22
|
2
|
|
|
2
|
|
1633
|
use OSPF::LSDB::gated; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
97
|
|
23
|
2
|
|
|
2
|
|
1133
|
use OSPF::LSDB::YAML; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
478
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub usage(@) { |
26
|
1
|
50
|
|
1
|
|
5
|
print STDERR "Error: @_\n" if @_; |
27
|
1
|
|
|
|
|
66
|
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
|
|
|
|
|
186
|
exit(2); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub main() { |
43
|
2
|
|
|
2
|
|
4
|
my($file, $ssh, $skip); |
44
|
|
|
|
|
|
|
GetOptions( |
45
|
1
|
|
|
1
|
|
2600
|
'h' => sub { usage() }, |
46
|
2
|
50
|
|
|
|
19
|
'D=s' => \$file, |
47
|
|
|
|
|
|
|
'H=s' => \$ssh, |
48
|
|
|
|
|
|
|
'S=i' => \$skip, |
49
|
|
|
|
|
|
|
) or usage("Bad option"); |
50
|
1
|
50
|
|
|
|
610
|
usage("Only one argument allowed") if @ARGV > 1; |
51
|
|
|
|
|
|
|
|
52
|
1
|
|
|
|
|
15
|
my $gated = OSPF::LSDB::gated->new(ssh => $ssh); |
53
|
1
|
|
|
|
|
10
|
my $ospf = $gated->parse(dump => !$file, file => $file, skip => $skip); |
54
|
|
|
|
|
|
|
|
55
|
1
|
|
|
|
|
27
|
my $yaml = OSPF::LSDB::YAML->new($gated); |
56
|
1
|
50
|
|
|
|
5
|
if (@ARGV > 0) { |
57
|
1
|
|
|
|
|
8
|
$yaml->DumpFile($ARGV[0]); |
58
|
|
|
|
|
|
|
} else { |
59
|
0
|
|
|
|
|
|
print $yaml->Dump(); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
main(); |