trema 0.3.19 → 0.3.20
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +7 -7
- data/README.md +3 -3
- data/Rakefile +13 -4
- data/cruise.rb +1 -1
- data/features/examples/switch_monitor.feature +2 -0
- data/features/switch_event/C-add_forward_entry.feature +4 -24
- data/features/switch_event/C-delete_forward_entry.feature +3 -18
- data/features/switch_event/C-dump_forward_entries.feature +2 -12
- data/features/switch_event/C-set_forward_entries.feature +2 -12
- data/features/switch_event/add_forward_entry.feature +44 -29
- data/features/switch_event/delete_forward_entry.feature +31 -16
- data/features/switch_event/dump_forward_entries.feature +23 -13
- data/features/switch_event/set_forward_entries.feature +17 -7
- data/features/trema_commands/dump_flows.feature +1 -0
- data/features/trema_commands/reset_stats.feature +1 -0
- data/features/trema_commands/show_stats.feature +1 -0
- data/ruby/trema/features-reply.c +9 -6
- data/ruby/trema/monkey-patch/integer/validators.rb +36 -0
- data/ruby/trema/monkey-patch/integer.rb +2 -0
- data/ruby/trema/packet-in.c +140 -0
- data/ruby/trema/packet-queue.rb +130 -126
- data/ruby/trema/port.c +11 -0
- data/ruby/trema/queue-get-config-reply.c +8 -5
- data/ruby/trema/set-ip-tos.rb +3 -3
- data/ruby/trema/vendor-action.rb +5 -1
- data/ruby/trema/version.rb +1 -1
- data/spec/trema/echo-reply_spec.rb +8 -8
- data/spec/trema/echo-request_spec.rb +1 -1
- data/spec/trema/hello_spec.rb +6 -6
- data/spec/trema/packet-in_spec.rb +131 -0
- data/spec/trema/queue-get-config-reply_spec.rb +1 -1
- data/spec/trema/set-ip-tos_spec.rb +5 -0
- data/spec/trema/vendor-action_spec.rb +5 -0
- data/src/examples/switch_event_config/.gitignore +0 -1
- data/src/examples/switch_event_config/network.conf +2 -0
- data/src/lib/arp.h +3 -1
- data/src/lib/ether.h +1 -0
- data/src/lib/event_forward_interface.c +9 -4
- data/src/lib/openflow_message.c +6 -0
- data/src/lib/openflow_message.h +1 -0
- data/src/lib/packet_info.c +23 -0
- data/src/lib/packet_info.h +5 -0
- data/src/lib/packet_parser.c +8 -3
- data/src/lib/utility.c +13 -13
- data/src/lib/utility.h +15 -0
- data/src/switch_manager/event_forward_entry_manipulation.c +1 -1
- data/src/switch_manager/secure_channel_listener.c +3 -6
- data/src/switch_manager/switch.c +68 -9
- data/trema.gemspec +4 -4
- data/unittests/lib/event_forward_interface_test.c +30 -0
- data/unittests/lib/openflow_message_test.c +19 -0
- data/unittests/lib/packet_info_test.c +16 -0
- data/unittests/lib/packet_parser_test.c +37 -0
- data/unittests/lib/test_packets/rarp_req.cap +0 -0
- metadata +9 -6
data/src/lib/utility.c
CHANGED
@@ -310,7 +310,7 @@ phy_port_to_string( const struct ofp_phy_port *phy_port, char *str, size_t size
|
|
310
310
|
}
|
311
311
|
|
312
312
|
|
313
|
-
|
313
|
+
bool
|
314
314
|
action_output_to_string( const struct ofp_action_output *action, char *str, size_t size ) {
|
315
315
|
assert( action != NULL );
|
316
316
|
assert( str != NULL );
|
@@ -324,7 +324,7 @@ action_output_to_string( const struct ofp_action_output *action, char *str, size
|
|
324
324
|
}
|
325
325
|
|
326
326
|
|
327
|
-
|
327
|
+
bool
|
328
328
|
action_set_vlan_vid_to_string( const struct ofp_action_vlan_vid *action, char *str, size_t size ) {
|
329
329
|
assert( action != NULL );
|
330
330
|
assert( str != NULL );
|
@@ -338,7 +338,7 @@ action_set_vlan_vid_to_string( const struct ofp_action_vlan_vid *action, char *s
|
|
338
338
|
}
|
339
339
|
|
340
340
|
|
341
|
-
|
341
|
+
bool
|
342
342
|
action_set_vlan_pcp_to_string( const struct ofp_action_vlan_pcp *action, char *str, size_t size ) {
|
343
343
|
assert( action != NULL );
|
344
344
|
assert( str != NULL );
|
@@ -352,7 +352,7 @@ action_set_vlan_pcp_to_string( const struct ofp_action_vlan_pcp *action, char *s
|
|
352
352
|
}
|
353
353
|
|
354
354
|
|
355
|
-
|
355
|
+
bool
|
356
356
|
action_strip_vlan_to_string( const struct ofp_action_header *action, char *str, size_t size ) {
|
357
357
|
UNUSED( action );
|
358
358
|
assert( action != NULL );
|
@@ -384,13 +384,13 @@ action_dl_addr_to_string( const struct ofp_action_dl_addr *action, char *str, si
|
|
384
384
|
}
|
385
385
|
|
386
386
|
|
387
|
-
|
387
|
+
bool
|
388
388
|
action_set_dl_src_to_string( const struct ofp_action_dl_addr *action, char *str, size_t size ) {
|
389
389
|
return action_dl_addr_to_string( action, str, size, OFPAT_SET_DL_SRC );
|
390
390
|
}
|
391
391
|
|
392
392
|
|
393
|
-
|
393
|
+
bool
|
394
394
|
action_set_dl_dst_to_string( const struct ofp_action_dl_addr *action, char *str, size_t size ) {
|
395
395
|
return action_dl_addr_to_string( action, str, size, OFPAT_SET_DL_DST );
|
396
396
|
}
|
@@ -416,19 +416,19 @@ action_nw_addr_to_string( const struct ofp_action_nw_addr *action, char *str, si
|
|
416
416
|
}
|
417
417
|
|
418
418
|
|
419
|
-
|
419
|
+
bool
|
420
420
|
action_set_nw_src_to_string( const struct ofp_action_nw_addr *action, char *str, size_t size ) {
|
421
421
|
return action_nw_addr_to_string( action, str, size, OFPAT_SET_NW_SRC );
|
422
422
|
}
|
423
423
|
|
424
424
|
|
425
|
-
|
425
|
+
bool
|
426
426
|
action_set_nw_dst_to_string( const struct ofp_action_nw_addr *action, char *str, size_t size ) {
|
427
427
|
return action_nw_addr_to_string( action, str, size, OFPAT_SET_NW_DST );
|
428
428
|
}
|
429
429
|
|
430
430
|
|
431
|
-
|
431
|
+
bool
|
432
432
|
action_set_nw_tos_to_string( const struct ofp_action_nw_tos *action, char *str, size_t size ) {
|
433
433
|
assert( action != NULL );
|
434
434
|
assert( str != NULL );
|
@@ -457,19 +457,19 @@ action_tp_port_to_string( const struct ofp_action_tp_port *action, char *str, si
|
|
457
457
|
}
|
458
458
|
|
459
459
|
|
460
|
-
|
460
|
+
bool
|
461
461
|
action_set_tp_src_to_string( const struct ofp_action_tp_port *action, char *str, size_t size ) {
|
462
462
|
return action_tp_port_to_string( action, str, size, OFPAT_SET_TP_SRC );
|
463
463
|
}
|
464
464
|
|
465
465
|
|
466
|
-
|
466
|
+
bool
|
467
467
|
action_set_tp_dst_to_string( const struct ofp_action_tp_port *action, char *str, size_t size ) {
|
468
468
|
return action_tp_port_to_string( action, str, size, OFPAT_SET_TP_DST );
|
469
469
|
}
|
470
470
|
|
471
471
|
|
472
|
-
|
472
|
+
bool
|
473
473
|
action_enqueue_to_string( const struct ofp_action_enqueue *action, char *str, size_t size ) {
|
474
474
|
assert( action != NULL );
|
475
475
|
assert( str != NULL );
|
@@ -483,7 +483,7 @@ action_enqueue_to_string( const struct ofp_action_enqueue *action, char *str, si
|
|
483
483
|
}
|
484
484
|
|
485
485
|
|
486
|
-
|
486
|
+
bool
|
487
487
|
action_vendor_to_string( const struct ofp_action_vendor_header *action, char *str, size_t size ) {
|
488
488
|
assert( action != NULL );
|
489
489
|
assert( str != NULL );
|
data/src/lib/utility.h
CHANGED
@@ -50,6 +50,20 @@ bool string_to_datapath_id( const char *str, uint64_t *datapath_id );
|
|
50
50
|
bool match_to_string( const struct ofp_match *match, char *str, size_t size );
|
51
51
|
bool wildcards_to_string( uint32_t wildcards, char *str, size_t size );
|
52
52
|
bool phy_port_to_string( const struct ofp_phy_port *phy_port, char *str, size_t size );
|
53
|
+
|
54
|
+
bool action_output_to_string( const struct ofp_action_output *action, char *str, size_t size );
|
55
|
+
bool action_set_vlan_vid_to_string( const struct ofp_action_vlan_vid *action, char *str, size_t size );
|
56
|
+
bool action_set_vlan_pcp_to_string( const struct ofp_action_vlan_pcp *action, char *str, size_t size );
|
57
|
+
bool action_strip_vlan_to_string( const struct ofp_action_header *action, char *str, size_t size );
|
58
|
+
bool action_set_dl_src_to_string( const struct ofp_action_dl_addr *action, char *str, size_t size );
|
59
|
+
bool action_set_dl_dst_to_string( const struct ofp_action_dl_addr *action, char *str, size_t size );
|
60
|
+
bool action_set_nw_src_to_string( const struct ofp_action_nw_addr *action, char *str, size_t size );
|
61
|
+
bool action_set_nw_dst_to_string( const struct ofp_action_nw_addr *action, char *str, size_t size );
|
62
|
+
bool action_set_nw_tos_to_string( const struct ofp_action_nw_tos *action, char *str, size_t size );
|
63
|
+
bool action_set_tp_src_to_string( const struct ofp_action_tp_port *action, char *str, size_t size );
|
64
|
+
bool action_set_tp_dst_to_string( const struct ofp_action_tp_port *action, char *str, size_t size );
|
65
|
+
bool action_enqueue_to_string( const struct ofp_action_enqueue *action, char *str, size_t size );
|
66
|
+
bool action_vendor_to_string( const struct ofp_action_vendor_header *action, char *str, size_t size );
|
53
67
|
bool actions_to_string( const struct ofp_action_header *actions, uint16_t actions_length, char *str, size_t str_length );
|
54
68
|
|
55
69
|
uint16_t get_checksum( uint16_t *pos, uint32_t size );
|
@@ -58,6 +72,7 @@ void xfree_data( void *data, void *user_data );
|
|
58
72
|
|
59
73
|
bool string_equal( void *data, void *user_data );
|
60
74
|
|
75
|
+
|
61
76
|
#endif // UTILITY_H
|
62
77
|
|
63
78
|
|
@@ -36,7 +36,7 @@ management_event_forward_entry_add( list_element **service_list,
|
|
36
36
|
const char *match = find_list_custom( *service_list, string_equal, service_name );
|
37
37
|
if ( match == NULL ) {
|
38
38
|
info( "Adding '%s' to event filter.", service_name );
|
39
|
-
|
39
|
+
append_to_tail( service_list, service_name );
|
40
40
|
}
|
41
41
|
else {
|
42
42
|
// already there
|
@@ -34,7 +34,6 @@
|
|
34
34
|
|
35
35
|
|
36
36
|
const int LISTEN_SOCK_MAX = 128;
|
37
|
-
const int SWITCH_MANAGER_DEFAULT_ARGC = 10;
|
38
37
|
|
39
38
|
#ifdef UNIT_TESTING
|
40
39
|
#define static
|
@@ -166,7 +165,8 @@ secure_channel_listen_start( struct listener_info *listener_info ) {
|
|
166
165
|
|
167
166
|
static char **
|
168
167
|
make_switch_daemon_args( struct listener_info *listener_info, struct sockaddr_in *addr, int accept_fd ) {
|
169
|
-
const int
|
168
|
+
const int SWITCH_DAEMON_DEFAULT_ARGC = 4;
|
169
|
+
const int argc = SWITCH_DAEMON_DEFAULT_ARGC
|
170
170
|
+ listener_info->switch_daemon_argc
|
171
171
|
+ ( int ) list_length_of( listener_info->vendor_service_name_list )
|
172
172
|
+ ( int ) list_length_of( listener_info->packetin_service_name_list )
|
@@ -176,7 +176,7 @@ make_switch_daemon_args( struct listener_info *listener_info, struct sockaddr_in
|
|
176
176
|
char **argv = xcalloc( ( size_t ) argc, sizeof( char * ) );
|
177
177
|
char *command_name = xasprintf( "%s%s:%u", SWITCH_MANAGER_COMMAND_PREFIX,
|
178
178
|
inet_ntoa( addr->sin_addr ),
|
179
|
-
|
179
|
+
ntohs( addr->sin_port ) );
|
180
180
|
char *service_name = xasprintf( "%s%s%s:%u", SWITCH_MANAGER_NAME_OPTION,
|
181
181
|
SWITCH_MANAGER_PREFIX,
|
182
182
|
inet_ntoa( addr->sin_addr ),
|
@@ -184,15 +184,12 @@ make_switch_daemon_args( struct listener_info *listener_info, struct sockaddr_in
|
|
184
184
|
char *socket_opt = xasprintf( "%s%d", SWITCH_MANAGER_SOCKET_OPTION,
|
185
185
|
accept_fd );
|
186
186
|
char *daemonize_opt = xstrdup( SWITCH_MANAGER_DAEMONIZE_OPTION );
|
187
|
-
char *notify_opt = xasprintf( "%s%s", SWITCH_MANAGER_STATE_PREFIX,
|
188
|
-
get_trema_name() );
|
189
187
|
|
190
188
|
int i = 0;
|
191
189
|
argv[ i++ ] = command_name;
|
192
190
|
argv[ i++ ] = service_name;
|
193
191
|
argv[ i++ ] = socket_opt;
|
194
192
|
argv[ i++ ] = daemonize_opt;
|
195
|
-
argv[ i++ ] = notify_opt;
|
196
193
|
int j;
|
197
194
|
for ( j = 0; j < listener_info->switch_daemon_argc; i++, j++ ) {
|
198
195
|
argv[ i ] = xstrdup( listener_info->switch_daemon_argv[ j ] );
|
data/src/switch_manager/switch.c
CHANGED
@@ -63,6 +63,9 @@ static const time_t WARNING_ECHO_RTT = 500; // msec. The value must is less than
|
|
63
63
|
|
64
64
|
static bool age_cookie_table_enabled = false;
|
65
65
|
|
66
|
+
#define SWITCH_MANAGER "switch_manager"
|
67
|
+
|
68
|
+
|
66
69
|
typedef struct {
|
67
70
|
uint64_t datapath_id;
|
68
71
|
uint32_t sec;
|
@@ -364,6 +367,10 @@ echo_request_interval( void *user_data ) {
|
|
364
367
|
}
|
365
368
|
|
366
369
|
|
370
|
+
static void
|
371
|
+
confirm_self_dpid_is_registerd( uint64_t* dpids, size_t n_dpids, void *user_data );
|
372
|
+
|
373
|
+
|
367
374
|
int
|
368
375
|
switch_event_recv_featuresreply( struct switch_info *sw_info, uint64_t *dpid ) {
|
369
376
|
int ret;
|
@@ -407,21 +414,36 @@ switch_event_recv_featuresreply( struct switch_info *sw_info, uint64_t *dpid ) {
|
|
407
414
|
}
|
408
415
|
set_trema_name( new_service_name );
|
409
416
|
|
410
|
-
//
|
411
|
-
service_send_state( sw_info, &sw_info->datapath_id, MESSENGER_OPENFLOW_READY );
|
412
|
-
debug( "send ready state" );
|
413
|
-
|
417
|
+
// reset to default config
|
414
418
|
ret = ofpmsg_send_setconfig( sw_info );
|
415
419
|
if ( ret < 0 ) {
|
420
|
+
error( "Failed to send setconfig." );
|
416
421
|
return ret;
|
417
422
|
}
|
418
423
|
if ( switch_info.flow_cleanup ) {
|
424
|
+
debug( "Deleting all flows." );
|
419
425
|
ret = ofpmsg_send_delete_all_flows( sw_info );
|
420
426
|
if ( ret < 0 ) {
|
427
|
+
error( "Failed to send delete all flows." );
|
421
428
|
return ret;
|
422
429
|
}
|
423
430
|
}
|
424
|
-
|
431
|
+
|
432
|
+
// switch_ready to switch_manager
|
433
|
+
debug( "Notify switch_ready to switch manager." );
|
434
|
+
char switch_manager[] = SWITCH_MANAGER;
|
435
|
+
list_element switch_manager_only_list;
|
436
|
+
switch_manager_only_list.next = NULL;
|
437
|
+
switch_manager_only_list.data = switch_manager;
|
438
|
+
service_send_to_application( &switch_manager_only_list, MESSENGER_OPENFLOW_READY, &sw_info->datapath_id, NULL );
|
439
|
+
|
440
|
+
init_event_forward_interface();
|
441
|
+
// Check switch_manager registration
|
442
|
+
debug( "Checking switch manager's switch list." );
|
443
|
+
if ( !send_efi_switch_list_request( confirm_self_dpid_is_registerd, sw_info ) ) {
|
444
|
+
error( "Failed to send switch list request to switch manager." );
|
445
|
+
return -1;
|
446
|
+
}
|
425
447
|
break;
|
426
448
|
|
427
449
|
case SWITCH_STATE_COMPLETED:
|
@@ -439,6 +461,40 @@ switch_event_recv_featuresreply( struct switch_info *sw_info, uint64_t *dpid ) {
|
|
439
461
|
}
|
440
462
|
|
441
463
|
|
464
|
+
static void
|
465
|
+
notify_state_to_controllers( struct switch_info *sw_info );
|
466
|
+
|
467
|
+
|
468
|
+
static void
|
469
|
+
confirm_self_dpid_is_registerd( uint64_t* dpids, size_t n_dpids, void *user_data ) {
|
470
|
+
struct switch_info *sw_info = user_data;
|
471
|
+
|
472
|
+
debug( "Received switch manager's switch list." );
|
473
|
+
for ( size_t i = 0 ; i < n_dpids ; ++i ) {
|
474
|
+
if ( sw_info->datapath_id == dpids[ i ] ) {
|
475
|
+
// self dpid registered
|
476
|
+
debug( "Self dpid found" );
|
477
|
+
return notify_state_to_controllers( sw_info );
|
478
|
+
}
|
479
|
+
}
|
480
|
+
|
481
|
+
debug( "Self dpid not found. Retrying..." );
|
482
|
+
if ( !send_efi_switch_list_request( confirm_self_dpid_is_registerd, sw_info ) ){
|
483
|
+
error( "Failed to send switch list request to switch manager on retry." );
|
484
|
+
}
|
485
|
+
}
|
486
|
+
|
487
|
+
|
488
|
+
static void
|
489
|
+
notify_state_to_controllers( struct switch_info *sw_info ) {
|
490
|
+
// notify state and datapath_id to controllers
|
491
|
+
service_send_state( sw_info, &sw_info->datapath_id, MESSENGER_OPENFLOW_READY );
|
492
|
+
debug( "send ready state" );
|
493
|
+
|
494
|
+
add_periodic_event_callback( ECHO_REQUEST_INTERVAL, echo_request_interval, sw_info );
|
495
|
+
}
|
496
|
+
|
497
|
+
|
442
498
|
int
|
443
499
|
switch_event_disconnected( struct switch_info *sw_info ) {
|
444
500
|
int old_state = sw_info->state;
|
@@ -701,19 +757,19 @@ main( int argc, char *argv[] ) {
|
|
701
757
|
for ( i = optind; i < argc; i++ ) {
|
702
758
|
if ( strncmp( argv[ i ], VENDOR_PREFIX, strlen( VENDOR_PREFIX ) ) == 0 ) {
|
703
759
|
service_name = xstrdup( argv[ i ] + strlen( VENDOR_PREFIX ) );
|
704
|
-
|
760
|
+
append_to_tail( &switch_info.vendor_service_name_list, service_name );
|
705
761
|
}
|
706
762
|
else if ( strncmp( argv[ i ], PACKET_IN_PREFIX, strlen( PACKET_IN_PREFIX ) ) == 0 ) {
|
707
763
|
service_name = xstrdup( argv[ i ] + strlen( PACKET_IN_PREFIX ) );
|
708
|
-
|
764
|
+
append_to_tail( &switch_info.packetin_service_name_list, service_name );
|
709
765
|
}
|
710
766
|
else if ( strncmp( argv[ i ], PORTSTATUS_PREFIX, strlen( PORTSTATUS_PREFIX ) ) == 0 ) {
|
711
767
|
service_name = xstrdup( argv[ i ] + strlen( PORTSTATUS_PREFIX ) );
|
712
|
-
|
768
|
+
append_to_tail( &switch_info.portstatus_service_name_list, service_name );
|
713
769
|
}
|
714
770
|
else if ( strncmp( argv[ i ], STATE_PREFIX, strlen( STATE_PREFIX ) ) == 0 ) {
|
715
771
|
service_name = xstrdup( argv[ i ] + strlen( STATE_PREFIX ) );
|
716
|
-
|
772
|
+
append_to_tail( &switch_info.state_service_name_list, service_name );
|
717
773
|
}
|
718
774
|
}
|
719
775
|
|
@@ -760,6 +816,9 @@ main( int argc, char *argv[] ) {
|
|
760
816
|
|
761
817
|
start_trema();
|
762
818
|
|
819
|
+
// Note: init_event_forward_interface will be called on feature_reply.
|
820
|
+
finalize_event_forward_interface();
|
821
|
+
|
763
822
|
finalize_xid_table();
|
764
823
|
if ( switch_info.cookie_translation ) {
|
765
824
|
finalize_cookie_table();
|
data/trema.gemspec
CHANGED
@@ -27,10 +27,10 @@ Gem::Specification.new do | gem |
|
|
27
27
|
gem.test_files = `git ls-files -- {spec,features}/*`.split( "\n" )
|
28
28
|
|
29
29
|
gem.add_dependency "bundler"
|
30
|
-
gem.add_dependency "gli", "~> 2.
|
31
|
-
gem.add_dependency "paper-house", "~> 0.1.
|
32
|
-
gem.add_dependency "rake", "~> 10.0
|
33
|
-
gem.add_dependency "rdoc", "~> 4.0.
|
30
|
+
gem.add_dependency "gli", "~> 2.6.1"
|
31
|
+
gem.add_dependency "paper-house", "~> 0.1.14"
|
32
|
+
gem.add_dependency "rake", "~> 10.1.0"
|
33
|
+
gem.add_dependency "rdoc", "~> 4.0.1"
|
34
34
|
end
|
35
35
|
|
36
36
|
|
@@ -1483,6 +1483,34 @@ test__dispatch_to_all_switch_succeeds() {
|
|
1483
1483
|
}
|
1484
1484
|
|
1485
1485
|
|
1486
|
+
static void
|
1487
|
+
test__dispatch_to_all_switch_with_no_switch_succeeds() {
|
1488
|
+
init_timer();
|
1489
|
+
uint64_t dpids[] = { 0x12345678 };
|
1490
|
+
const size_t n_dpids = 0;
|
1491
|
+
|
1492
|
+
void *user_data = ( void * ) 0xABCDEF;
|
1493
|
+
|
1494
|
+
struct event_forward_operation_to_all_request_param *param = xcalloc( 1, sizeof( struct event_forward_operation_to_all_request_param ) );
|
1495
|
+
param->add = true;
|
1496
|
+
param->type = EVENT_FORWARD_TYPE_PACKET_IN;
|
1497
|
+
param->service_name = xstrdup( "alpha" );
|
1498
|
+
param->callback = mock_event_forward_entry_to_all_callback;
|
1499
|
+
param->user_data = user_data;
|
1500
|
+
|
1501
|
+
expect_value( mock_event_forward_entry_to_all_callback, result, EFI_OPERATION_SUCCEEDED );
|
1502
|
+
expect_value( mock_event_forward_entry_to_all_callback, user_data, user_data );
|
1503
|
+
|
1504
|
+
_dispatch_to_all_switch( dpids, n_dpids, param );
|
1505
|
+
|
1506
|
+
// free all_sw_tx, param
|
1507
|
+
_cleanup_tx_table();
|
1508
|
+
|
1509
|
+
finalize_timer();
|
1510
|
+
}
|
1511
|
+
|
1512
|
+
|
1513
|
+
|
1486
1514
|
static void
|
1487
1515
|
test__switch_response_handler_succeeds_when_last_one_standing() {
|
1488
1516
|
|
@@ -1628,6 +1656,8 @@ main() {
|
|
1628
1656
|
setup_init_efi, teardown_finl_efi ),
|
1629
1657
|
unit_test_setup_teardown( test__dispatch_to_all_switch_succeeds,
|
1630
1658
|
setup_init_efi, teardown_finl_efi ),
|
1659
|
+
unit_test_setup_teardown( test__dispatch_to_all_switch_with_no_switch_succeeds,
|
1660
|
+
setup_init_efi, teardown_finl_efi ),
|
1631
1661
|
unit_test_setup_teardown( test__switch_response_handler_succeeds_when_last_one_standing,
|
1632
1662
|
setup_init_efi, teardown_finl_efi ),
|
1633
1663
|
unit_test_setup_teardown( test__switch_response_timeout_then_fails,
|
@@ -4554,6 +4554,24 @@ test_validate_action_vendor_fails_with_too_short_ofp_action_vendor_header() {
|
|
4554
4554
|
}
|
4555
4555
|
|
4556
4556
|
|
4557
|
+
static void
|
4558
|
+
test_validate_action_vendor_fails_with_invalid_length_ofp_action_vendor_header() {
|
4559
|
+
buffer *body = create_dummy_data( LONG_DATA_LENGTH );
|
4560
|
+
openflow_actions *actions = create_actions();
|
4561
|
+
append_action_vendor( actions, VENDOR_ID, body );
|
4562
|
+
struct ofp_action_vendor_header *invalid_length_action_vendor_header = xmalloc( sizeof( struct ofp_action_vendor_header ) + body->length );
|
4563
|
+
hton_action_vendor( invalid_length_action_vendor_header, ( struct ofp_action_vendor_header * ) ( actions->list->data ) );
|
4564
|
+
uint16_t invalid_length_action_vendor = ( uint16_t ) ( LONG_DATA_LENGTH - 1 );
|
4565
|
+
invalid_length_action_vendor_header->len = htons( invalid_length_action_vendor );
|
4566
|
+
|
4567
|
+
assert_int_equal( validate_action_vendor( invalid_length_action_vendor_header ), ERROR_INVALID_LENGTH_ACTION_VENDOR );
|
4568
|
+
|
4569
|
+
free_buffer( body );
|
4570
|
+
delete_actions( actions );
|
4571
|
+
xfree( invalid_length_action_vendor_header );
|
4572
|
+
}
|
4573
|
+
|
4574
|
+
|
4557
4575
|
/********************************************************************************
|
4558
4576
|
* validate_openflow_message() tests.
|
4559
4577
|
********************************************************************************/
|
@@ -7890,6 +7908,7 @@ main() {
|
|
7890
7908
|
unit_test_setup_teardown( test_validate_action_vendor, init, teardown ),
|
7891
7909
|
unit_test_setup_teardown( test_validate_action_vendor_fails_with_invalid_action_type, init, teardown ),
|
7892
7910
|
unit_test_setup_teardown( test_validate_action_vendor_fails_with_too_short_ofp_action_vendor_header, init, teardown ),
|
7911
|
+
unit_test_setup_teardown( test_validate_action_vendor_fails_with_invalid_length_ofp_action_vendor_header, init, teardown ),
|
7893
7912
|
|
7894
7913
|
unit_test_setup_teardown( test_validate_openflow_message_succeeds_with_valid_OFPT_HELLO_message, init, teardown ),
|
7895
7914
|
unit_test_setup_teardown( test_validate_openflow_message_succeeds_with_valid_OFPT_ERROR_message, init, teardown ),
|
@@ -261,6 +261,21 @@ test_packet_type_arp() {
|
|
261
261
|
}
|
262
262
|
|
263
263
|
|
264
|
+
static void
|
265
|
+
test_packet_type_rarp() {
|
266
|
+
buffer *buf = alloc_buffer_with_length( sizeof( struct iphdr ) );
|
267
|
+
calloc_packet_info( buf );
|
268
|
+
|
269
|
+
assert_false( packet_type_rarp( buf ) );
|
270
|
+
|
271
|
+
packet_info *packet_info = buf->user_data;
|
272
|
+
packet_info->format |= NW_RARP;
|
273
|
+
assert_true( packet_type_rarp( buf ) );
|
274
|
+
|
275
|
+
free_buffer( buf );
|
276
|
+
}
|
277
|
+
|
278
|
+
|
264
279
|
static void
|
265
280
|
test_packet_type_ipv4() {
|
266
281
|
buffer *buf = alloc_buffer_with_length( sizeof( struct iphdr ) );
|
@@ -513,6 +528,7 @@ main() {
|
|
513
528
|
unit_test( test_packet_type_ether ),
|
514
529
|
|
515
530
|
unit_test( test_packet_type_arp ),
|
531
|
+
unit_test( test_packet_type_rarp ),
|
516
532
|
unit_test( test_packet_type_ipv4 ),
|
517
533
|
unit_test( test_packet_type_icmpv4 ),
|
518
534
|
|
@@ -147,6 +147,42 @@ test_parse_packet_arp_request_succeeds() {
|
|
147
147
|
}
|
148
148
|
|
149
149
|
|
150
|
+
static void
|
151
|
+
test_parse_packet_rarp_request_succeeds() {
|
152
|
+
const char filename[] = "./unittests/lib/test_packets/rarp_req.cap";
|
153
|
+
buffer *buffer = store_packet_to_buffer( filename );
|
154
|
+
|
155
|
+
assert_true( parse_packet( buffer ) );
|
156
|
+
packet_info *packet_info = buffer->user_data;
|
157
|
+
|
158
|
+
assert_int_equal( packet_info->format, ETH_RARP );
|
159
|
+
|
160
|
+
u_char macda[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
|
161
|
+
u_char macsa[] = { 0x0a, 0x1d, 0x79, 0x67, 0x55, 0xad };
|
162
|
+
assert_memory_equal( packet_info->eth_macda, macda, ETH_ADDRLEN );
|
163
|
+
assert_memory_equal( packet_info->eth_macsa, macsa, ETH_ADDRLEN );
|
164
|
+
assert_int_equal( packet_info->eth_type, ETH_ETHTYPE_RARP );
|
165
|
+
|
166
|
+
assert_int_equal( packet_info->l2_payload_length, 28 );
|
167
|
+
|
168
|
+
assert_int_equal( packet_info->arp_ar_hrd, 0x0001 );
|
169
|
+
assert_int_equal( packet_info->arp_ar_pro, 0x0800 );
|
170
|
+
assert_int_equal( packet_info->arp_ar_hln, 6 );
|
171
|
+
assert_int_equal( packet_info->arp_ar_pln, 4 );
|
172
|
+
assert_int_equal( packet_info->arp_ar_op, 3 );
|
173
|
+
assert_int_equal( packet_info->arp_spa, 0xc0a80003 );
|
174
|
+
assert_memory_equal( packet_info->arp_sha, macsa, ETH_ADDRLEN );
|
175
|
+
assert_int_equal( packet_info->arp_tpa, 0 );
|
176
|
+
u_char whois[] = { 0x22, 0x4f, 0x0d, 0x93, 0xae, 0xf0 };
|
177
|
+
assert_memory_equal( packet_info->arp_tha, whois, ETH_ADDRLEN );
|
178
|
+
|
179
|
+
assert_true( packet_type_rarp_request( buffer ) );
|
180
|
+
assert_false( packet_type_rarp_reply( buffer ) );
|
181
|
+
|
182
|
+
free_buffer( buffer );
|
183
|
+
}
|
184
|
+
|
185
|
+
|
150
186
|
static void
|
151
187
|
test_parse_packet_ipv6_succeeds() {
|
152
188
|
const char filename[] = "./unittests/lib/test_packets/icmp6_echo_req.cap";
|
@@ -713,6 +749,7 @@ main() {
|
|
713
749
|
unit_test( test_parse_packet_snap_succeeds ),
|
714
750
|
|
715
751
|
unit_test( test_parse_packet_arp_request_succeeds ),
|
752
|
+
unit_test( test_parse_packet_rarp_request_succeeds ),
|
716
753
|
|
717
754
|
unit_test( test_parse_packet_ipv6_succeeds ),
|
718
755
|
|
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trema
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yasuhito Takamiya
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: .
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-06-27 00:00:00 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 2.
|
32
|
+
version: 2.6.1
|
33
33
|
prerelease: false
|
34
34
|
version_requirements: *id002
|
35
35
|
- !ruby/object:Gem::Dependency
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
requirements:
|
40
40
|
- - ~>
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: 0.1.
|
42
|
+
version: 0.1.14
|
43
43
|
prerelease: false
|
44
44
|
version_requirements: *id003
|
45
45
|
- !ruby/object:Gem::Dependency
|
@@ -49,7 +49,7 @@ dependencies:
|
|
49
49
|
requirements:
|
50
50
|
- - ~>
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version: 10.0
|
52
|
+
version: 10.1.0
|
53
53
|
prerelease: false
|
54
54
|
version_requirements: *id004
|
55
55
|
- !ruby/object:Gem::Dependency
|
@@ -59,7 +59,7 @@ dependencies:
|
|
59
59
|
requirements:
|
60
60
|
- - ~>
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version: 4.0.
|
62
|
+
version: 4.0.1
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: *id005
|
65
65
|
description: Trema is a full-stack, easy-to-use framework for developing OpenFlow controllers in Ruby and C.
|
@@ -234,6 +234,7 @@ files:
|
|
234
234
|
- ruby/trema/monkey-patch/integer.rb
|
235
235
|
- ruby/trema/monkey-patch/integer/base-conversions.rb
|
236
236
|
- ruby/trema/monkey-patch/integer/ranges.rb
|
237
|
+
- ruby/trema/monkey-patch/integer/validators.rb
|
237
238
|
- ruby/trema/monkey-patch/module.rb
|
238
239
|
- ruby/trema/monkey-patch/module/class-method.rb
|
239
240
|
- ruby/trema/monkey-patch/module/deprecation.rb
|
@@ -472,6 +473,7 @@ files:
|
|
472
473
|
- src/examples/switch_event_config/add_forward_entry.c
|
473
474
|
- src/examples/switch_event_config/delete_forward_entry.c
|
474
475
|
- src/examples/switch_event_config/dump_forward_entries.c
|
476
|
+
- src/examples/switch_event_config/network.conf
|
475
477
|
- src/examples/switch_event_config/set_forward_entries.c
|
476
478
|
- src/examples/switch_info/README
|
477
479
|
- src/examples/switch_info/switch-info.rb
|
@@ -656,6 +658,7 @@ files:
|
|
656
658
|
- unittests/lib/test_packets/ipx.cap
|
657
659
|
- unittests/lib/test_packets/lldp.cap
|
658
660
|
- unittests/lib/test_packets/lldp_over_ip.cap
|
661
|
+
- unittests/lib/test_packets/rarp_req.cap
|
659
662
|
- unittests/lib/test_packets/tcp.cap
|
660
663
|
- unittests/lib/test_packets/tcp_syn.cap
|
661
664
|
- unittests/lib/test_packets/udp.cap
|