ospfv2 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/ospfv2 +136 -0
- data/lib/ie/au_type.rb +79 -0
- data/lib/ie/external_route.rb +181 -0
- data/lib/ie/id.rb +97 -0
- data/lib/ie/interface_mtu.rb +64 -0
- data/lib/ie/ls_age.rb +89 -0
- data/lib/ie/ls_type.rb +148 -0
- data/lib/ie/metric.rb +63 -0
- data/lib/ie/mt_metric.rb +119 -0
- data/lib/ie/options.rb +356 -0
- data/lib/ie/ospf_version.rb +67 -0
- data/lib/ie/packet_type.rb +65 -0
- data/lib/ie/router_link.rb +167 -0
- data/lib/ie/router_link_factory.rb +53 -0
- data/lib/ie/router_link_type.rb +86 -0
- data/lib/ie/sequence_number.rb +144 -0
- data/lib/ie/tos_metric.rb +102 -0
- data/lib/infra/ospf_common.rb +291 -0
- data/lib/infra/ospf_constants.rb +73 -0
- data/lib/infra/ospf_io.rb +133 -0
- data/lib/infra/ospf_socket.rb +126 -0
- data/lib/infra/parse_options.rb +135 -0
- data/lib/infra/timer.rb +104 -0
- data/lib/infra/to_s.rb +38 -0
- data/lib/ls_db/advertised_routers.rb +78 -0
- data/lib/ls_db/common.rb +31 -0
- data/lib/ls_db/link_state_database.rb +376 -0
- data/lib/ls_db/link_state_database_build.rb +181 -0
- data/lib/ls_db/link_state_database_links.rb +178 -0
- data/lib/ls_db/links.rb +160 -0
- data/lib/lsa/external.rb +347 -0
- data/lib/lsa/lsa.rb +438 -0
- data/lib/lsa/lsa_factory.rb +59 -0
- data/lib/lsa/network.rb +166 -0
- data/lib/lsa/router.rb +336 -0
- data/lib/lsa/summary.rb +393 -0
- data/lib/neighbor/neighbor.rb +298 -0
- data/lib/neighbor/neighbor_event_handler.rb +61 -0
- data/lib/neighbor/recv_database_description.rb +153 -0
- data/lib/neighbor/recv_hello.rb +53 -0
- data/lib/neighbor/recv_ospf_packet.rb +68 -0
- data/lib/neighbor_sm/attempt_state.rb +44 -0
- data/lib/neighbor_sm/down_state.rb +46 -0
- data/lib/neighbor_sm/exchange_state.rb +32 -0
- data/lib/neighbor_sm/exstart_state.rb +69 -0
- data/lib/neighbor_sm/full_state.rb +36 -0
- data/lib/neighbor_sm/init_state.rb +43 -0
- data/lib/neighbor_sm/loading_state.rb +33 -0
- data/lib/neighbor_sm/neighbor_state.rb +87 -0
- data/lib/packet/database_description.rb +300 -0
- data/lib/packet/hello.rb +327 -0
- data/lib/packet/link_state_ack.rb +144 -0
- data/lib/packet/link_state_request.rb +153 -0
- data/lib/packet/link_state_update.rb +189 -0
- data/lib/packet/ospf_packet.rb +306 -0
- metadata +116 -0
@@ -0,0 +1,61 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright 2010 Jean-Michel Esnault.
|
3
|
+
# All rights reserved.
|
4
|
+
# See LICENSE.txt for permissions.
|
5
|
+
#
|
6
|
+
#
|
7
|
+
# This file is part of OSPFv2.
|
8
|
+
#
|
9
|
+
# OSPFv2 is free software: you can redistribute it and/or modify
|
10
|
+
# it under the terms of the GNU General Public License as published by
|
11
|
+
# the Free Software Foundation, either version 3 of the License, or
|
12
|
+
# (at your option) any later version.
|
13
|
+
#
|
14
|
+
# OSPFv2 is distributed in the hope that it will be useful,
|
15
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17
|
+
# GNU General Public License for more details.
|
18
|
+
#
|
19
|
+
# You should have received a copy of the GNU General Public License
|
20
|
+
# along with OSPFv2. If not, see <http://www.gnu.org/licenses/>.
|
21
|
+
#++
|
22
|
+
|
23
|
+
|
24
|
+
module OSPFv2
|
25
|
+
|
26
|
+
class NeighborEventHandler
|
27
|
+
|
28
|
+
def initialize(neighbor)
|
29
|
+
@neighbor = neighbor
|
30
|
+
@evQ = Queue.new
|
31
|
+
start_event_loop
|
32
|
+
end
|
33
|
+
|
34
|
+
def update(*args)
|
35
|
+
@evQ.enq(args)
|
36
|
+
end
|
37
|
+
|
38
|
+
def start_event_loop
|
39
|
+
@neighbor.debug "*** Event Loop Started ***"
|
40
|
+
Thread.new(@evQ) do |events|
|
41
|
+
loop do
|
42
|
+
ev_type, *ev = events.deq
|
43
|
+
case ev_type
|
44
|
+
when :ev_recv
|
45
|
+
bits, from, @port = ev
|
46
|
+
packet = OspfPacket.factory(bits[20..-1])
|
47
|
+
if packet
|
48
|
+
@neighbor.log :rcv, packet
|
49
|
+
@neighbor.__send__ "recv_#{packet.name}", packet, from, @port
|
50
|
+
else
|
51
|
+
STDERR.puts "Not an ospf packet: #{bits.unpack('H*')}"
|
52
|
+
end
|
53
|
+
else
|
54
|
+
@neighbor.log ev_type, ev.inspect
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,153 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright 2010 Jean-Michel Esnault.
|
3
|
+
# All rights reserved.
|
4
|
+
# See LICENSE.txt for permissions.
|
5
|
+
#
|
6
|
+
#
|
7
|
+
# This file is part of OSPFv2.
|
8
|
+
#
|
9
|
+
# OSPFv2 is free software: you can redistribute it and/or modify
|
10
|
+
# it under the terms of the GNU General Public License as published by
|
11
|
+
# the Free Software Foundation, either version 3 of the License, or
|
12
|
+
# (at your option) any later version.
|
13
|
+
#
|
14
|
+
# OSPFv2 is distributed in the hope that it will be useful,
|
15
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17
|
+
# GNU General Public License for more details.
|
18
|
+
#
|
19
|
+
# You should have received a copy of the GNU General Public License
|
20
|
+
# along with OSPFv2. If not, see <http://www.gnu.org/licenses/>.
|
21
|
+
#++
|
22
|
+
|
23
|
+
module OSPFv2
|
24
|
+
class Neighbor
|
25
|
+
|
26
|
+
def recv_database_description(rcv_dd, *args)
|
27
|
+
|
28
|
+
case state
|
29
|
+
when :exstart
|
30
|
+
|
31
|
+
if router_id.to_i > rcv_dd.router_id.to_i
|
32
|
+
debug "*** #{rcv_dd.router_id} is slave ***"
|
33
|
+
if rcv_dd.master?
|
34
|
+
debug "*** #{rcv_dd.router_id} claims mastership ***"
|
35
|
+
@last_dd_seqn += 1
|
36
|
+
dd = DatabaseDescription.new :router_id=> @router_id, :area_id=> @area_id, :imms=>7, :dd_sequence_number=>@last_dd_seqn
|
37
|
+
send_dd dd, true
|
38
|
+
elsif rcv_dd.seqn == @last_dd_seqn
|
39
|
+
negotiation_done
|
40
|
+
@last_dd_seqn += 1
|
41
|
+
if @ls_db
|
42
|
+
@ls_db.recv_dd(rcv_dd, @ls_req_list)
|
43
|
+
dd = DatabaseDescription.new :router_id=> @router_id, :area_id=> @area_id,
|
44
|
+
:ls_db => @ls_db, :number_of_lsa=>60
|
45
|
+
else
|
46
|
+
dd = DatabaseDescription.new :router_id=> @router_id, :area_id=> @area_id
|
47
|
+
end
|
48
|
+
dd.is_master
|
49
|
+
@last_dd_seqn = dd.seqn = @last_dd_seqn
|
50
|
+
send_dd dd, true
|
51
|
+
else
|
52
|
+
# just stay in ExStart ...
|
53
|
+
debug "*** @last_dd_seqn=#{@last_dd_seqn}, rcv_dd.seqn=#{rcv_dd.seqn} "
|
54
|
+
end
|
55
|
+
else
|
56
|
+
debug "*** #{rcv_dd.router_id} is master ***"
|
57
|
+
if rcv_dd.imms == 0x7
|
58
|
+
if @ls_db
|
59
|
+
@ls_db.recv_dd(rcv_dd, @ls_req_list)
|
60
|
+
dd = DatabaseDescription.new :router_id=> @router_id, :area_id=> @area_id, :ls_db => @ls_db
|
61
|
+
else
|
62
|
+
dd = DatabaseDescription.new :router_id=> @router_id, :area_id=> @area_id
|
63
|
+
dd.imms = 0 # no more
|
64
|
+
end
|
65
|
+
@last_dd_seqn_rcv = dd.seqn = rcv_dd.seqn
|
66
|
+
dd_rxmt_interval.cancel
|
67
|
+
send_dd dd, true
|
68
|
+
negotiation_done
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
when :exchange
|
73
|
+
|
74
|
+
@tot_dd ||=0
|
75
|
+
if rcv_dd.init?
|
76
|
+
new_state ExStart.new(self), 'Init'
|
77
|
+
|
78
|
+
elsif rcv_dd.master?
|
79
|
+
debug "*** #{rcv_dd.router_id} is master ***"
|
80
|
+
|
81
|
+
if rcv_dd.seqn - @last_dd_seqn_rcv == 1
|
82
|
+
@tot_dd += 1
|
83
|
+
@last_dd_seqn_rcv = rcv_dd.seqn
|
84
|
+
if @ls_db
|
85
|
+
@ls_db.recv_dd(rcv_dd, @ls_req_list)
|
86
|
+
@dd = DatabaseDescription.new :router_id=> @router_id, :area_id=> @area_id,
|
87
|
+
:ls_db => @ls_db, :dd_sequence_number=>rcv_dd.seqn
|
88
|
+
else
|
89
|
+
@dd = DatabaseDescription.new :router_id=> @router_id, :area_id=> @area_id
|
90
|
+
@dd.imms = 0 # no more
|
91
|
+
end
|
92
|
+
@dd.dd_sequence_number = rcv_dd.seqn
|
93
|
+
send_dd @dd, true
|
94
|
+
elsif rcv_dd.seqn == @last_dd_seqn_rcv
|
95
|
+
# use rxmt
|
96
|
+
else
|
97
|
+
@state.seq_number_mismatch(self)
|
98
|
+
end
|
99
|
+
|
100
|
+
unless rcv_dd.more? || @dd.more?
|
101
|
+
dd_rxmt_interval.cancel
|
102
|
+
new_state Loading.new(self), 'exchange_done'
|
103
|
+
new_state Full.new, 'no loading: req list is empty' if @ls_req_list.empty?
|
104
|
+
end
|
105
|
+
|
106
|
+
else
|
107
|
+
debug "*** #{rcv_dd.router_id} is slave ***"
|
108
|
+
|
109
|
+
if rcv_dd.seqn == @last_dd_seqn
|
110
|
+
|
111
|
+
if ! @sent_dd.more? && ! rcv_dd.more?
|
112
|
+
dd_rxmt_interval.cancel
|
113
|
+
new_state Loading.new(self), 'exchange_done'
|
114
|
+
new_state Full.new, 'no loading: req list is empty' if @ls_req_list.empty?
|
115
|
+
|
116
|
+
else
|
117
|
+
|
118
|
+
debug "*** OK: @last_dd_seqn=#{@last_dd_seqn}, rcv_dd.seqn=#{rcv_dd.seqn} "
|
119
|
+
|
120
|
+
@last_dd_seqn += 1
|
121
|
+
if @ls_db
|
122
|
+
@ls_db.recv_dd(rcv_dd, @ls_req_list)
|
123
|
+
@dd = DatabaseDescription.new :router_id=> @router_id, :area_id=> @area_id,
|
124
|
+
:ls_db => @ls_db, :number_of_lsa=>60
|
125
|
+
else
|
126
|
+
@dd.no_more
|
127
|
+
end
|
128
|
+
@dd.is_master
|
129
|
+
@dd.seqn = @last_dd_seqn
|
130
|
+
send_dd @dd, true
|
131
|
+
end
|
132
|
+
|
133
|
+
elsif @last_dd_seqn - rcv_dd.seqn == 1
|
134
|
+
debug "*** RXMT SHOULD FIX THIS: @last_dd_seqn=#{@last_dd_seqn}, rcv_dd.seqn=#{rcv_dd.seqn} "
|
135
|
+
else
|
136
|
+
debug "*** SHOULD GO TO EXSTART: @last_dd_seqn=#{@last_dd_seqn}, rcv_dd.seqn=#{rcv_dd.seqn} "
|
137
|
+
new_state Full.new, "SeqNumberMismatch"
|
138
|
+
end
|
139
|
+
|
140
|
+
end
|
141
|
+
|
142
|
+
else
|
143
|
+
debug "*** recv dd packet while in #{state} #{rcv_dd.imms}***"
|
144
|
+
unless rcv_dd.imms == 0
|
145
|
+
new_state ExStart.new(self), 'recv dd packet'
|
146
|
+
debug "*** recv dd packet while in #{state} ***"
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
end
|
152
|
+
|
153
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright 2010 Jean-Michel Esnault.
|
3
|
+
# All rights reserved.
|
4
|
+
# See LICENSE.txt for permissions.
|
5
|
+
#
|
6
|
+
#
|
7
|
+
# This file is part of OSPFv2.
|
8
|
+
#
|
9
|
+
# OSPFv2 is free software: you can redistribute it and/or modify
|
10
|
+
# it under the terms of the GNU General Public License as published by
|
11
|
+
# the Free Software Foundation, either version 3 of the License, or
|
12
|
+
# (at your option) any later version.
|
13
|
+
#
|
14
|
+
# OSPFv2 is distributed in the hope that it will be useful,
|
15
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17
|
+
# GNU General Public License for more details.
|
18
|
+
#
|
19
|
+
# You should have received a copy of the GNU General Public License
|
20
|
+
# along with OSPFv2. If not, see <http://www.gnu.org/licenses/>.
|
21
|
+
#++
|
22
|
+
|
23
|
+
module OSPFv2
|
24
|
+
class Neighbor
|
25
|
+
|
26
|
+
def recv_hello(hello, from, port)
|
27
|
+
@neighbor_ip = from
|
28
|
+
@state.recv_hello self, hello, from
|
29
|
+
rescue Exception => e
|
30
|
+
debug "rescued #{e.inspect}"
|
31
|
+
end
|
32
|
+
|
33
|
+
def recv_link_state_request(ls_request, from, port)
|
34
|
+
#TODO: check what address the LSU shoul be send to ? unicast ? AllDRouteres ? AllSpfRouters ?
|
35
|
+
send ls_request.to_lsu(@ls_db, :area_id=> @aread_id, :router_id => @router_id), from
|
36
|
+
end
|
37
|
+
|
38
|
+
def recv_link_state_update(ls_update, from, port)
|
39
|
+
ls_ack = LinkStateAck.ack_ls_update ls_update, :area_id=> @area_id, :router_id=> @router_id
|
40
|
+
send ls_ack, OSPFv2::AllDRouters #from
|
41
|
+
unless @ls_req_list.empty?
|
42
|
+
ls_update.each { |l|
|
43
|
+
if @ls_req_list.has_key?(l.key)
|
44
|
+
debug "*** deleting #{l.key.inspect} from Ls Req List! ***"
|
45
|
+
@ls_req_list.delete(l.key)
|
46
|
+
end
|
47
|
+
}
|
48
|
+
new_state Full.new, 'loading_done' if @ls_req_list.empty?
|
49
|
+
end
|
50
|
+
@ls_db.recv_link_state_update ls_update
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright 2010 Jean-Michel Esnault.
|
3
|
+
# All rights reserved.
|
4
|
+
# See LICENSE.txt for permissions.
|
5
|
+
#
|
6
|
+
#
|
7
|
+
# This file is part of OSPFv2.
|
8
|
+
#
|
9
|
+
# OSPFv2 is free software: you can redistribute it and/or modify
|
10
|
+
# it under the terms of the GNU General Public License as published by
|
11
|
+
# the Free Software Foundation, either version 3 of the License, or
|
12
|
+
# (at your option) any later version.
|
13
|
+
#
|
14
|
+
# OSPFv2 is distributed in the hope that it will be useful,
|
15
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17
|
+
# GNU General Public License for more details.
|
18
|
+
#
|
19
|
+
# You should have received a copy of the GNU General Public License
|
20
|
+
# along with OSPFv2. If not, see <http://www.gnu.org/licenses/>.
|
21
|
+
#++
|
22
|
+
|
23
|
+
require 'neighbor/recv_database_description'
|
24
|
+
# require 'neighbor/recv_hello'
|
25
|
+
|
26
|
+
module OSPFv2
|
27
|
+
class Neighbor
|
28
|
+
|
29
|
+
def recv_hello(hello, from, port)
|
30
|
+
@neighbor_ip = from
|
31
|
+
@state.recv_hello self, hello, from
|
32
|
+
rescue Exception => e
|
33
|
+
debug "rescued #{e.inspect}"
|
34
|
+
end
|
35
|
+
|
36
|
+
def recv_link_state_request(ls_request, from, port)
|
37
|
+
#TODO: check what address the LSU shoul be send to ? unicast ? AllDRouteres ? AllSpfRouters ?
|
38
|
+
send ls_request.to_lsu(@ls_db, :area_id=> @aread_id, :router_id => @router_id), from
|
39
|
+
end
|
40
|
+
|
41
|
+
def recv_link_state_update(ls_update, from, port)
|
42
|
+
unless in_state?(:full, :loading, :exchange)
|
43
|
+
debug "*** ignoring link state update received while in #{@state}!"
|
44
|
+
end
|
45
|
+
ls_ack = LinkStateAck.ack_ls_update ls_update, :area_id=> @area_id, :router_id=> @router_id
|
46
|
+
send ls_ack, OSPFv2::AllSPFRouters #from
|
47
|
+
unless @ls_req_list.empty?
|
48
|
+
ls_update.each { |l|
|
49
|
+
if @ls_req_list.has_key?(l.key)
|
50
|
+
debug "*** deleting #{l.key.inspect} from Ls Req List! ***"
|
51
|
+
@ls_req_list.delete(l.key)
|
52
|
+
end
|
53
|
+
}
|
54
|
+
new_state Full.new, 'loading_done' if @ls_req_list.empty?
|
55
|
+
end
|
56
|
+
@ls_db.recv_link_state_update ls_update if @ls_db
|
57
|
+
end
|
58
|
+
|
59
|
+
def recv_link_state_ack(ls_ack, from, port)
|
60
|
+
return unless @ls_db
|
61
|
+
before = @ls_db.all_not_acked.size
|
62
|
+
ls_ack.each { |lsa| @ls_db.ls_ack lsa }
|
63
|
+
debug "*** number of lsa acked : #{before - @ls_db.all_not_acked.size} ***"
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright 2010 Jean-Michel Esnault.
|
3
|
+
# All rights reserved.
|
4
|
+
# See LICENSE.txt for permissions.
|
5
|
+
#
|
6
|
+
#
|
7
|
+
# This file is part of OSPFv2.
|
8
|
+
#
|
9
|
+
# OSPFv2 is free software: you can redistribute it and/or modify
|
10
|
+
# it under the terms of the GNU General Public License as published by
|
11
|
+
# the Free Software Foundation, either version 3 of the License, or
|
12
|
+
# (at your option) any later version.
|
13
|
+
#
|
14
|
+
# OSPFv2 is distributed in the hope that it will be useful,
|
15
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17
|
+
# GNU General Public License for more details.
|
18
|
+
#
|
19
|
+
# You should have received a copy of the GNU General Public License
|
20
|
+
# along with OSPFv2. If not, see <http://www.gnu.org/licenses/>.
|
21
|
+
#++
|
22
|
+
|
23
|
+
require 'neighbor_sm/neighbor_state'
|
24
|
+
module OSPFv2
|
25
|
+
|
26
|
+
module NeighborState
|
27
|
+
|
28
|
+
class Attempt < State
|
29
|
+
|
30
|
+
def recv_hello(neighbor, hello, *args)
|
31
|
+
super
|
32
|
+
#TODO: check hello dead and hello interval and netmask ?
|
33
|
+
two_way_received(neighbor) if hello.has_neighbor?(neighbor.router_id)
|
34
|
+
end
|
35
|
+
|
36
|
+
def two_way_received(neighbor)
|
37
|
+
new_state neighbor, ExStart.new(neighbor), 'two_way_received'
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright 2010 Jean-Michel Esnault.
|
3
|
+
# All rights reserved.
|
4
|
+
# See LICENSE.txt for permissions.
|
5
|
+
#
|
6
|
+
#
|
7
|
+
# This file is part of OSPFv2.
|
8
|
+
#
|
9
|
+
# OSPFv2 is free software: you can redistribute it and/or modify
|
10
|
+
# it under the terms of the GNU General Public License as published by
|
11
|
+
# the Free Software Foundation, either version 3 of the License, or
|
12
|
+
# (at your option) any later version.
|
13
|
+
#
|
14
|
+
# OSPFv2 is distributed in the hope that it will be useful,
|
15
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17
|
+
# GNU General Public License for more details.
|
18
|
+
#
|
19
|
+
# You should have received a copy of the GNU General Public License
|
20
|
+
# along with OSPFv2. If not, see <http://www.gnu.org/licenses/>.
|
21
|
+
#++
|
22
|
+
|
23
|
+
require 'neighbor_sm/neighbor_state'
|
24
|
+
module OSPFv2
|
25
|
+
|
26
|
+
module NeighborState
|
27
|
+
|
28
|
+
class Down < State
|
29
|
+
|
30
|
+
def start(neighbor)
|
31
|
+
neighbor.instance_eval {
|
32
|
+
new_state Attempt.new, 'start'
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
def recv_hello(neighbor, rcv_hello, *args)
|
37
|
+
super
|
38
|
+
new_state neighbor, Init.new, 'recv_hello'
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
@@ -0,0 +1,32 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright 2010 Jean-Michel Esnault.
|
3
|
+
# All rights reserved.
|
4
|
+
# See LICENSE.txt for permissions.
|
5
|
+
#
|
6
|
+
#
|
7
|
+
# This file is part of OSPFv2.
|
8
|
+
#
|
9
|
+
# OSPFv2 is free software: you can redistribute it and/or modify
|
10
|
+
# it under the terms of the GNU General Public License as published by
|
11
|
+
# the Free Software Foundation, either version 3 of the License, or
|
12
|
+
# (at your option) any later version.
|
13
|
+
#
|
14
|
+
# OSPFv2 is distributed in the hope that it will be useful,
|
15
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17
|
+
# GNU General Public License for more details.
|
18
|
+
#
|
19
|
+
# You should have received a copy of the GNU General Public License
|
20
|
+
# along with OSPFv2. If not, see <http://www.gnu.org/licenses/>.
|
21
|
+
#++
|
22
|
+
|
23
|
+
require 'neighbor_sm/neighbor_state'
|
24
|
+
module OSPFv2
|
25
|
+
module NeighborState
|
26
|
+
class Exchange < State
|
27
|
+
def seq_number_mismatch(neighbor)
|
28
|
+
change_state(neighor, Exstart.new, 'seq_number_mismatch')
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright 2010 Jean-Michel Esnault.
|
3
|
+
# All rights reserved.
|
4
|
+
# See LICENSE.txt for permissions.
|
5
|
+
#
|
6
|
+
#
|
7
|
+
# This file is part of OSPFv2.
|
8
|
+
#
|
9
|
+
# OSPFv2 is free software: you can redistribute it and/or modify
|
10
|
+
# it under the terms of the GNU General Public License as published by
|
11
|
+
# the Free Software Foundation, either version 3 of the License, or
|
12
|
+
# (at your option) any later version.
|
13
|
+
#
|
14
|
+
# OSPFv2 is distributed in the hope that it will be useful,
|
15
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17
|
+
# GNU General Public License for more details.
|
18
|
+
#
|
19
|
+
# You should have received a copy of the GNU General Public License
|
20
|
+
# along with OSPFv2. If not, see <http://www.gnu.org/licenses/>.
|
21
|
+
#++
|
22
|
+
|
23
|
+
require 'neighbor_sm/neighbor_state'
|
24
|
+
module OSPFv2
|
25
|
+
module NeighborState
|
26
|
+
|
27
|
+
class ExStart < State
|
28
|
+
def initialize(n)
|
29
|
+
@neighbor = n
|
30
|
+
n.instance_eval do
|
31
|
+
@last_dd_seqn = n.dd_sequence_number
|
32
|
+
|
33
|
+
#-- could be a State#reset method inherited ?
|
34
|
+
@ls_db.reset if @ls_db
|
35
|
+
@ls_req_list={}
|
36
|
+
@periodic_refresh.cancel
|
37
|
+
@periodic_rxmt.cancel
|
38
|
+
#--
|
39
|
+
|
40
|
+
@last_dd_seqn = dd_sequence_number
|
41
|
+
raise unless @last_dd_seqn>0
|
42
|
+
|
43
|
+
p "***"
|
44
|
+
p @last_dd_seqn
|
45
|
+
|
46
|
+
dd = DatabaseDescription.new :router_id=> @router_id, :area_id=> @area_id,
|
47
|
+
:imms=>7, :dd_sequence_number => @last_dd_seqn
|
48
|
+
send_dd dd, true
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
def negotiation_done
|
54
|
+
@neighbor.instance_eval do
|
55
|
+
dd_rxmt_interval.cancel
|
56
|
+
new_state Exchange.new
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def adj_ok?
|
61
|
+
if ! ok
|
62
|
+
change_state(@neighbor, Two_way.new)
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright 2010 Jean-Michel Esnault.
|
3
|
+
# All rights reserved.
|
4
|
+
# See LICENSE.txt for permissions.
|
5
|
+
#
|
6
|
+
#
|
7
|
+
# This file is part of OSPFv2.
|
8
|
+
#
|
9
|
+
# OSPFv2 is free software: you can redistribute it and/or modify
|
10
|
+
# it under the terms of the GNU General Public License as published by
|
11
|
+
# the Free Software Foundation, either version 3 of the License, or
|
12
|
+
# (at your option) any later version.
|
13
|
+
#
|
14
|
+
# OSPFv2 is distributed in the hope that it will be useful,
|
15
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17
|
+
# GNU General Public License for more details.
|
18
|
+
#
|
19
|
+
# You should have received a copy of the GNU General Public License
|
20
|
+
# along with OSPFv2. If not, see <http://www.gnu.org/licenses/>.
|
21
|
+
#++
|
22
|
+
|
23
|
+
|
24
|
+
require 'neighbor_sm/neighbor_state'
|
25
|
+
module OSPFv2
|
26
|
+
module NeighborState
|
27
|
+
class Full < State
|
28
|
+
def recv_link_state_ack(neighbor, link_state_ack)
|
29
|
+
neighbor.debug "*** in full state object ev recv_link_state_ack ????? ****"
|
30
|
+
end
|
31
|
+
def recv_dd(neighbor, dd)
|
32
|
+
new_state neighbor, ExStart.new(neighbor), 'Received DatabaseDescription'
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright 2010 Jean-Michel Esnault.
|
3
|
+
# All rights reserved.
|
4
|
+
# See LICENSE.txt for permissions.
|
5
|
+
#
|
6
|
+
#
|
7
|
+
# This file is part of OSPFv2.
|
8
|
+
#
|
9
|
+
# OSPFv2 is free software: you can redistribute it and/or modify
|
10
|
+
# it under the terms of the GNU General Public License as published by
|
11
|
+
# the Free Software Foundation, either version 3 of the License, or
|
12
|
+
# (at your option) any later version.
|
13
|
+
#
|
14
|
+
# OSPFv2 is distributed in the hope that it will be useful,
|
15
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17
|
+
# GNU General Public License for more details.
|
18
|
+
#
|
19
|
+
# You should have received a copy of the GNU General Public License
|
20
|
+
# along with OSPFv2. If not, see <http://www.gnu.org/licenses/>.
|
21
|
+
#++
|
22
|
+
|
23
|
+
require 'neighbor_sm/neighbor_state'
|
24
|
+
module OSPFv2
|
25
|
+
module NeighborState
|
26
|
+
|
27
|
+
class Init < State
|
28
|
+
|
29
|
+
# recv_hello inherited
|
30
|
+
|
31
|
+
def recv_hello(neighbor, hello, *args)
|
32
|
+
super
|
33
|
+
two_way_received(neighbor) if hello.has_neighbor?(neighbor.router_id)
|
34
|
+
end
|
35
|
+
|
36
|
+
def two_way_received(neighbor, *args)
|
37
|
+
change_state(neighbor, ExStart.new(neighbor), 'two_way_received' )
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
@@ -0,0 +1,33 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright 2010 Jean-Michel Esnault.
|
3
|
+
# All rights reserved.
|
4
|
+
# See LICENSE.txt for permissions.
|
5
|
+
#
|
6
|
+
#
|
7
|
+
# This file is part of OSPFv2.
|
8
|
+
#
|
9
|
+
# OSPFv2 is free software: you can redistribute it and/or modify
|
10
|
+
# it under the terms of the GNU General Public License as published by
|
11
|
+
# the Free Software Foundation, either version 3 of the License, or
|
12
|
+
# (at your option) any later version.
|
13
|
+
#
|
14
|
+
# OSPFv2 is distributed in the hope that it will be useful,
|
15
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17
|
+
# GNU General Public License for more details.
|
18
|
+
#
|
19
|
+
# You should have received a copy of the GNU General Public License
|
20
|
+
# along with OSPFv2. If not, see <http://www.gnu.org/licenses/>.
|
21
|
+
#++
|
22
|
+
|
23
|
+
require 'neighbor_sm/neighbor_state'
|
24
|
+
module OSPFv2
|
25
|
+
module NeighborState
|
26
|
+
class Loading < State
|
27
|
+
def initialize(neighbor)
|
28
|
+
neighbor.start_periodic_rxmt
|
29
|
+
neighbor.start_ls_refresh
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|