line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Eixo::Zone::Artifact::NetworkVeth; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1988
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
61
|
|
4
|
1
|
|
|
1
|
|
9
|
use parent qw(Eixo::Zone::Artifact); |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
7
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub new{ |
7
|
|
|
|
|
|
|
|
8
|
0
|
|
|
0
|
0
|
|
my ($self) = bless({ |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
name=>$_[1], |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
ctl => $_[2], |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
f_created=>undef, |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
ns=>{}, |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
}, $_[0]); |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
|
($self->{a}, $self->{b}) = $self->generatePair; |
21
|
|
|
|
|
|
|
|
22
|
0
|
|
|
|
|
|
$self; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub DELETE{ |
27
|
|
|
|
|
|
|
|
28
|
0
|
0
|
|
0
|
|
|
$_[0]->delete if($_[0]->{f_created}); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub clean{ |
32
|
0
|
|
|
0
|
0
|
|
$_[0]->delete; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# this is an interface |
36
|
|
|
|
|
|
|
sub up{ |
37
|
0
|
|
|
0
|
0
|
|
my ($self, $extreme) = @_; |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
$extreme = lc($extreme); |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
my ($method, @extra) = $self->__getMethod("link_up", $extreme); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
$self->{ctl}->$method( |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
$self->{$extreme}, |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
@extra |
48
|
|
|
|
|
|
|
); |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
$self; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
0
|
0
|
|
sub down{ |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub setns{ |
58
|
0
|
|
|
0
|
0
|
|
my ($self, $ns, $extreme) = @_; |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
$extreme = lc($extreme); |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
$self->{ctl}->link_setns($self->{$extreme}, $ns); |
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
$self->{ns}->{$extreme} = $ns; |
65
|
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
$self; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub delete{ |
70
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
$self->{ctl}->link_delete($self->{a}) if( |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
$self->{ctl}->link_exists($self->{a}) |
75
|
|
|
|
|
|
|
|
76
|
0
|
0
|
|
|
|
|
); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub addr{ |
80
|
0
|
|
|
0
|
0
|
|
my ($self, $addr, $extreme) = @_; |
81
|
|
|
|
|
|
|
|
82
|
0
|
|
|
|
|
|
$extreme = lc($extreme); |
83
|
|
|
|
|
|
|
|
84
|
0
|
|
|
|
|
|
my ($method, @extra) = $self->__getMethod( |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
'link_addr', |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
$extreme |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
); |
91
|
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
|
$self->{ctl}->$method($self->{$extreme}, $addr, @extra); |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub create{ |
96
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
97
|
|
|
|
|
|
|
|
98
|
0
|
|
|
|
|
|
$self->{ctl}->link_create($self->{a}, $self->{b}); |
99
|
|
|
|
|
|
|
|
100
|
0
|
|
|
|
|
|
$self->{f_created} = 1; |
101
|
|
|
|
|
|
|
|
102
|
0
|
|
|
|
|
|
$self; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub generatePair{ |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
( |
108
|
|
|
|
|
|
|
$_[0]->{name} . "_a", |
109
|
|
|
|
|
|
|
|
110
|
0
|
|
|
0
|
0
|
|
$_[0]->{name} . "_b", |
111
|
|
|
|
|
|
|
) |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub __getMethod{ |
115
|
0
|
|
|
0
|
|
|
my ($self, $base_method, $extreme) = @_; |
116
|
|
|
|
|
|
|
|
117
|
0
|
0
|
|
|
|
|
if(my $ns = $self->{ns}->{$extreme}){ |
118
|
|
|
|
|
|
|
|
119
|
0
|
|
|
|
|
|
$base_method . '_ns', $ns; |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
else{ |
123
|
0
|
|
|
|
|
|
$base_method; |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
1; |