trema 0.3.21 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.ruby-version +1 -1
- data/Gemfile +4 -4
- data/README.md +6 -9
- data/Rakefile +508 -24
- data/build.rb +4 -9
- data/cruise.rb +3 -3
- data/features/switch_event/add_forward_entry.feature +1 -0
- data/features/switch_event/delete_forward_entry.feature +1 -0
- data/features/switch_event/dump_forward_entries.feature +1 -0
- data/features/switch_event/set_forward_entries.feature +1 -0
- data/ruby/trema/compat.h +36 -0
- data/ruby/trema/controller.c +23 -7
- data/ruby/trema/default-logger.c +1 -1
- data/ruby/trema/features-reply.c +1 -1
- data/ruby/trema/switch-event.c +11 -10
- data/ruby/trema/switch.c +11 -11
- data/ruby/trema/version.rb +1 -1
- data/spec/support/matchers/constant.rb +25 -0
- data/spec/trema/barrier-request_spec.rb +1 -0
- data/spec/trema/controller_spec.rb +11 -28
- data/spec/trema/error_spec.rb +0 -46
- data/spec/trema/packet-out_spec.rb +1 -1
- data/spec/trema/port-status_spec.rb +8 -5
- data/spec/trema_spec.rb +64 -24
- data/src/lib/checks.h +2 -2
- data/src/lib/messenger.c +3 -3
- data/src/lib/openflow_message.c +8 -1
- data/src/lib/openflow_message.h +1 -0
- data/src/lib/openflow_switch_interface.c +1 -1
- data/src/switch_manager/secure_channel_listener.c +1 -1
- data/src/switch_manager/secure_channel_receiver.c +1 -1
- data/trema.gemspec +3 -3
- data/unittests/lib/daemon_test.c +1 -1
- data/unittests/lib/hash_table_test.c +1 -1
- metadata +87 -113
- data/.mono.rant +0 -4107
- data/Rantfile +0 -739
data/ruby/trema/compat.h
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (C) 2008-2013 NEC Corporation
|
3
|
+
*
|
4
|
+
* This program is free software; you can redistribute it and/or modify
|
5
|
+
* it under the terms of the GNU General Public License, version 2, as
|
6
|
+
* published by the Free Software Foundation.
|
7
|
+
*
|
8
|
+
* This program is distributed in the hope that it will be useful,
|
9
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
11
|
+
* GNU General Public License for more details.
|
12
|
+
*
|
13
|
+
* You should have received a copy of the GNU General Public License along
|
14
|
+
* with this program; if not, write to the Free Software Foundation, Inc.,
|
15
|
+
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
16
|
+
*/
|
17
|
+
|
18
|
+
|
19
|
+
#ifndef COMPAT_H
|
20
|
+
#define COMPAT_H
|
21
|
+
|
22
|
+
|
23
|
+
#ifndef RARRAY_LEN
|
24
|
+
#define RARRAY_LEN( ary ) RARRAY( ary )->len
|
25
|
+
#endif
|
26
|
+
|
27
|
+
|
28
|
+
#endif // COMPAT_H
|
29
|
+
|
30
|
+
|
31
|
+
/*
|
32
|
+
* Local variables:
|
33
|
+
* c-basic-offset: 2
|
34
|
+
* indent-tabs-mode: nil
|
35
|
+
* End:
|
36
|
+
*/
|
data/ruby/trema/controller.c
CHANGED
@@ -44,7 +44,7 @@ VALUE cController;
|
|
44
44
|
|
45
45
|
static void
|
46
46
|
handle_timer_event( void *self ) {
|
47
|
-
if ( rb_respond_to( ( VALUE ) self, rb_intern( "handle_timer_event" ) )
|
47
|
+
if ( rb_respond_to( ( VALUE ) self, rb_intern( "handle_timer_event" ) ) ) {
|
48
48
|
rb_funcall( ( VALUE ) self, rb_intern( "handle_timer_event" ), 0 );
|
49
49
|
}
|
50
50
|
}
|
@@ -195,8 +195,9 @@ controller_send_flow_mod( uint16_t command, int argc, VALUE *argv, VALUE self )
|
|
195
195
|
struct ofp_match default_match;
|
196
196
|
memset( &default_match, 0, sizeof( struct ofp_match ) );
|
197
197
|
default_match.wildcards = OFPFW_ALL;
|
198
|
+
uint32_t transaction_id;
|
198
199
|
struct ofp_match *match = &default_match;
|
199
|
-
uint64_t cookie
|
200
|
+
uint64_t cookie;
|
200
201
|
uint16_t idle_timeout = 0;
|
201
202
|
uint16_t hard_timeout = 0;
|
202
203
|
uint16_t priority = UINT16_MAX;
|
@@ -207,6 +208,14 @@ controller_send_flow_mod( uint16_t command, int argc, VALUE *argv, VALUE self )
|
|
207
208
|
|
208
209
|
// Options
|
209
210
|
if ( options != Qnil ) {
|
211
|
+
VALUE opt_transaction_id = rb_hash_aref( options, ID2SYM( rb_intern( "transaction_id" ) ) );
|
212
|
+
if ( opt_transaction_id != Qnil ) {
|
213
|
+
transaction_id = ( uint32_t ) NUM2ULONG( opt_transaction_id );
|
214
|
+
}
|
215
|
+
else {
|
216
|
+
transaction_id = get_transaction_id();
|
217
|
+
}
|
218
|
+
|
210
219
|
VALUE opt_match = rb_hash_aref( options, ID2SYM( rb_intern( "match" ) ) );
|
211
220
|
if ( opt_match != Qnil ) {
|
212
221
|
Data_Get_Struct( opt_match, struct ofp_match, match );
|
@@ -216,6 +225,9 @@ controller_send_flow_mod( uint16_t command, int argc, VALUE *argv, VALUE self )
|
|
216
225
|
if ( opt_cookie != Qnil ) {
|
217
226
|
cookie = NUM2ULL( opt_cookie );
|
218
227
|
}
|
228
|
+
else {
|
229
|
+
cookie = get_cookie();
|
230
|
+
}
|
219
231
|
|
220
232
|
VALUE opt_idle_timeout = rb_hash_aref( options, ID2SYM( rb_intern( "idle_timeout" ) ) );
|
221
233
|
if ( opt_idle_timeout != Qnil ) {
|
@@ -264,7 +276,7 @@ controller_send_flow_mod( uint16_t command, int argc, VALUE *argv, VALUE self )
|
|
264
276
|
}
|
265
277
|
|
266
278
|
buffer *flow_mod = create_flow_mod(
|
267
|
-
|
279
|
+
transaction_id,
|
268
280
|
*match,
|
269
281
|
cookie,
|
270
282
|
command,
|
@@ -302,6 +314,10 @@ controller_send_flow_mod( uint16_t command, int argc, VALUE *argv, VALUE self )
|
|
302
314
|
* the options to create a message with.
|
303
315
|
*
|
304
316
|
*
|
317
|
+
* @option options [Number, nil] :transaction_id (nil)
|
318
|
+
* Transaction ids, message sequence numbers matching requests to replies.
|
319
|
+
* nil means automatically generate transaction ID.
|
320
|
+
*
|
305
321
|
* @option options [Match, nil] :match (nil)
|
306
322
|
* A {Match} object describing the fields of the flow.
|
307
323
|
*
|
@@ -536,16 +552,16 @@ controller_send_packet_out( int argc, VALUE *argv, VALUE self ) {
|
|
536
552
|
*/
|
537
553
|
static VALUE
|
538
554
|
controller_run( VALUE self ) {
|
539
|
-
setenv( "TREMA_HOME",
|
555
|
+
setenv( "TREMA_HOME", RSTRING_PTR( rb_funcall( mTrema, rb_intern( "home" ), 0 ) ), 1 );
|
540
556
|
|
541
557
|
VALUE name = rb_funcall( self, rb_intern( "name" ), 0 );
|
542
558
|
rb_gv_set( "$PROGRAM_NAME", name );
|
543
559
|
|
544
560
|
int argc = 3;
|
545
561
|
char **argv = xmalloc( sizeof( char * ) * ( uint32_t ) ( argc + 1 ) );
|
546
|
-
argv[ 0 ] =
|
562
|
+
argv[ 0 ] = RSTRING_PTR( name );
|
547
563
|
argv[ 1 ] = ( char * ) ( uintptr_t ) "--name";
|
548
|
-
argv[ 2 ] =
|
564
|
+
argv[ 2 ] = RSTRING_PTR( name );
|
549
565
|
argv[ 3 ] = NULL;
|
550
566
|
init_trema( &argc, &argv );
|
551
567
|
xfree( argv );
|
@@ -571,7 +587,7 @@ controller_run( VALUE self ) {
|
|
571
587
|
interval.it_value.tv_nsec = 0;
|
572
588
|
add_timer_event_callback( &interval, handle_timer_event, ( void * ) self );
|
573
589
|
|
574
|
-
if ( rb_respond_to( self, rb_intern( "start" ) )
|
590
|
+
if ( rb_respond_to( self, rb_intern( "start" ) ) ) {
|
575
591
|
rb_funcall( self, rb_intern( "start" ), 0 );
|
576
592
|
}
|
577
593
|
|
data/ruby/trema/default-logger.c
CHANGED
@@ -28,7 +28,7 @@ VALUE mDefaultLogger;
|
|
28
28
|
static VALUE
|
29
29
|
do_log( void ( *log_function )( const char *format, ... ), int argc, VALUE *argv ) {
|
30
30
|
VALUE message = rb_f_sprintf( argc, argv );
|
31
|
-
log_function(
|
31
|
+
log_function( RSTRING_PTR( message ) );
|
32
32
|
return message;
|
33
33
|
}
|
34
34
|
|
data/ruby/trema/features-reply.c
CHANGED
@@ -245,7 +245,7 @@ Init_features_reply() {
|
|
245
245
|
|
246
246
|
void
|
247
247
|
handle_switch_ready( uint64_t datapath_id, void *controller ) {
|
248
|
-
if ( rb_respond_to( ( VALUE ) controller, rb_intern( "switch_ready" ) )
|
248
|
+
if ( rb_respond_to( ( VALUE ) controller, rb_intern( "switch_ready" ) ) ) {
|
249
249
|
rb_funcall( ( VALUE ) controller, rb_intern( "switch_ready" ), 1, ULL2NUM( datapath_id ) );
|
250
250
|
}
|
251
251
|
}
|
data/ruby/trema/switch-event.c
CHANGED
@@ -18,6 +18,7 @@
|
|
18
18
|
#include <assert.h>
|
19
19
|
#include "ruby.h"
|
20
20
|
#include "switch-event.h"
|
21
|
+
#include "compat.h"
|
21
22
|
|
22
23
|
#include "trema.h"
|
23
24
|
|
@@ -100,7 +101,7 @@ add_forward_entry_to_all_switches( VALUE self, VALUE type, VALUE service_name )
|
|
100
101
|
return Qfalse;
|
101
102
|
}
|
102
103
|
|
103
|
-
const char *c_service_name =
|
104
|
+
const char *c_service_name = RSTRING_PTR( service_name );
|
104
105
|
if ( strlen( c_service_name ) == 0 ) {
|
105
106
|
warn( "service_name cannot be empty" );
|
106
107
|
return Qfalse;
|
@@ -149,7 +150,7 @@ delete_forward_entry_from_all_switches( VALUE self, VALUE type,
|
|
149
150
|
return Qfalse;
|
150
151
|
}
|
151
152
|
|
152
|
-
const char *c_service_name =
|
153
|
+
const char *c_service_name = RSTRING_PTR( service_name );
|
153
154
|
if ( strlen( c_service_name ) == 0 ) {
|
154
155
|
warn( "service_name cannot be empty" );
|
155
156
|
return Qfalse;
|
@@ -225,7 +226,7 @@ add_forward_entry_to_switch( VALUE self, VALUE dpid, VALUE type,
|
|
225
226
|
}
|
226
227
|
|
227
228
|
const uint64_t c_dpid = NUM2ULL( dpid );
|
228
|
-
const char *c_service_name =
|
229
|
+
const char *c_service_name = RSTRING_PTR( service_name );
|
229
230
|
if ( strlen( c_service_name ) == 0 ) {
|
230
231
|
warn( "service_name cannot be empty" );
|
231
232
|
return Qfalse;
|
@@ -277,7 +278,7 @@ delete_forward_entry_from_switch( VALUE self, VALUE dpid, VALUE type,
|
|
277
278
|
}
|
278
279
|
|
279
280
|
const uint64_t c_dpid = NUM2ULL( dpid );
|
280
|
-
const char *c_service_name =
|
281
|
+
const char *c_service_name = RSTRING_PTR( service_name );
|
281
282
|
if ( strlen( c_service_name ) == 0 ) {
|
282
283
|
warn( "service_name cannot be empty" );
|
283
284
|
return Qfalse;
|
@@ -331,9 +332,9 @@ set_forward_entries_to_switch( VALUE self, VALUE dpid, VALUE type,
|
|
331
332
|
const uint64_t c_dpid = NUM2ULL( dpid );
|
332
333
|
list_element *service_list = NULL;
|
333
334
|
create_list( &service_list );
|
334
|
-
for ( long i = 0 ; i <
|
335
|
+
for ( long i = 0 ; i < RARRAY_LEN( service_names ) ; ++i ) {
|
335
336
|
VALUE ruby_service_name = rb_ary_entry( service_names, i );
|
336
|
-
char *c_service_name =
|
337
|
+
char *c_service_name = RSTRING_PTR( ruby_service_name );
|
337
338
|
if ( strlen( c_service_name ) == 0 ) {
|
338
339
|
warn( "Ignoring empty service_name" );
|
339
340
|
continue;
|
@@ -433,7 +434,7 @@ add_forward_entry_to_switch_manager( VALUE self, VALUE type,
|
|
433
434
|
return Qfalse;
|
434
435
|
}
|
435
436
|
|
436
|
-
const char *c_service_name =
|
437
|
+
const char *c_service_name = RSTRING_PTR( service_name );
|
437
438
|
if ( strlen( c_service_name ) == 0 ) {
|
438
439
|
warn( "service_name cannot be empty" );
|
439
440
|
return Qfalse;
|
@@ -483,7 +484,7 @@ delete_forward_entry_from_switch_manager( VALUE self, VALUE type,
|
|
483
484
|
return Qfalse;
|
484
485
|
}
|
485
486
|
|
486
|
-
const char *c_service_name =
|
487
|
+
const char *c_service_name = RSTRING_PTR( service_name );
|
487
488
|
if ( strlen( c_service_name ) == 0 ) {
|
488
489
|
warn( "service_name cannot be empty" );
|
489
490
|
return Qfalse;
|
@@ -535,9 +536,9 @@ set_forward_entries_to_switch_manager( VALUE self, VALUE type,
|
|
535
536
|
|
536
537
|
list_element *service_list = NULL;
|
537
538
|
create_list( &service_list );
|
538
|
-
for ( long i = 0 ; i <
|
539
|
+
for ( long i = 0 ; i < RARRAY_LEN( service_names ) ; ++i ) {
|
539
540
|
VALUE ruby_service_name = rb_ary_entry( service_names, i );
|
540
|
-
char *c_service_name =
|
541
|
+
char *c_service_name = RSTRING_PTR( ruby_service_name );
|
541
542
|
if ( strlen( c_service_name ) == 0 ) {
|
542
543
|
warn( "Ignoring empty service_name" );
|
543
544
|
continue;
|
data/ruby/trema/switch.c
CHANGED
@@ -40,7 +40,7 @@ switch_send_message( VALUE self, VALUE message ) {
|
|
40
40
|
|
41
41
|
static void
|
42
42
|
handle_controller_connected( void *rbswitch ) {
|
43
|
-
if ( rb_respond_to( ( VALUE ) rbswitch, rb_intern( "controller_connected" ) )
|
43
|
+
if ( rb_respond_to( ( VALUE ) rbswitch, rb_intern( "controller_connected" ) ) ) {
|
44
44
|
rb_funcall( ( VALUE ) rbswitch, rb_intern( "controller_connected" ), 0 );
|
45
45
|
}
|
46
46
|
}
|
@@ -48,7 +48,7 @@ handle_controller_connected( void *rbswitch ) {
|
|
48
48
|
|
49
49
|
static void
|
50
50
|
handle_hello( uint32_t transaction_id, uint8_t version, void *rbswitch ) {
|
51
|
-
if ( rb_respond_to( ( VALUE ) rbswitch, rb_intern( "hello" ) )
|
51
|
+
if ( rb_respond_to( ( VALUE ) rbswitch, rb_intern( "hello" ) ) ) {
|
52
52
|
rb_funcall( ( VALUE ) rbswitch, rb_intern( "hello" ), 2, UINT2NUM( transaction_id ), UINT2NUM( version ) );
|
53
53
|
}
|
54
54
|
}
|
@@ -56,7 +56,7 @@ handle_hello( uint32_t transaction_id, uint8_t version, void *rbswitch ) {
|
|
56
56
|
|
57
57
|
static void
|
58
58
|
handle_features_request( uint32_t transaction_id, void *rbswitch ) {
|
59
|
-
if ( rb_respond_to( ( VALUE ) rbswitch, rb_intern( "features_request" ) )
|
59
|
+
if ( rb_respond_to( ( VALUE ) rbswitch, rb_intern( "features_request" ) ) ) {
|
60
60
|
rb_funcall( ( VALUE ) rbswitch, rb_intern( "features_request" ), 1, UINT2NUM( transaction_id ) );
|
61
61
|
}
|
62
62
|
}
|
@@ -64,7 +64,7 @@ handle_features_request( uint32_t transaction_id, void *rbswitch ) {
|
|
64
64
|
|
65
65
|
static void
|
66
66
|
handle_set_config( uint32_t transaction_id, uint16_t flags, uint16_t miss_send_len, void *rbswitch ) {
|
67
|
-
if ( rb_respond_to( ( VALUE ) rbswitch, rb_intern( "set_config" ) )
|
67
|
+
if ( rb_respond_to( ( VALUE ) rbswitch, rb_intern( "set_config" ) ) ) {
|
68
68
|
rb_funcall( ( VALUE ) rbswitch, rb_intern( "set_config" ), 3, UINT2NUM( transaction_id ), UINT2NUM( flags ), UINT2NUM( miss_send_len ) );
|
69
69
|
}
|
70
70
|
}
|
@@ -92,7 +92,7 @@ handle_flow_mod(
|
|
92
92
|
UNUSED( out_port );
|
93
93
|
UNUSED( flags );
|
94
94
|
UNUSED( actions );
|
95
|
-
if ( rb_respond_to( ( VALUE ) rbswitch, rb_intern( "flow_mod" ) )
|
95
|
+
if ( rb_respond_to( ( VALUE ) rbswitch, rb_intern( "flow_mod" ) ) ) {
|
96
96
|
VALUE options = rb_hash_new();
|
97
97
|
rb_hash_aset( options, ID2SYM( rb_intern( "transaction_id" ) ), UINT2NUM( transaction_id ) );
|
98
98
|
rb_hash_aset( options, ID2SYM( rb_intern( "command" ) ), UINT2NUM( command ) );
|
@@ -106,7 +106,7 @@ handle_flow_mod(
|
|
106
106
|
|
107
107
|
static void
|
108
108
|
handle_echo_request( uint32_t transaction_id, const buffer *body, void *rbswitch ) {
|
109
|
-
if ( rb_respond_to( ( VALUE ) rbswitch, rb_intern( "echo_request" ) )
|
109
|
+
if ( rb_respond_to( ( VALUE ) rbswitch, rb_intern( "echo_request" ) ) ) {
|
110
110
|
VALUE rbody = rb_str_new( body->data, ( long ) body->length );
|
111
111
|
rb_funcall( ( VALUE ) rbswitch, rb_intern( "echo_request" ), 2, UINT2NUM( transaction_id ), rbody );
|
112
112
|
}
|
@@ -115,18 +115,18 @@ handle_echo_request( uint32_t transaction_id, const buffer *body, void *rbswitch
|
|
115
115
|
|
116
116
|
static VALUE
|
117
117
|
switch_run( VALUE self ) {
|
118
|
-
setenv( "CHIBACH_HOME",
|
118
|
+
setenv( "CHIBACH_HOME", RSTRING_PTR( rb_funcall( mTrema, rb_intern( "home" ), 0 ) ), 1 );
|
119
119
|
|
120
120
|
VALUE name = rb_funcall( self, rb_intern( "name" ), 0 );
|
121
121
|
rb_gv_set( "$PROGRAM_NAME", name );
|
122
122
|
|
123
123
|
int argc = 6;
|
124
124
|
char **argv = xmalloc( sizeof( char * ) * ( uint32_t ) ( argc + 1 ) );
|
125
|
-
argv[ 0 ] =
|
125
|
+
argv[ 0 ] = RSTRING_PTR( name );
|
126
126
|
argv[ 1 ] = ( char * ) ( uintptr_t ) "--name";
|
127
|
-
argv[ 2 ] =
|
127
|
+
argv[ 2 ] = RSTRING_PTR( name );
|
128
128
|
argv[ 3 ] = ( char * ) ( uintptr_t ) "--datapath_id";
|
129
|
-
argv[ 4 ] =
|
129
|
+
argv[ 4 ] = RSTRING_PTR( rb_funcall( rb_iv_get( self, "@dpid" ), rb_intern( "to_hex" ), 0 ) );
|
130
130
|
argv[ 5 ] = ( char * ) ( uintptr_t ) "--daemonize";
|
131
131
|
argv[ 6 ] = NULL;
|
132
132
|
init_chibach( &argc, &argv );
|
@@ -139,7 +139,7 @@ switch_run( VALUE self ) {
|
|
139
139
|
set_flow_mod_handler( handle_flow_mod, ( void * ) self );
|
140
140
|
set_echo_request_handler( handle_echo_request, ( void * ) self );
|
141
141
|
|
142
|
-
if ( rb_respond_to( self, rb_intern( "start" ) )
|
142
|
+
if ( rb_respond_to( self, rb_intern( "start" ) ) ) {
|
143
143
|
rb_funcall( self, rb_intern( "start" ), 0 );
|
144
144
|
}
|
145
145
|
|
data/ruby/trema/version.rb
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
RSpec::Matchers.define :have_constant do | const, klass |
|
2
|
+
match do | owner |
|
3
|
+
const_defined = owner.const_defined?( const )
|
4
|
+
klass_match = owner.const_get( const ).class == klass unless klass.nil?
|
5
|
+
klass.nil? ? const_defined : ( const_defined && klass_match )
|
6
|
+
end
|
7
|
+
|
8
|
+
failure_message_for_should do | actual |
|
9
|
+
msg = "constant #{ expected[ 0 ] } not defined in #{ actual }"
|
10
|
+
msg += " as a #{ expected[ 1 ] }" unless expected[ 1 ].nil?
|
11
|
+
msg
|
12
|
+
end
|
13
|
+
|
14
|
+
failure_message_for_should_not do | actual |
|
15
|
+
msg = "constant #{ expected[ 0 ] } is defined in #{ actual }"
|
16
|
+
msg += " as a #{ expected[ 1 ] }" unless expected[ 1 ].nil?
|
17
|
+
msg
|
18
|
+
end
|
19
|
+
|
20
|
+
description do
|
21
|
+
msg = "have constant #{ const }"
|
22
|
+
msg += " defined with class #{ klass }" unless klass.nil?
|
23
|
+
msg
|
24
|
+
end
|
25
|
+
end
|
@@ -28,6 +28,7 @@ shared_examples_for "barrier request message" do
|
|
28
28
|
vswitch( "barrier-request" ) { datapath_id 0xabc }
|
29
29
|
}.run( BarrierRequestController ) {
|
30
30
|
controller( "BarrierRequestController" ).send_message( 0xabc, subject )
|
31
|
+
sleep 2 # FIXME: wait to send_message
|
31
32
|
expect( IO.read( File.join( Trema.log, "openflowd.barrier-request.log" ) ) ).to include( "OFPT_BARRIER_REQUEST" )
|
32
33
|
}
|
33
34
|
end
|
@@ -22,22 +22,20 @@ require "trema"
|
|
22
22
|
|
23
23
|
module Trema
|
24
24
|
describe Controller do
|
25
|
-
|
26
|
-
subject { Controller.constants }
|
25
|
+
subject { Controller }
|
27
26
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
end
|
27
|
+
it { should have_constant :OFPP_MAX }
|
28
|
+
it { should have_constant :OFPP_IN_PORT }
|
29
|
+
it { should have_constant :OFPP_TABLE }
|
30
|
+
it { should have_constant :OFPP_NORMAL }
|
31
|
+
it { should have_constant :OFPP_FLOOD }
|
32
|
+
it { should have_constant :OFPP_ALL }
|
33
|
+
it { should have_constant :OFPP_CONTROLLER }
|
34
|
+
it { should have_constant :OFPP_LOCAL }
|
35
|
+
it { should have_constant :OFPP_NONE }
|
38
36
|
|
39
37
|
|
40
|
-
context "
|
38
|
+
context ".new" do
|
41
39
|
subject { Controller.new }
|
42
40
|
|
43
41
|
it { should respond_to :critical }
|
@@ -47,21 +45,6 @@ module Trema
|
|
47
45
|
it { should respond_to :info }
|
48
46
|
it { should respond_to :debug }
|
49
47
|
end
|
50
|
-
|
51
|
-
|
52
|
-
context "when sending flow_mod messages" do
|
53
|
-
it "should send a flow_mod_add message" do
|
54
|
-
class FlowModAddController < Controller; end
|
55
|
-
|
56
|
-
network {
|
57
|
-
vswitch { datapath_id 0xabc }
|
58
|
-
}.run( FlowModAddController ) {
|
59
|
-
controller( "FlowModAddController" ).send_flow_mod_add( 0xabc )
|
60
|
-
sleep 20 # FIXME: wait to send_flow_mod_add
|
61
|
-
expect( vswitch( "0xabc" ) ).to have( 1 ).flows
|
62
|
-
}
|
63
|
-
end
|
64
|
-
end
|
65
48
|
end
|
66
49
|
end
|
67
50
|
|
data/spec/trema/error_spec.rb
CHANGED
@@ -21,52 +21,6 @@ require "trema"
|
|
21
21
|
|
22
22
|
|
23
23
|
module Trema
|
24
|
-
describe Trema, ".constants", :nosudo => true do
|
25
|
-
subject { Trema.constants }
|
26
|
-
it { should include "OFPET_HELLO_FAILED" }
|
27
|
-
it { should include "OFPHFC_INCOMPATIBLE" }
|
28
|
-
it { should include "OFPHFC_EPERM" }
|
29
|
-
|
30
|
-
it { should include "OFPET_BAD_REQUEST" }
|
31
|
-
it { should include "OFPBRC_BAD_VERSION" }
|
32
|
-
it { should include "OFPBRC_BAD_TYPE" }
|
33
|
-
it { should include "OFPBRC_BAD_STAT" }
|
34
|
-
it { should include "OFPBRC_BAD_VENDOR" }
|
35
|
-
it { should include "OFPBRC_BAD_SUBTYPE" }
|
36
|
-
it { should include "OFPBRC_EPERM" }
|
37
|
-
it { should include "OFPBRC_BAD_LEN" }
|
38
|
-
it { should include "OFPBRC_BUFFER_EMPTY" }
|
39
|
-
it { should include "OFPBRC_BUFFER_UNKNOWN" }
|
40
|
-
|
41
|
-
it { should include "OFPET_BAD_ACTION" }
|
42
|
-
it { should include "OFPBAC_BAD_TYPE" }
|
43
|
-
it { should include "OFPBAC_BAD_LEN" }
|
44
|
-
it { should include "OFPBAC_BAD_VENDOR" }
|
45
|
-
it { should include "OFPBAC_BAD_VENDOR_TYPE" }
|
46
|
-
it { should include "OFPBAC_BAD_OUT_PORT" }
|
47
|
-
it { should include "OFPBAC_BAD_ARGUMENT" }
|
48
|
-
it { should include "OFPBAC_EPERM" }
|
49
|
-
it { should include "OFPBAC_TOO_MANY" }
|
50
|
-
it { should include "OFPBAC_BAD_QUEUE" }
|
51
|
-
|
52
|
-
it { should include "OFPET_FLOW_MOD_FAILED" }
|
53
|
-
it { should include "OFPFMFC_ALL_TABLES_FULL" }
|
54
|
-
it { should include "OFPFMFC_OVERLAP" }
|
55
|
-
it { should include "OFPFMFC_BAD_EMERG_TIMEOUT" }
|
56
|
-
it { should include "OFPFMFC_BAD_COMMAND" }
|
57
|
-
it { should include "OFPFMFC_UNSUPPORTED" }
|
58
|
-
|
59
|
-
it { should include "OFPET_PORT_MOD_FAILED" }
|
60
|
-
it { should include "OFPPMFC_BAD_PORT" }
|
61
|
-
it { should include "OFPPMFC_BAD_HW_ADDR" }
|
62
|
-
|
63
|
-
it { should include "OFPET_QUEUE_OP_FAILED" }
|
64
|
-
it { should include "OFPQOFC_BAD_PORT" }
|
65
|
-
it { should include "OFPQOFC_BAD_QUEUE" }
|
66
|
-
it { should include "OFPQOFC_EPERM" }
|
67
|
-
end
|
68
|
-
|
69
|
-
|
70
24
|
describe Error, ".new", :nosudo => true do
|
71
25
|
it { expect { subject }.to raise_error( ArgumentError, "Type and code are mandatory options" ) }
|
72
26
|
end
|
@@ -46,7 +46,7 @@ describe "packet-out" do
|
|
46
46
|
|
47
47
|
context "when invoked with no datapath_id" do
|
48
48
|
it "should raise an error" do
|
49
|
-
expect { PacketOutController.new.send_packet_out }.to raise_error
|
49
|
+
expect { PacketOutController.new.send_packet_out }.to raise_error
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
@@ -20,11 +20,14 @@ require File.join( File.dirname( __FILE__ ), "..", "spec_helper" )
|
|
20
20
|
require "trema"
|
21
21
|
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
module Trema
|
24
|
+
describe PortStatus do
|
25
|
+
subject { PortStatus }
|
26
|
+
|
27
|
+
it { should have_constant :OFPPR_ADD }
|
28
|
+
it { should have_constant :OFPPR_DELETE }
|
29
|
+
it { should have_constant :OFPPR_MODIFY }
|
30
|
+
end
|
28
31
|
end
|
29
32
|
|
30
33
|
|
data/spec/trema_spec.rb
CHANGED
@@ -20,30 +20,70 @@ require File.join( File.dirname( __FILE__ ), "spec_helper" )
|
|
20
20
|
require "trema"
|
21
21
|
|
22
22
|
|
23
|
-
describe Trema
|
24
|
-
|
25
|
-
|
26
|
-
it { should
|
27
|
-
it { should
|
28
|
-
it { should
|
29
|
-
it { should
|
30
|
-
it { should
|
31
|
-
it { should
|
32
|
-
|
33
|
-
it { should
|
34
|
-
|
35
|
-
it { should
|
36
|
-
it { should
|
37
|
-
it { should
|
38
|
-
it { should
|
39
|
-
it { should
|
40
|
-
it { should
|
41
|
-
it { should
|
42
|
-
it { should
|
43
|
-
it { should
|
44
|
-
it { should
|
45
|
-
|
46
|
-
it { should
|
23
|
+
describe Trema do
|
24
|
+
it { should have_constant :OFPC_FLOW_STATS }
|
25
|
+
it { should have_constant :OFPC_TABLE_STATS }
|
26
|
+
it { should have_constant :OFPC_PORT_STATS }
|
27
|
+
it { should have_constant :OFPC_STP }
|
28
|
+
it { should have_constant :OFPC_RESERVED }
|
29
|
+
it { should have_constant :OFPC_IP_REASM }
|
30
|
+
it { should have_constant :OFPC_QUEUE_STATS }
|
31
|
+
it { should have_constant :OFPC_ARP_MATCH_IP }
|
32
|
+
|
33
|
+
it { should have_constant :OFPAT_OUTPUT }
|
34
|
+
it { should have_constant :OFPAT_SET_VLAN_VID }
|
35
|
+
it { should have_constant :OFPAT_SET_VLAN_PCP }
|
36
|
+
it { should have_constant :OFPAT_STRIP_VLAN }
|
37
|
+
it { should have_constant :OFPAT_SET_DL_SRC }
|
38
|
+
it { should have_constant :OFPAT_SET_DL_DST }
|
39
|
+
it { should have_constant :OFPAT_SET_NW_SRC }
|
40
|
+
it { should have_constant :OFPAT_SET_NW_DST }
|
41
|
+
it { should have_constant :OFPAT_SET_NW_TOS }
|
42
|
+
it { should have_constant :OFPAT_SET_TP_DST }
|
43
|
+
it { should have_constant :OFPAT_ENQUEUE }
|
44
|
+
it { should have_constant :OFPAT_VENDOR }
|
45
|
+
|
46
|
+
it { should have_constant :OFPET_HELLO_FAILED }
|
47
|
+
it { should have_constant :OFPHFC_INCOMPATIBLE }
|
48
|
+
it { should have_constant :OFPHFC_EPERM }
|
49
|
+
|
50
|
+
it { should have_constant :OFPET_BAD_REQUEST }
|
51
|
+
it { should have_constant :OFPBRC_BAD_VERSION }
|
52
|
+
it { should have_constant :OFPBRC_BAD_TYPE }
|
53
|
+
it { should have_constant :OFPBRC_BAD_STAT }
|
54
|
+
it { should have_constant :OFPBRC_BAD_VENDOR }
|
55
|
+
it { should have_constant :OFPBRC_BAD_SUBTYPE }
|
56
|
+
it { should have_constant :OFPBRC_EPERM }
|
57
|
+
it { should have_constant :OFPBRC_BAD_LEN }
|
58
|
+
it { should have_constant :OFPBRC_BUFFER_EMPTY }
|
59
|
+
it { should have_constant :OFPBRC_BUFFER_UNKNOWN }
|
60
|
+
|
61
|
+
it { should have_constant :OFPET_BAD_ACTION }
|
62
|
+
it { should have_constant :OFPBAC_BAD_TYPE }
|
63
|
+
it { should have_constant :OFPBAC_BAD_LEN }
|
64
|
+
it { should have_constant :OFPBAC_BAD_VENDOR }
|
65
|
+
it { should have_constant :OFPBAC_BAD_VENDOR_TYPE }
|
66
|
+
it { should have_constant :OFPBAC_BAD_OUT_PORT }
|
67
|
+
it { should have_constant :OFPBAC_BAD_ARGUMENT }
|
68
|
+
it { should have_constant :OFPBAC_EPERM }
|
69
|
+
it { should have_constant :OFPBAC_TOO_MANY }
|
70
|
+
it { should have_constant :OFPBAC_BAD_QUEUE }
|
71
|
+
|
72
|
+
it { should have_constant :OFPET_FLOW_MOD_FAILED }
|
73
|
+
it { should have_constant :OFPFMFC_ALL_TABLES_FULL }
|
74
|
+
it { should have_constant :OFPFMFC_OVERLAP }
|
75
|
+
it { should have_constant :OFPFMFC_BAD_EMERG_TIMEOUT }
|
76
|
+
it { should have_constant :OFPFMFC_BAD_COMMAND }
|
77
|
+
it { should have_constant :OFPFMFC_UNSUPPORTED }
|
78
|
+
|
79
|
+
it { should have_constant :OFPET_PORT_MOD_FAILED }
|
80
|
+
it { should have_constant :OFPPMFC_BAD_PORT }
|
81
|
+
it { should have_constant :OFPPMFC_BAD_HW_ADDR }
|
82
|
+
|
83
|
+
it { should have_constant :OFPET_QUEUE_OP_FAILED }
|
84
|
+
it { should have_constant :OFPQOFC_BAD_PORT }
|
85
|
+
it { should have_constant :OFPQOFC_BAD_QUEUE }
|
86
|
+
it { should have_constant :OFPQOFC_EPERM }
|
47
87
|
end
|
48
88
|
|
49
89
|
|
data/src/lib/checks.h
CHANGED
@@ -20,9 +20,9 @@
|
|
20
20
|
#define CHECKS_H
|
21
21
|
|
22
22
|
|
23
|
-
#define
|
23
|
+
#define DEPRECATED_FUNCTION __attribute__ ( ( deprecated ) )
|
24
24
|
#define UNUSED( x ) ( void ) ( x )
|
25
|
-
#define
|
25
|
+
#define UNREACHABLE_CODE() die( "unreachable code" )
|
26
26
|
#define die_if_NULL( data ) \
|
27
27
|
if ( data == NULL ) { \
|
28
28
|
die( "Argument of %s must not be NULL.", __func__ ); \
|
data/src/lib/messenger.c
CHANGED
@@ -269,9 +269,9 @@ init_messenger( const char *working_directory ) {
|
|
269
269
|
|
270
270
|
strcpy( socket_directory, working_directory );
|
271
271
|
|
272
|
-
receive_queues =
|
273
|
-
send_queues =
|
274
|
-
context_db =
|
272
|
+
receive_queues = create_hash_with_size( compare_string, hash_string, 8 );
|
273
|
+
send_queues = create_hash_with_size( compare_string, hash_string, 8 );
|
274
|
+
context_db = create_hash_with_size( compare_uint32, hash_uint32, 128 );
|
275
275
|
|
276
276
|
initialized = true;
|
277
277
|
finalized = false;
|