trema 0.3.4 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -70,6 +70,7 @@ barrier_reply_transaction_id( VALUE self ) {
70
70
 
71
71
  void
72
72
  Init_barrier_reply() {
73
+ mTrema = rb_define_module( "Trema" );
73
74
  cBarrierReply = rb_define_class_under( mTrema, "BarrierReply", rb_cObject );
74
75
  rb_define_method( cBarrierReply, "initialize", barrier_reply_init, 2 );
75
76
  rb_define_method( cBarrierReply, "datapath_id", barrier_reply_datapath_id, 0 );
@@ -118,6 +118,7 @@ barrier_request_transaction_id( VALUE self ) {
118
118
 
119
119
  void
120
120
  Init_barrier_request() {
121
+ mTrema = rb_define_module( "Trema" );
121
122
  cBarrierRequest = rb_define_class_under( mTrema, "BarrierRequest", rb_cObject );
122
123
  rb_define_alloc_func( cBarrierRequest, barrier_request_alloc );
123
124
  rb_define_method( cBarrierRequest, "initialize", barrier_request_init, -1 );
@@ -641,6 +641,7 @@ Init_controller() {
641
641
  rb_require( "trema/app" );
642
642
 
643
643
  VALUE cApp = rb_eval_string( "Trema::App" );
644
+ mTrema = rb_define_module( "Trema" );
644
645
  cController = rb_define_class_under( mTrema, "Controller", cApp );
645
646
 
646
647
  rb_define_const( cController, "OFPP_MAX", INT2NUM( OFPP_MAX ) );
@@ -104,6 +104,7 @@ echo_user_data( VALUE self ) {}
104
104
 
105
105
  void
106
106
  Init_echo_reply() {
107
+ mTrema = rb_define_module( "Trema" );
107
108
  cEchoReply = rb_define_class_under( mTrema, "EchoReply", rb_cObject );
108
109
  rb_define_alloc_func( cEchoReply, echo_reply_alloc );
109
110
  rb_define_method( cEchoReply, "initialize", echo_init, -1 );
@@ -99,6 +99,7 @@ echo_user_data( VALUE self ) {}
99
99
 
100
100
  void
101
101
  Init_echo_request() {
102
+ mTrema = rb_define_module( "Trema" );
102
103
  cEchoRequest = rb_define_class_under( mTrema, "EchoRequest", rb_cObject );
103
104
  rb_define_alloc_func( cEchoRequest, echo_request_alloc );
104
105
  rb_define_method( cEchoRequest, "initialize", echo_init, -1 );
@@ -195,6 +195,7 @@ error_code( VALUE self ) {
195
195
 
196
196
  void
197
197
  Init_error() {
198
+ mTrema = rb_define_module( "Trema" );
198
199
  rb_define_const( mTrema, "OFPET_HELLO_FAILED", INT2NUM( OFPET_HELLO_FAILED ) );
199
200
  rb_define_const( mTrema, "OFPHFC_INCOMPATIBLE", INT2NUM( OFPHFC_INCOMPATIBLE ) );
200
201
  rb_define_const( mTrema, "OFPHFC_EPERM", INT2NUM( OFPHFC_EPERM ) );
@@ -215,6 +215,7 @@ features_reply_ports( VALUE self ) {
215
215
 
216
216
  void
217
217
  Init_features_reply() {
218
+ mTrema = rb_define_module( "Trema" );
218
219
  cFeaturesReply = rb_define_class_under( mTrema, "FeaturesReply", rb_cObject );
219
220
  rb_define_alloc_func( cFeaturesReply, features_reply_alloc );
220
221
  rb_define_method( cFeaturesReply, "initialize", features_reply_init, 1 );
@@ -117,6 +117,7 @@ features_request_transaction_id( VALUE self ) {
117
117
 
118
118
  void
119
119
  Init_features_request() {
120
+ mTrema = rb_define_module( "Trema" );
120
121
  cFeaturesRequest = rb_define_class_under( mTrema, "FeaturesRequest", rb_cObject );
121
122
  rb_define_alloc_func( cFeaturesRequest, features_request_alloc );
122
123
  rb_define_method( cFeaturesRequest, "initialize", features_request_init, -1 );
@@ -130,6 +130,7 @@ flow_mod_hard_timeout( VALUE self ) {
130
130
 
131
131
  void
132
132
  Init_flow_mod() {
133
+ mTrema = rb_define_module( "Trema" );
133
134
  cFlowMod = rb_define_class_under( mTrema, "FlowMod", rb_cObject );
134
135
  rb_define_alloc_func( cFlowMod, flow_mod_alloc );
135
136
  rb_define_method( cFlowMod, "initialize", flow_mod_init, -1 );
@@ -222,6 +222,7 @@ flow_removed_byte_count( VALUE self ) {
222
222
 
223
223
  void
224
224
  Init_flow_removed() {
225
+ mTrema = rb_define_module( "Trema" );
225
226
  cFlowRemoved = rb_define_class_under( mTrema, "FlowRemoved", rb_cObject );
226
227
  rb_define_const( cFlowRemoved, "OFPRR_IDLE_TIMEOUT", INT2NUM( OFPRR_IDLE_TIMEOUT ) );
227
228
  rb_define_const( cFlowRemoved, "OFPRR_HARD_TIMEOUT", INT2NUM( OFPRR_HARD_TIMEOUT ) );
@@ -113,6 +113,7 @@ get_config_reply_miss_send_len( VALUE self ) {
113
113
 
114
114
  void
115
115
  Init_get_config_reply() {
116
+ mTrema = rb_define_module( "Trema" );
116
117
  cGetConfigReply = rb_define_class_under( mTrema, "GetConfigReply", rb_cObject );
117
118
  rb_define_method( cGetConfigReply, "initialize", get_config_reply_init, 1 );
118
119
  rb_define_method( cGetConfigReply, "datapath_id", get_config_reply_datapath_id, 0 );
@@ -119,6 +119,7 @@ get_config_request_transaction_id( VALUE self ) {
119
119
 
120
120
  void
121
121
  Init_get_config_request() {
122
+ mTrema = rb_define_module( "Trema" );
122
123
  cGetConfigRequest = rb_define_class_under( mTrema, "GetConfigRequest", rb_cObject );
123
124
  rb_define_alloc_func( cGetConfigRequest, get_config_request_alloc );
124
125
  rb_define_method( cGetConfigRequest, "initialize", get_config_request_init, -1 );
@@ -116,6 +116,7 @@ hello_transaction_id( VALUE self ) {
116
116
 
117
117
  void
118
118
  Init_hello() {
119
+ mTrema = rb_define_module( "Trema" );
119
120
  cHello = rb_define_class_under( mTrema, "Hello", rb_cObject );
120
121
  rb_define_alloc_func( cHello, hello_alloc );
121
122
  rb_define_method( cHello, "initialize", hello_init, -1 );
@@ -143,6 +143,7 @@ logger_debug( int argc, VALUE *argv, VALUE self ) {
143
143
 
144
144
  void
145
145
  Init_logger() {
146
+ mTrema = rb_define_module( "Trema" );
146
147
  mLogger = rb_define_module_under( mTrema, "Logger" );
147
148
 
148
149
  rb_define_method( mLogger, "critical", logger_critical, -1 );
@@ -562,6 +562,7 @@ match_init( int argc, VALUE *argv, VALUE self ) {
562
562
 
563
563
  void
564
564
  Init_match() {
565
+ mTrema = rb_define_module( "Trema" );
565
566
  cMatch = rb_define_class_under( mTrema, "Match", rb_cObject );
566
567
  rb_define_alloc_func( cMatch, match_alloc );
567
568
  rb_define_const( cMatch, "OFPFW_IN_PORT", INT2NUM( OFPFW_IN_PORT ) );
@@ -127,6 +127,7 @@ openflow_error_data( VALUE self ) {
127
127
 
128
128
  void
129
129
  Init_openflow_error() {
130
+ mTrema = rb_define_module( "Trema" );
130
131
  cOpenflowError = rb_define_class_under( mTrema, "OpenflowError", rb_cObject );
131
132
  rb_define_method( cOpenflowError, "initialize", openflow_error_init, 1 );
132
133
  rb_define_method( cOpenflowError, "datapath_id", openflow_error_datapath_id, 0 );
@@ -1080,6 +1080,7 @@ void
1080
1080
  Init_packet_in() {
1081
1081
  rb_require( "trema/ip" );
1082
1082
  rb_require( "trema/mac" );
1083
+ mTrema = rb_define_module( "Trema" );
1083
1084
  cPacketIn = rb_define_class_under( mTrema, "PacketIn", rb_cObject );
1084
1085
  rb_define_alloc_func( cPacketIn, packet_in_alloc );
1085
1086
 
@@ -205,6 +205,7 @@ port_mod_advertise( VALUE self ) {
205
205
 
206
206
  void
207
207
  Init_port_mod() {
208
+ mTrema = rb_define_module( "Trema" );
208
209
  cPortMod = rb_define_class_under( mTrema, "PortMod", rb_cObject );
209
210
  rb_define_alloc_func( cPortMod, port_mod_alloc );
210
211
  rb_define_method( cPortMod, "initialize", port_mod_init, -1 );
@@ -122,6 +122,7 @@ port_status_phy_port( VALUE self ) {
122
122
 
123
123
  void
124
124
  Init_port_status() {
125
+ mTrema = rb_define_module( "Trema" );
125
126
  cPortStatus = rb_define_class_under( mTrema, "PortStatus", rb_cObject );
126
127
 
127
128
  rb_define_const( cPortStatus, "OFPPR_ADD", INT2NUM( OFPPR_ADD ) );
@@ -300,6 +300,7 @@ port_compare( VALUE self, VALUE other ) {
300
300
 
301
301
  void
302
302
  Init_port() {
303
+ mTrema = rb_define_module( "Trema" );
303
304
  cPort = rb_define_class_under( mTrema, "Port", rb_cObject );
304
305
 
305
306
  rb_define_const( cPort, "OFPPC_PORT_DOWN", INT2NUM( OFPPC_PORT_DOWN ) );
@@ -112,6 +112,7 @@ queue_get_config_reply_queues( VALUE self ) {
112
112
  void
113
113
  Init_queue_get_config_reply() {
114
114
  rb_require( "trema/packet-queue" );
115
+ mTrema = rb_define_module( "Trema" );
115
116
  cQueueGetConfigReply = rb_define_class_under( mTrema, "QueueGetConfigReply", rb_cObject );
116
117
  rb_define_method( cQueueGetConfigReply, "initialize", queue_get_config_reply_init, 1 );
117
118
  rb_define_method( cQueueGetConfigReply, "datapath_id", queue_get_config_reply_datapath_id, 0 );
@@ -125,6 +125,7 @@ queue_get_config_request_port( VALUE self ) {
125
125
 
126
126
  void
127
127
  Init_queue_get_config_request() {
128
+ mTrema = rb_define_module( "Trema" );
128
129
  cQueueGetConfigRequest = rb_define_class_under( mTrema, "QueueGetConfigRequest", rb_cObject );
129
130
  rb_define_alloc_func( cQueueGetConfigRequest, queue_get_config_request_alloc );
130
131
  rb_define_method( cQueueGetConfigRequest, "initialize", queue_get_config_request_init, -1 );
@@ -75,7 +75,7 @@ module Trema
75
75
 
76
76
 
77
77
  def to_s
78
- "SendOutPort: port_number=#{ @port_number }, max_len=#{ @max_len }"
78
+ "#{ self.class.to_s }: port_number=#{ @port_number }, max_len=#{ @max_len }"
79
79
  end
80
80
 
81
81
 
@@ -147,6 +147,7 @@ set_config_miss_send_len( VALUE self ) {
147
147
 
148
148
  void
149
149
  Init_set_config() {
150
+ mTrema = rb_define_module( "Trema" );
150
151
  cSetConfig = rb_define_class_under( mTrema, "SetConfig", rb_cObject );
151
152
  rb_define_alloc_func( cSetConfig, set_config_alloc );
152
153
  rb_define_const( cSetConfig, "OFPC_FRAG_NORMAL", INT2NUM( OFPC_FRAG_NORMAL ) );
@@ -38,6 +38,11 @@ module Trema
38
38
  def initialize mac_address
39
39
  @mac_address = Mac.new( mac_address )
40
40
  end
41
+
42
+
43
+ def to_s
44
+ "#{ self.class.to_s }: mac_address=#{ @mac_address }"
45
+ end
41
46
  end
42
47
  end
43
48
 
@@ -27,6 +27,8 @@ module Trema
27
27
  #
28
28
  # Creates an action to modify the destination Ethernet address of a packet.
29
29
  #
30
+ # @overload initialize(mac_address)
31
+ #
30
32
  # @example
31
33
  # SetEthDstAddr.new("11:22:33:44:55:66")
32
34
  # SetEthDstAddr.new(0x112233445566)
@@ -38,14 +40,6 @@ module Trema
38
40
  # @raise [ArgumentError] if invalid format is detected.
39
41
  # @raise [TypeError] if supplied argument is not a String or Integer or Mac.
40
42
  #
41
- def initialize mac_address
42
- super mac_address
43
- end
44
-
45
-
46
- def to_s
47
- "SetEthDstAddr: mac_address=#{ @mac_address }"
48
- end
49
43
  end
50
44
 
51
45
 
@@ -27,6 +27,8 @@ module Trema
27
27
  #
28
28
  # Creates an action to modify the source Ethernet address of a packet.
29
29
  #
30
+ # @overload initialize(mac_address)
31
+ #
30
32
  # @example
31
33
  # SetEthSrcAddr.new("11:22:33:44:55:66")
32
34
  # SetEthSrcAddr.new(0x112233445566)
@@ -38,14 +40,6 @@ module Trema
38
40
  # @raise [ArgumentError] if invalid format is detected.
39
41
  # @raise [TypeError] if supplied argument is not a String or Integer or Mac.
40
42
  #
41
- def initialize mac_address
42
- super mac_address
43
- end
44
-
45
-
46
- def to_s
47
- "SetEthSrcAddr: mac_address=#{ @mac_address }"
48
- end
49
43
  end
50
44
 
51
45
 
@@ -148,6 +148,7 @@ Init_stats_reply() {
148
148
  rb_require( "trema/port-stats-reply" );
149
149
  rb_require( "trema/queue-stats-reply" );
150
150
  rb_require( "trema/vendor-stats-reply" );
151
+ mTrema = rb_define_module( "Trema" );
151
152
  cStatsReply = rb_define_class_under( mTrema, "StatsReply", rb_cObject );
152
153
  rb_define_const( cStatsReply, "OFPST_DESC", INT2NUM( OFPST_DESC ) );
153
154
  rb_define_const( cStatsReply, "OFPST_FLOW", INT2NUM( OFPST_FLOW ) );
@@ -618,6 +618,7 @@ vendor_stats_request_init( int argc, VALUE *argv, VALUE self ) {
618
618
 
619
619
  void
620
620
  Init_stats_request() {
621
+ mTrema = rb_define_module( "Trema" );
621
622
  cStatsRequest = rb_define_class_under( mTrema, "StatsRequest", rb_cObject );
622
623
 
623
624
  cDescStatsRequest = rb_define_class_under( mTrema, "DescStatsRequest", cStatsRequest );
@@ -178,6 +178,7 @@ switch_start_chibach( VALUE self ) {
178
178
 
179
179
  void
180
180
  Init_switch() {
181
+ mTrema = rb_define_module( "Trema" );
181
182
  cSwitch = rb_define_class_under( mTrema, "Switch", rb_cObject );
182
183
  rb_include_module( cSwitch, mLogger );
183
184
 
@@ -177,6 +177,7 @@ vendor_data( VALUE self ) {
177
177
 
178
178
  void
179
179
  Init_vendor() {
180
+ mTrema = rb_define_module( "Trema" );
180
181
  cVendor = rb_define_class_under( mTrema, "Vendor", rb_cObject );
181
182
  rb_define_alloc_func( cVendor, vendor_alloc );
182
183
  rb_define_method( cVendor, "initialize", vendor_init, -1 );
@@ -17,7 +17,7 @@
17
17
 
18
18
 
19
19
  module Trema
20
- VERSION = "0.3.4"
20
+ VERSION = "0.3.5"
21
21
  end
22
22
 
23
23
 
@@ -30,7 +30,7 @@ describe SendOutPort, :type => "actions" do
30
30
 
31
31
  its( :port_number ) { should eq( 1 ) }
32
32
  its( :max_len ) { should eq( 2 ** 16 - 1 ) }
33
- its( :to_s ) { should eq( "SendOutPort: port_number=1, max_len=65535" ) }
33
+ its( :to_s ) { should eq( "Trema::SendOutPort: port_number=1, max_len=65535" ) }
34
34
  end
35
35
 
36
36
 
@@ -47,6 +47,12 @@ describe SendOutPort, :type => "actions" do
47
47
  sleep 2
48
48
  expect( vswitch( "0xabc" ) ).to have( 1 ).flows
49
49
  expect( vswitch( "0xabc" ).flows[ 0 ].actions ).to eq( "output:10" )
50
+ pending( "Test actions as an object using Trema::Switch" ) do
51
+ expect( vswitch( "0xabc" ) ).to have( 1 ).flows
52
+ expect( vswitch( "0xabc" ).flows[ 0 ] ).to have( 1 ).actions
53
+ expect( vswitch( "0xabc" ).flows[ 0 ].actions[ 0 ] ).to be_a( SendOutPort )
54
+ expect( vswitch( "0xabc" ).flows[ 0 ].actions[ 0 ].port_number ).to eq( 10 )
55
+ end
50
56
  }
51
57
  end
52
58
  end
@@ -66,7 +72,7 @@ describe SendOutPort, :type => "actions" do
66
72
 
67
73
  its( :port_number ) { should eq( 1 ) }
68
74
  its( :max_len ) { should eq( 2 ** 16 - 1 ) }
69
- its( :to_s ) { should eq( "SendOutPort: port_number=1, max_len=65535" ) }
75
+ its( :to_s ) { should eq( "Trema::SendOutPort: port_number=1, max_len=65535" ) }
70
76
  end
71
77
  end
72
78
 
@@ -80,7 +86,7 @@ describe SendOutPort, :type => "actions" do
80
86
 
81
87
  its( :port_number ) { should eq( 1 ) }
82
88
  its( :max_len ) { should eq( 256 ) }
83
- its( :to_s ) { should eq( "SendOutPort: port_number=1, max_len=256" ) }
89
+ its( :to_s ) { should eq( "Trema::SendOutPort: port_number=1, max_len=256" ) }
84
90
  end
85
91
 
86
92
 
@@ -0,0 +1,100 @@
1
+ #
2
+ # Copyright (C) 2008-2012 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
+ require File.join( File.dirname( __FILE__ ), "..", "spec_helper" )
20
+ require "trema"
21
+
22
+
23
+ [ SetEthSrcAddr, SetEthDstAddr ].each do | klass |
24
+ describe klass, "#new(mac_address)", :type => "actions" do
25
+ subject { klass.new( mac_address ) }
26
+
27
+
28
+ context "with mac_address (52:54:00:a8:ad:8c)" do
29
+ let( :mac_address ) { "52:54:00:a8:ad:8c" }
30
+
31
+ its( "mac_address.to_s" ) { should eq( "52:54:00:a8:ad:8c" ) }
32
+ its( :to_s ) { should eq( "#{ klass.to_s }: mac_address=52:54:00:a8:ad:8c" ) }
33
+ end
34
+
35
+
36
+ context "with mac_address (11:22:33:44:55:66)" do
37
+ let( :mac_address ) { "11:22:33:44:55:66" }
38
+
39
+ context "when set as FlowMod's action", :sudo => true do
40
+ it "should insert a new flow with action (mod_dl_{src,dst}:11:22:33:44:55:66)" do
41
+ class TestController < Controller; end
42
+ network {
43
+ vswitch { datapath_id 0xabc }
44
+ }.run( TestController ) {
45
+ controller( "TestController" ).send_flow_mod_add( 0xabc, :actions => subject )
46
+ sleep 2
47
+ expect( vswitch( "0xabc" ) ).to have( 1 ).flows
48
+ expect( vswitch( "0xabc" ).flows[ 0 ].actions ).to match( /mod_dl_(src|dst):11:22:33:44:55:66/ )
49
+ pending( "Test actions as an object using Trema::Switch" ) do
50
+ expect( vswitch( "0xabc" ) ).to have( 1 ).flows
51
+ expect( vswitch( "0xabc" ).flows[ 0 ] ).to have( 1 ).actions
52
+ expect( vswitch( "0xabc" ).flows[ 0 ].actions[ 0 ] ).to be_a( klass )
53
+ expect( vswitch( "0xabc" ).flows[ 0 ].actions[ 0 ].mac_address.to_s ).to eq( "11:22:33:44:55:66" )
54
+ end
55
+ }
56
+ end
57
+ end
58
+ end
59
+
60
+
61
+ context %q{with mac_address (Mac.new("52:54:00:a8:ad:8c"))} do
62
+ let( :mac_address ) { Mac.new("52:54:00:a8:ad:8c") }
63
+
64
+ its( "mac_address.to_s" ) { should eq( "52:54:00:a8:ad:8c" ) }
65
+ its( :to_s ) { should eq( "#{ klass.to_s }: mac_address=52:54:00:a8:ad:8c" ) }
66
+ end
67
+
68
+
69
+ context "with mac_address (0x525400a8ad8c)" do
70
+ let( :mac_address ) { 0x525400a8ad8c }
71
+
72
+ its( "mac_address.to_s" ) { should eq( "52:54:00:a8:ad:8c" ) }
73
+ its( :to_s ) { should eq( "#{ klass.to_s }: mac_address=52:54:00:a8:ad:8c" ) }
74
+ end
75
+
76
+
77
+ context %q{with invalid mac_address ("INVALID MAC STRING")} do
78
+ let( :mac_address ) { "INVALID MAC STRING" }
79
+
80
+ it { expect { subject }.to raise_error( ArgumentError ) }
81
+ end
82
+
83
+
84
+ context "with invalid mac_address ([1, 2, 3])" do
85
+ let( :mac_address ) { [ 1, 2, 3 ] }
86
+
87
+ it { expect { subject }.to raise_error( TypeError ) }
88
+ end
89
+
90
+
91
+ it_validates "option is within range", :mac_address, 0..0xffffffffffff
92
+ end
93
+ end
94
+
95
+
96
+ ### Local variables:
97
+ ### mode: Ruby
98
+ ### coding: utf-8-unix
99
+ ### indent-tabs-mode: nil
100
+ ### End:
@@ -23,6 +23,7 @@ Gem::Specification.new do | s |
23
23
  # s.add_development_dependency "rspec"
24
24
  s.add_runtime_dependency "rake"
25
25
  s.add_runtime_dependency "gli", "~> 2.5.2"
26
+ s.add_runtime_dependency "rdoc", "~> 3.12"
26
27
 
27
28
  s.add_development_dependency "rake"
28
29
  s.add_development_dependency "rdoc"
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trema
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 4
10
- version: 0.3.4
9
+ - 5
10
+ version: 0.3.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Yasuhito Takamiya
@@ -49,8 +49,23 @@ dependencies:
49
49
  type: :runtime
50
50
  - !ruby/object:Gem::Dependency
51
51
  prerelease: false
52
- name: rake
52
+ name: rdoc
53
53
  version_requirements: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ~>
57
+ - !ruby/object:Gem::Version
58
+ hash: 31
59
+ segments:
60
+ - 3
61
+ - 12
62
+ version: "3.12"
63
+ requirement: *id003
64
+ type: :runtime
65
+ - !ruby/object:Gem::Dependency
66
+ prerelease: false
67
+ name: rake
68
+ version_requirements: &id004 !ruby/object:Gem::Requirement
54
69
  none: false
55
70
  requirements:
56
71
  - - ">="
@@ -59,12 +74,12 @@ dependencies:
59
74
  segments:
60
75
  - 0
61
76
  version: "0"
62
- requirement: *id003
77
+ requirement: *id004
63
78
  type: :development
64
79
  - !ruby/object:Gem::Dependency
65
80
  prerelease: false
66
81
  name: rdoc
67
- version_requirements: &id004 !ruby/object:Gem::Requirement
82
+ version_requirements: &id005 !ruby/object:Gem::Requirement
68
83
  none: false
69
84
  requirements:
70
85
  - - ">="
@@ -73,12 +88,12 @@ dependencies:
73
88
  segments:
74
89
  - 0
75
90
  version: "0"
76
- requirement: *id004
91
+ requirement: *id005
77
92
  type: :development
78
93
  - !ruby/object:Gem::Dependency
79
94
  prerelease: false
80
95
  name: aruba
81
- version_requirements: &id005 !ruby/object:Gem::Requirement
96
+ version_requirements: &id006 !ruby/object:Gem::Requirement
82
97
  none: false
83
98
  requirements:
84
99
  - - ">="
@@ -87,7 +102,7 @@ dependencies:
87
102
  segments:
88
103
  - 0
89
104
  version: "0"
90
- requirement: *id005
105
+ requirement: *id006
91
106
  type: :development
92
107
  description: Trema is a full-stack, easy-to-use framework for developing OpenFlow controllers in Ruby and C
93
108
  email:
@@ -380,8 +395,7 @@ files:
380
395
  - spec/trema/queue-get-config-request_spec.rb
381
396
  - spec/trema/send-out-port_spec.rb
382
397
  - spec/trema/set-config_spec.rb
383
- - spec/trema/set-eth-dst-addr_spec.rb
384
- - spec/trema/set-eth-src-addr_spec.rb
398
+ - spec/trema/set-eth-addr_spec.rb
385
399
  - spec/trema/set-ip-dst-addr_spec.rb
386
400
  - spec/trema/set-ip-src-addr_spec.rb
387
401
  - spec/trema/set-ip-tos_spec.rb
@@ -1,78 +0,0 @@
1
- #
2
- # Copyright (C) 2008-2012 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
- require File.join( File.dirname( __FILE__ ), "..", "spec_helper" )
20
- require "trema"
21
-
22
-
23
- describe SetEthDstAddr, ".new( mac_address )", :type => "actions" do
24
- subject { SetEthDstAddr.new( mac_address ) }
25
-
26
- context "with mac_address (52:54:00:a8:ad:8c)" do
27
- let( :mac_address ) { "52:54:00:a8:ad:8c" }
28
- its( "mac_address.to_s" ) { should == "52:54:00:a8:ad:8c" }
29
- its( :to_s ) { should == "SetEthDstAddr: mac_address=52:54:00:a8:ad:8c" }
30
- end
31
-
32
- context %q{with mac_address (Mac.new("52:54:00:a8:ad:8c"))} do
33
- let( :mac_address ) { Mac.new("52:54:00:a8:ad:8c") }
34
- its( "mac_address.to_s" ) { should == "52:54:00:a8:ad:8c" }
35
- its( :to_s ) { should == "SetEthDstAddr: mac_address=52:54:00:a8:ad:8c" }
36
- end
37
-
38
- context "with mac_address (0x525400a8ad8c)" do
39
- let( :mac_address ) { 0x525400a8ad8c }
40
- its( "mac_address.to_s" ) { should == "52:54:00:a8:ad:8c" }
41
- its( :to_s ) { should == "SetEthDstAddr: mac_address=52:54:00:a8:ad:8c" }
42
- end
43
-
44
- context %q{with invalid mac_address ("INVALID MAC STRING")} do
45
- let( :mac_address ) { "INVALID MAC STRING" }
46
- it { expect { subject }.to raise_error( ArgumentError ) }
47
- end
48
-
49
- context "with invalid mac_address ([1, 2, 3])" do
50
- let( :mac_address ) { [ 1, 2, 3 ] }
51
- it { expect { subject }.to raise_error( TypeError ) }
52
- end
53
-
54
- it_validates "option is within range", :mac_address, 0..0xffffffffffff
55
-
56
- context "when sending a Flow Mod with action set to SetEthDstAddr" do
57
- let( :mac_address ) { "52:54:00:a8:ad:8c" }
58
-
59
- it "should insert a new flow with action set to mod_dl_dst" do
60
- class TestController < Controller; end
61
- network {
62
- vswitch { datapath_id 0xabc }
63
- }.run( TestController ) {
64
- controller( "TestController" ).send_flow_mod_add( 0xabc, :actions => subject )
65
- sleep 2
66
- expect( vswitch( "0xabc" ) ).to have( 1 ).flows
67
- expect( vswitch( "0xabc" ).flows[ 0 ].actions ).to eq( "mod_dl_dst:52:54:00:a8:ad:8c" )
68
- }
69
- end
70
- end
71
- end
72
-
73
-
74
- ### Local variables:
75
- ### mode: Ruby
76
- ### coding: utf-8-unix
77
- ### indent-tabs-mode: nil
78
- ### End:
@@ -1,78 +0,0 @@
1
- #
2
- # Copyright (C) 2008-2012 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
- require File.join( File.dirname( __FILE__ ), "..", "spec_helper" )
20
- require "trema"
21
-
22
-
23
- describe SetEthSrcAddr, ".new( mac_address )", :type => "actions" do
24
- subject { SetEthSrcAddr.new( mac_address ) }
25
-
26
- context "with mac_address (52:54:00:a8:ad:8c)" do
27
- let( :mac_address ) { "52:54:00:a8:ad:8c" }
28
- its( "mac_address.to_s" ) { should == "52:54:00:a8:ad:8c" }
29
- its( :to_s ) { should == "SetEthSrcAddr: mac_address=52:54:00:a8:ad:8c" }
30
- end
31
-
32
- context %q{with mac_address (Mac.new("52:54:00:a8:ad:8c"))} do
33
- let( :mac_address ) { Mac.new("52:54:00:a8:ad:8c") }
34
- its( "mac_address.to_s" ) { should == "52:54:00:a8:ad:8c" }
35
- its( :to_s ) { should == "SetEthSrcAddr: mac_address=52:54:00:a8:ad:8c" }
36
- end
37
-
38
- context "with mac_address (0x525400a8ad8c)" do
39
- let( :mac_address ) { 0x525400a8ad8c }
40
- its( "mac_address.to_s" ) { should == "52:54:00:a8:ad:8c" }
41
- its( :to_s ) { should == "SetEthSrcAddr: mac_address=52:54:00:a8:ad:8c" }
42
- end
43
-
44
- context %q{with invalid mac_address ("INVALID MAC STRING")} do
45
- let( :mac_address ) { "INVALID MAC STRING" }
46
- it { expect { subject }.to raise_error( ArgumentError ) }
47
- end
48
-
49
- context "with invalid mac_address ([1, 2, 3])" do
50
- let( :mac_address ) { [ 1, 2, 3 ] }
51
- it { expect { subject }.to raise_error( TypeError ) }
52
- end
53
-
54
- it_validates "option is within range", :mac_address, 0..0xffffffffffff
55
-
56
- context "when sending a Flow Mod with action set to SetEthSrcAddr" do
57
- let( :mac_address ) { "52:54:00:a8:ad:8c" }
58
-
59
- it "should insert a new flow with action set to mod_dl_src" do
60
- class TestController < Controller; end
61
- network {
62
- vswitch { datapath_id 0xabc }
63
- }.run( TestController ) {
64
- controller( "TestController" ).send_flow_mod_add( 0xabc, :actions => subject )
65
- sleep 2
66
- expect( vswitch( "0xabc" ) ).to have( 1 ).flows
67
- expect( vswitch( "0xabc" ).flows[ 0 ].actions ).to eq( "mod_dl_src:52:54:00:a8:ad:8c" )
68
- }
69
- end
70
- end
71
- end
72
-
73
-
74
- ### Local variables:
75
- ### mode: Ruby
76
- ### coding: utf-8-unix
77
- ### indent-tabs-mode: nil
78
- ### End: