line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
########################################################################## |
2
|
|
|
|
|
|
|
# Copyright (c) 2010-2021 Alexander Bluhm |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# Permission to use, copy, modify, and distribute this software for any |
5
|
|
|
|
|
|
|
# purpose with or without fee is hereby granted, provided that the above |
6
|
|
|
|
|
|
|
# copyright notice and this permission notice appear in all copies. |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
9
|
|
|
|
|
|
|
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
10
|
|
|
|
|
|
|
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
11
|
|
|
|
|
|
|
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
12
|
|
|
|
|
|
|
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
13
|
|
|
|
|
|
|
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
14
|
|
|
|
|
|
|
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
15
|
|
|
|
|
|
|
########################################################################## |
16
|
|
|
|
|
|
|
|
17
|
28
|
|
|
28
|
|
560535
|
use strict; |
|
28
|
|
|
|
|
128
|
|
|
28
|
|
|
|
|
715
|
|
18
|
28
|
|
|
28
|
|
118
|
use warnings; |
|
28
|
|
|
|
|
43
|
|
|
28
|
|
|
|
|
1042
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=pod |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 NAME |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
OSPF::LSDB::YAML - load or dump OSPF link state database as YAML |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 SYNOPSIS |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
use OSPF::LSDB; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
use OSPF::LSDB::YAML; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my $ospf = OSPF::LSDB-Enew(); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
my $yaml = OSPF::LSDB::YAML-Enew($ospf); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
$string = $yaml-EDump(); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
$yaml-EDumpFile($filename); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
$yaml-ELoad($string); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
$yaml-ELoadFile($filename); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 DESCRIPTION |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
The OSPF::LSDB::YAML module allows to load or dump a L |
47
|
|
|
|
|
|
|
instance in YAML format. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=cut |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
package OSPF::LSDB::YAML; |
52
|
28
|
|
|
28
|
|
127
|
use base qw(OSPF::LSDB); |
|
28
|
|
|
|
|
41
|
|
|
28
|
|
|
|
|
5797
|
|
53
|
28
|
|
|
28
|
|
10471
|
use YAML::Syck qw(); |
|
28
|
|
|
|
|
42915
|
|
|
28
|
|
|
|
|
4054
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=pod |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=over 4 |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=item $self-EDump() |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Return the L content as YAML string. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=cut |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub Dump { |
66
|
6
|
|
|
6
|
1
|
21310
|
my OSPF::LSDB $self = shift; |
67
|
6
|
|
|
|
|
32
|
return YAML::Syck::Dump($self->{ospf}); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=pod |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=item $self-EDumpFile($filepath) |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Write the L content as YAML into a file. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=cut |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub DumpFile { |
79
|
6
|
|
|
6
|
1
|
22608
|
my OSPF::LSDB $self = shift; |
80
|
6
|
|
|
|
|
11
|
my $filepath = shift; |
81
|
6
|
|
|
|
|
35
|
YAML::Syck::DumpFile($filepath, $self->{ospf}); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=pod |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=item $self-ELoad($string) |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Set the L base object to the given YAML string. |
89
|
|
|
|
|
|
|
The content is converted to the current version and is validated. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=cut |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub Load { |
94
|
176
|
|
|
176
|
1
|
1579
|
my OSPF::LSDB $self = shift; |
95
|
176
|
|
|
|
|
275
|
my $string = shift; |
96
|
176
|
|
|
|
|
740
|
$self->{ospf} = YAML::Syck::Load($string); |
97
|
176
|
|
|
|
|
28284
|
$self->convert(); |
98
|
176
|
|
|
|
|
527
|
$self->validate(); |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=pod |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=item $self-ELoadFile($filepath) |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Set the L base object to the given YAML file. |
106
|
|
|
|
|
|
|
The content is converted to the current version and is validated. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=back |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=cut |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub LoadFile { |
113
|
15
|
|
|
15
|
1
|
72
|
my OSPF::LSDB $self = shift; |
114
|
15
|
|
|
|
|
37
|
my $filepath = shift; |
115
|
15
|
|
|
|
|
64
|
$self->{ospf} = YAML::Syck::LoadFile($filepath); |
116
|
15
|
|
|
|
|
36081
|
$self->convert(); |
117
|
15
|
|
|
|
|
80
|
$self->validate(); |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=pod |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 ERRORS |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
The methods die if any error occures. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 SEE ALSO |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
L, |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
L |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 AUTHORS |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Alexander Bluhm |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=cut |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
1; |