trema 0.4.5 → 0.4.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +4 -4
- data/Guardfile +8 -0
- data/Rakefile +2 -1
- data/bin/trema +4 -0
- data/cruise.rb +1 -1
- data/features/core/switch_manager.feature +2 -2
- data/features/examples/message.vendor-action.feature +2 -2
- data/features/examples/message.vendor-stats-request.feature +20 -0
- data/features/trema_commands/kill.feature +4 -0
- data/features/trema_commands/killall.feature +1 -0
- data/features/trema_commands/run.feature +20 -1
- data/ruby/trema/command/run.rb +4 -0
- data/ruby/trema/default_openflow_channel_port.rb +26 -0
- data/ruby/trema/dsl/configuration.rb +2 -1
- data/ruby/trema/open-vswitch.rb +2 -4
- data/ruby/trema/stats-reply.c +10 -1
- data/ruby/trema/stats-request.c +34 -1
- data/ruby/trema/vendor-stats-reply.rb +6 -2
- data/ruby/trema/version.rb +1 -1
- data/spec/trema/dsl/runner_spec.rb +1 -1
- data/spec/trema/dsl/syntax_spec.rb +1 -1
- data/spec/trema/shell/vswitch_spec.rb +1 -1
- data/spec/trema/stats-reply_spec.rb +2 -1
- data/spec/trema/stats-request_spec.rb +11 -0
- data/src/examples/cbench_switch/cbench-switch.rb +1 -0
- data/src/examples/cbench_switch/cbench_switch.c +1 -1
- data/src/examples/openflow_message/vendor-action.rb +4 -4
- data/src/examples/openflow_message/vendor-stats-request.rb +66 -0
- data/src/examples/simple_router/arp-table.rb +6 -17
- data/src/examples/simple_router/interface.rb +20 -29
- data/src/examples/simple_router/routing-table.rb +15 -22
- data/src/examples/simple_router/simple-router.rb +75 -64
- data/src/lib/chibach.c +3 -2
- data/src/lib/event_handler.c +55 -23
- data/src/lib/event_handler.h +0 -5
- data/src/lib/external_callback.c +126 -0
- data/src/lib/external_callback.h +46 -0
- data/src/lib/messenger.c +58 -35
- data/src/lib/openflow_message.c +32 -11
- data/src/lib/trema.c +13 -7
- data/src/lib/trema.h +1 -0
- data/src/lib/utility.c +13 -2
- data/src/switch_manager/secure_channel_receiver.c +6 -1
- data/src/switch_manager/switch.c +27 -26
- data/src/switch_manager/switch_manager.c +31 -10
- data/src/tremashark/packet_capture.c +3 -2
- data/src/tremashark/tremashark.c +2 -2
- data/trema.gemspec +1 -1
- data/unittests/lib/external_callback_test.c +282 -0
- data/unittests/lib/messenger_test.c +22 -0
- data/unittests/lib/openflow_message_test.c +1 -1
- data/unittests/lib/trema_test.c +1 -1
- data/unittests/switch_manager/switch_manager_test.c +3 -3
- metadata +12 -6
- data/src/examples/simple_router/router-utils.rb +0 -211
@@ -31,6 +31,7 @@
|
|
31
31
|
#include "checks.h"
|
32
32
|
#include "cmockery_trema.h"
|
33
33
|
#include "doubly_linked_list.h"
|
34
|
+
#include "external_callback.h"
|
34
35
|
#include "hash_table.h"
|
35
36
|
#include "event_handler.h"
|
36
37
|
#include "messenger.h"
|
@@ -163,6 +164,27 @@ static uint32_t last_transaction_id;
|
|
163
164
|
* Mocks.
|
164
165
|
********************************************************************************/
|
165
166
|
|
167
|
+
void
|
168
|
+
mock_init_external_callback() {
|
169
|
+
}
|
170
|
+
|
171
|
+
|
172
|
+
void
|
173
|
+
mock_finalize_external_callback() {
|
174
|
+
}
|
175
|
+
|
176
|
+
|
177
|
+
void
|
178
|
+
mock_push_external_callback( external_callback_t callback ) {
|
179
|
+
check_expected( callback );
|
180
|
+
}
|
181
|
+
|
182
|
+
|
183
|
+
void
|
184
|
+
mock_run_external_callback() {
|
185
|
+
}
|
186
|
+
|
187
|
+
|
166
188
|
void
|
167
189
|
mock_execute_timer_events( int *next_timeout_usec ) {
|
168
190
|
UNUSED( next_timeout_usec );
|
@@ -3505,7 +3505,7 @@ test_validate_stats_reply_fails_with_unsupported_stats_type() {
|
|
3505
3505
|
|
3506
3506
|
static void
|
3507
3507
|
test_validate_queue_stats_request() {
|
3508
|
-
buffer *port_stats_request = create_queue_stats_request( MY_TRANSACTION_ID, NO_FLAGS,
|
3508
|
+
buffer *port_stats_request = create_queue_stats_request( MY_TRANSACTION_ID, NO_FLAGS, 1, OFPQ_ALL );
|
3509
3509
|
|
3510
3510
|
assert_int_equal( validate_queue_stats_request( port_stats_request ), 0 );
|
3511
3511
|
|
data/unittests/lib/trema_test.c
CHANGED
@@ -333,7 +333,7 @@ mock_clock_gettime( clockid_t clk_id, struct timespec *tp ) {
|
|
333
333
|
|
334
334
|
|
335
335
|
bool
|
336
|
-
|
336
|
+
mock_push_external_callback( void ( *callback )( void ) ) {
|
337
337
|
UNUSED( callback );
|
338
338
|
return true;
|
339
339
|
}
|
@@ -167,7 +167,7 @@ mock_get_executable_name( void ) {
|
|
167
167
|
|
168
168
|
|
169
169
|
void
|
170
|
-
|
170
|
+
mock_push_external_callback( void ( *callback )( void ) ) {
|
171
171
|
check_expected( callback );
|
172
172
|
}
|
173
173
|
|
@@ -309,7 +309,7 @@ static void
|
|
309
309
|
test_handle_sigchld_succeeded() {
|
310
310
|
setup();
|
311
311
|
|
312
|
-
expect_value(
|
312
|
+
expect_value( mock_push_external_callback, callback, wait_child );
|
313
313
|
|
314
314
|
handle_sigchld( 3 );
|
315
315
|
|
@@ -625,7 +625,7 @@ test_switch_manager_main_and_port_option_succeeded() {
|
|
625
625
|
|
626
626
|
char *argv[] = {
|
627
627
|
( char * ) ( uintptr_t ) "switch_manager",
|
628
|
-
( char * ) ( uintptr_t ) "--port=
|
628
|
+
( char * ) ( uintptr_t ) "--port=6653",
|
629
629
|
NULL,
|
630
630
|
};
|
631
631
|
int argc = ARRAY_SIZE( argv ) - 1;
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trema
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yasuhito Takamiya
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.
|
61
|
+
version: 0.3.0
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ~>
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.
|
68
|
+
version: 0.3.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rake
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -113,6 +113,7 @@ files:
|
|
113
113
|
- CONTRIBUTING.md
|
114
114
|
- Doxyfile
|
115
115
|
- Gemfile
|
116
|
+
- Guardfile
|
116
117
|
- README.md
|
117
118
|
- Rakefile
|
118
119
|
- bin/quality
|
@@ -133,6 +134,7 @@ files:
|
|
133
134
|
- features/examples/list_switches.feature
|
134
135
|
- features/examples/message.set_config.feature
|
135
136
|
- features/examples/message.vendor-action.feature
|
137
|
+
- features/examples/message.vendor-stats-request.feature
|
136
138
|
- features/examples/multi_learning_switch.feature
|
137
139
|
- features/examples/openflow_message.echo.feature
|
138
140
|
- features/examples/openflow_message.features_request.feature
|
@@ -211,6 +213,7 @@ files:
|
|
211
213
|
- ruby/trema/default-logger.c
|
212
214
|
- ruby/trema/default-logger.h
|
213
215
|
- ruby/trema/default-logger.rb
|
216
|
+
- ruby/trema/default_openflow_channel_port.rb
|
214
217
|
- ruby/trema/desc-stats-reply.rb
|
215
218
|
- ruby/trema/dsl.rb
|
216
219
|
- ruby/trema/dsl/configuration.rb
|
@@ -466,6 +469,7 @@ files:
|
|
466
469
|
- src/examples/openflow_message/set-config.rb
|
467
470
|
- src/examples/openflow_message/set_config.c
|
468
471
|
- src/examples/openflow_message/vendor-action.rb
|
472
|
+
- src/examples/openflow_message/vendor-stats-request.rb
|
469
473
|
- src/examples/openflow_message/vendor_action.c
|
470
474
|
- src/examples/openflow_switch/echo_switch.c
|
471
475
|
- src/examples/openflow_switch/hello_switch.c
|
@@ -494,7 +498,6 @@ files:
|
|
494
498
|
- src/examples/simple_router/README
|
495
499
|
- src/examples/simple_router/arp-table.rb
|
496
500
|
- src/examples/simple_router/interface.rb
|
497
|
-
- src/examples/simple_router/router-utils.rb
|
498
501
|
- src/examples/simple_router/routing-table.rb
|
499
502
|
- src/examples/simple_router/simple-router.rb
|
500
503
|
- src/examples/simple_router/simple_router.conf
|
@@ -544,6 +547,8 @@ files:
|
|
544
547
|
- src/lib/event_forward_interface.h
|
545
548
|
- src/lib/event_handler.c
|
546
549
|
- src/lib/event_handler.h
|
550
|
+
- src/lib/external_callback.c
|
551
|
+
- src/lib/external_callback.h
|
547
552
|
- src/lib/hash_table.c
|
548
553
|
- src/lib/hash_table.h
|
549
554
|
- src/lib/icmp.h
|
@@ -664,6 +669,7 @@ files:
|
|
664
669
|
- unittests/lib/doubly_linked_list_test.c
|
665
670
|
- unittests/lib/ether_test.c
|
666
671
|
- unittests/lib/event_forward_interface_test.c
|
672
|
+
- unittests/lib/external_callback_test.c
|
667
673
|
- unittests/lib/hash_table_test.c
|
668
674
|
- unittests/lib/linked_list_test.c
|
669
675
|
- unittests/lib/log_test.c
|
@@ -814,7 +820,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
814
820
|
version: '0'
|
815
821
|
requirements: []
|
816
822
|
rubyforge_project:
|
817
|
-
rubygems_version: 2.
|
823
|
+
rubygems_version: 2.1.11
|
818
824
|
signing_key:
|
819
825
|
specification_version: 4
|
820
826
|
summary: Full-stack OpenFlow framework.
|
@@ -1,211 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# A router implementation in Trema
|
3
|
-
#
|
4
|
-
# Copyright (C) 2013 NEC Corporation
|
5
|
-
#
|
6
|
-
# This program is free software; you can redistribute it and/or modify
|
7
|
-
# it under the terms of the GNU General Public License, version 2, as
|
8
|
-
# published by the Free Software Foundation.
|
9
|
-
#
|
10
|
-
# This program is distributed in the hope that it will be useful,
|
11
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
-
# GNU General Public License for more details.
|
14
|
-
#
|
15
|
-
# You should have received a copy of the GNU General Public License along
|
16
|
-
# with this program; if not, write to the Free Software Foundation, Inc.,
|
17
|
-
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
18
|
-
#
|
19
|
-
|
20
|
-
|
21
|
-
require 'ipaddr'
|
22
|
-
|
23
|
-
|
24
|
-
def get_checksum csum, val
|
25
|
-
sum = ( ~csum & 0xffff ) + val
|
26
|
-
while sum > 0xffff
|
27
|
-
sum = ( sum & 0xffff ) + ( sum >> 16 )
|
28
|
-
end
|
29
|
-
~sum & 0xffff
|
30
|
-
end
|
31
|
-
|
32
|
-
|
33
|
-
class IPAddr
|
34
|
-
def to_a
|
35
|
-
self.to_s.split( "." ).collect do | each |
|
36
|
-
each.to_i
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
|
42
|
-
class EthernetHeader
|
43
|
-
attr_accessor :macda, :macsa, :eth_type
|
44
|
-
|
45
|
-
|
46
|
-
def initialize macda, macsa, eth_type
|
47
|
-
@macda = macda
|
48
|
-
@macsa = macsa
|
49
|
-
@eth_type = eth_type
|
50
|
-
end
|
51
|
-
|
52
|
-
|
53
|
-
def pack
|
54
|
-
( @macda.to_a + @macsa.to_a + [ eth_type ] ).pack( "C12n" )
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
|
59
|
-
class ARPPacket
|
60
|
-
attr_accessor :type, :tha, :sha, :tpa, :spa
|
61
|
-
|
62
|
-
|
63
|
-
def initialize type, tha, sha, tpa, spa
|
64
|
-
@type = type
|
65
|
-
@tha = tha
|
66
|
-
@sha = sha
|
67
|
-
@tpa = tpa
|
68
|
-
@spa = spa
|
69
|
-
end
|
70
|
-
|
71
|
-
|
72
|
-
def pack
|
73
|
-
eth_header = EthernetHeader.new( @tha, @sha, 0x0806 )
|
74
|
-
|
75
|
-
# arp
|
76
|
-
arp = [ 0x00, 0x01, 0x08, 0x00, 0x06, 0x04, 0x00, @type ]
|
77
|
-
arp += @sha.to_a + @spa.to_a + @tha.to_a + @tpa.to_a
|
78
|
-
|
79
|
-
while arp.length < 46 do
|
80
|
-
arp += [ 0x00 ]
|
81
|
-
end
|
82
|
-
|
83
|
-
eth_header.pack + arp.pack( "C*" )
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
|
88
|
-
class ARPRequest < ARPPacket
|
89
|
-
def initialize sha, tpa, spa
|
90
|
-
tha = [ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff ]
|
91
|
-
super( 1, tha, sha, tpa, spa )
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
|
96
|
-
class ARPReply < ARPPacket
|
97
|
-
def initialize tha, sha, tpa, spa
|
98
|
-
super( 2, tha, sha, tpa, spa )
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
|
103
|
-
class IPPacket
|
104
|
-
attr_accessor :id, :protocol, :daddr, :saddr, :payload
|
105
|
-
|
106
|
-
|
107
|
-
def initialize options
|
108
|
-
@id = options[ :id ]
|
109
|
-
@protocol = options[ :protocol ]
|
110
|
-
@daddr = options[ :daddr ]
|
111
|
-
@saddr = options[ :saddr ]
|
112
|
-
@payload = options[ :payload ]
|
113
|
-
@tot_len = 20 + payload.length
|
114
|
-
end
|
115
|
-
|
116
|
-
|
117
|
-
def pack
|
118
|
-
csum = get_checksum( 0, 0x4500 )
|
119
|
-
header = [ 0x45, 0x00 ] # Version, IHL, ToS
|
120
|
-
|
121
|
-
csum = get_checksum( csum, @tot_len )
|
122
|
-
header += [ @tot_len >> 8, @tot_len & 0xff ] # len
|
123
|
-
|
124
|
-
csum = get_checksum( csum, @id )
|
125
|
-
header += [ @id >> 8, @id & 0xff ] # ID
|
126
|
-
|
127
|
-
csum = get_checksum( csum, 0x4000 )
|
128
|
-
header += [ 0x40, 0x00 ] # Flags, Frag offset
|
129
|
-
|
130
|
-
csum = get_checksum( csum, 0x40 * 0x100 + @protocol )
|
131
|
-
header += [ 0x40, @protocol ] # ttl, protocol
|
132
|
-
|
133
|
-
csum = get_checksum( csum, @saddr.to_i >> 16 )
|
134
|
-
csum = get_checksum( csum, @saddr.to_i & 0xffff )
|
135
|
-
csum = get_checksum( csum, @daddr.to_i >> 16 )
|
136
|
-
csum = get_checksum( csum, @daddr.to_i & 0xffff )
|
137
|
-
header += [ csum >> 8, csum & 0xff ] # checksum
|
138
|
-
header += @saddr.to_a + @daddr.to_a
|
139
|
-
|
140
|
-
header.pack( "C*" ) + @payload.pack
|
141
|
-
end
|
142
|
-
end
|
143
|
-
|
144
|
-
|
145
|
-
class ICMPPacket
|
146
|
-
attr_reader :payload, :length
|
147
|
-
|
148
|
-
|
149
|
-
def initialize type, code, payload
|
150
|
-
@type = type
|
151
|
-
@code = code
|
152
|
-
@payload = payload
|
153
|
-
@length = 4 + payload.length
|
154
|
-
end
|
155
|
-
|
156
|
-
|
157
|
-
def pack
|
158
|
-
@checksum = get_checksum( 0, @type * 0x100 + @code )
|
159
|
-
|
160
|
-
words = @payload.pack( "C*" ).unpack( "n*" )
|
161
|
-
words.each do | each |
|
162
|
-
@checksum = get_checksum( @checksum, each )
|
163
|
-
end
|
164
|
-
|
165
|
-
[ @type, @code, @checksum ].pack( "C2n" ) + @payload.pack( "C*" )
|
166
|
-
end
|
167
|
-
end
|
168
|
-
|
169
|
-
|
170
|
-
class ICMPEchoReply < ICMPPacket
|
171
|
-
def initialize payload
|
172
|
-
super( 0x00, 0x00, payload )
|
173
|
-
end
|
174
|
-
end
|
175
|
-
|
176
|
-
|
177
|
-
module RouterUtils
|
178
|
-
def create_arp_request_from interface, addr
|
179
|
-
arp = ARPRequest.new( interface.hwaddr, addr, interface.ipaddr )
|
180
|
-
arp.pack
|
181
|
-
end
|
182
|
-
|
183
|
-
|
184
|
-
def create_arp_reply_from message, replyaddr
|
185
|
-
arp = ARPReply.new( message.macsa, replyaddr, message.arp_spa, message.arp_tpa )
|
186
|
-
arp.pack
|
187
|
-
end
|
188
|
-
|
189
|
-
|
190
|
-
def create_icmpv4_reply entry, interface, message
|
191
|
-
offset = 14 + 20 + 4
|
192
|
-
payload = message.data.unpack( "C*" )[ offset .. message.data.length - 1 ]
|
193
|
-
icmp = ICMPEchoReply.new( payload )
|
194
|
-
ip_packet = IPPacket.new( :id => message.ipv4_id,
|
195
|
-
:protocol => message.ipv4_protocol,
|
196
|
-
:ttl => message.ipv4_ttl,
|
197
|
-
:daddr => message.ipv4_saddr,
|
198
|
-
:saddr => message.ipv4_daddr,
|
199
|
-
:payload => icmp )
|
200
|
-
eth_header = EthernetHeader.new( entry.hwaddr, interface.hwaddr, 0x0800 )
|
201
|
-
|
202
|
-
eth_header.pack + ip_packet.pack
|
203
|
-
end
|
204
|
-
end
|
205
|
-
|
206
|
-
|
207
|
-
### Local variables:
|
208
|
-
### mode: Ruby
|
209
|
-
### coding: utf-8
|
210
|
-
### indent-tabs-mode: nil
|
211
|
-
### End:
|