trema 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +87 -13
- data/ruby/trema/barrier-reply.c +1 -3
- data/ruby/trema/controller.rb +165 -3
- data/ruby/trema/get-config-reply.c +6 -8
- data/ruby/trema/link.rb +2 -2
- data/ruby/trema/openflow-error.c +2 -4
- data/ruby/trema/queue-get-config-reply.c +3 -5
- data/ruby/trema/send-out-port.rb +29 -18
- data/ruby/trema/set-eth-addr.rb +1 -1
- data/ruby/trema/set-ip-addr.rb +1 -1
- data/ruby/trema/set-ip-tos.rb +1 -1
- data/ruby/trema/set-transport-port.rb +1 -1
- data/ruby/trema/switch-daemon.rb +18 -7
- data/ruby/trema/vendor.c +1 -1
- data/ruby/trema/version.rb +1 -3
- data/spec/trema/barrier-request_spec.rb +2 -4
- data/spec/trema/controller_spec.rb +0 -2
- data/spec/trema/get-config-reply_spec.rb +0 -2
- data/spec/trema/get-config-request_spec.rb +2 -4
- data/spec/trema/link_spec.rb +2 -4
- data/spec/trema/openflow-error_spec.rb +13 -15
- data/spec/trema/set-config_spec.rb +1 -1
- data/spec/trema/switch-daemon_spec.rb +44 -2
- data/src/examples/dumper/dumper.rb +15 -16
- data/src/lib/openflow_message.c +12 -22
- data/unittests/lib/openflow_message_test.c +6 -12
- metadata +5 -5
data/README.md
CHANGED
@@ -17,6 +17,18 @@ testing your own controllers. For debugging, a wireshark plug-in to
|
|
17
17
|
diagnose internal data-flows among functional modules is provided.
|
18
18
|
|
19
19
|
|
20
|
+
Supported Platforms
|
21
|
+
-------------------
|
22
|
+
|
23
|
+
Trema supports GNU/Linux only. And it has been tested on the following environments:
|
24
|
+
|
25
|
+
* Ubuntu 12.04, 11.10, 11.04, 10.10, and 10.04 (i386/amd64, Desktop Edition)
|
26
|
+
* Debian GNU/Linux 6.0 (i386/amd64)
|
27
|
+
|
28
|
+
It may also run on other GNU/Linux distributions but is not tested and
|
29
|
+
NOT SUPPORTED at this moment.
|
30
|
+
|
31
|
+
|
20
32
|
Getting Started
|
21
33
|
---------------
|
22
34
|
|
@@ -33,10 +45,84 @@ Getting Started
|
|
33
45
|
* The [Getting Started with Trema](https://github.com/trema/trema/wiki/Quick-start).
|
34
46
|
* The [Trema in 10 Minutes Tutorial](http://trema-10min.heroku.com/).
|
35
47
|
* The [Trema Tutorial](http://trema-tutorial.heroku.com/).
|
36
|
-
* The [Trema Ruby API documents](http://rubydoc.info/github/trema/trema/master/frames).
|
37
48
|
* The [Programming Trema Article (in Japanese)](http://gihyo.jp/dev/serial/01/openflow_sd/0007).
|
38
49
|
|
39
50
|
|
51
|
+
Ruby API
|
52
|
+
--------
|
53
|
+
|
54
|
+
The following is an exerpt from the Trema Ruby API.
|
55
|
+
The full documents are found here http://rubydoc.info/github/trema/trema/master/frames
|
56
|
+
|
57
|
+
### Event and Message Handlers
|
58
|
+
|
59
|
+
Subclass
|
60
|
+
[Trema::Controller](http://rubydoc.info/github/trema/trema/master/Trema/Controller)
|
61
|
+
and override some of the following methods to implement your own
|
62
|
+
controller.
|
63
|
+
|
64
|
+
* [switch_ready(datapath_id)](http://rubydoc.info/github/trema/trema/master/Trema/Controller:switch_ready)
|
65
|
+
* [switch_disconnected(datapath_id)](http://rubydoc.info/github/trema/trema/master/Trema/Controller:switch_disconnected)
|
66
|
+
* [packet_in(datapath_id, message)](http://rubydoc.info/github/trema/trema/master/Trema/Controller:packet_in)
|
67
|
+
* [flow_removed(datapath_id, message)](http://rubydoc.info/github/trema/trema/master/Trema/Controller:flow_removed)
|
68
|
+
* [port_status(datapath_id, message)](http://rubydoc.info/github/trema/trema/master/Trema/Controller:port_status)
|
69
|
+
* [openflow_error(datapath_id, message)](http://rubydoc.info/github/trema/trema/master/Trema/Controller:openflow_error)
|
70
|
+
* [features_reply(datapath_id, message)](http://rubydoc.info/github/trema/trema/master/Trema/Controller:features_reply)
|
71
|
+
* [stats_reply(datapath_id, message)](http://rubydoc.info/github/trema/trema/master/Trema/Controller:stats_reply)
|
72
|
+
* [barrier_reply(datapath_id, message)](http://rubydoc.info/github/trema/trema/master/Trema/Controller:barrier_reply)
|
73
|
+
* [get_config_reply(datapath_id, message)](http://rubydoc.info/github/trema/trema/master/Trema/Controller:get_config_reply)
|
74
|
+
* [queue_get_config_reply(datapath_id, message)](http://rubydoc.info/github/trema/trema/master/Trema/Controller:queue_get_config_reply)
|
75
|
+
* [vendor(datapath_id, message)](http://rubydoc.info/github/trema/trema/master/Trema/Controller:vendor)
|
76
|
+
|
77
|
+
### Flow-Mod and Packet-Out
|
78
|
+
|
79
|
+
For sending Flow-Mod and Packet-Out, there are some methods defined in
|
80
|
+
[Trema::Controller](http://rubydoc.info/github/trema/trema/master/Trema/Controller)
|
81
|
+
class.
|
82
|
+
|
83
|
+
* [send_flow_mod_add(datapath_id, options)](http://rubydoc.info/github/trema/trema/master/Trema/Controller:send_flow_mod_add)
|
84
|
+
* [send_flow_mod_delete(datapath_id, options)](http://rubydoc.info/github/trema/trema/master/Trema/Controller:send_flow_mod_delete)
|
85
|
+
* [send_flow_mod_modify(datapath_id, options)](http://rubydoc.info/github/trema/trema/master/Trema/Controller:send_flow_mod_modify)
|
86
|
+
* [send_packet_out(datapath_id, options)](http://rubydoc.info/github/trema/trema/master/Trema/Controller:send_packet_out)
|
87
|
+
|
88
|
+
### Other OpenFlow Messages
|
89
|
+
|
90
|
+
The following OpenFlow messages can be sent with
|
91
|
+
[Trema::Controller#send_message](http://rubydoc.info/github/trema/trema/master/Trema/Controller:send_message)
|
92
|
+
|
93
|
+
* [Trema::FeaturesRequest](http://rubydoc.info/github/trema/trema/master/Trema/FeaturesRequest)
|
94
|
+
* [Trema::SetConfigRequest](http://rubydoc.info/github/trema/trema/master/Trema/SetConfigRequest)
|
95
|
+
* [Trema::GetConfigRequest](http://rubydoc.info/github/trema/trema/master/Trema/GetConfigRequest)
|
96
|
+
* [Trema::QueueGetConfigRequest](http://rubydoc.info/github/trema/trema/master/Trema/QueueGetConfigRequest)
|
97
|
+
* [Trema::DescStatsRequest](http://rubydoc.info/github/trema/trema/master/Trema/DescStatsRequest)
|
98
|
+
* [Trema::FlowStatsRequest](http://rubydoc.info/github/trema/trema/master/Trema/FlowStatsRequest)
|
99
|
+
* [Trema::AggregateStatsRequest](http://rubydoc.info/github/trema/trema/master/Trema/AggregateStatsRequest)
|
100
|
+
* [Trema::TableStatsRequest](http://rubydoc.info/github/trema/trema/master/Trema/TableStatsRequest)
|
101
|
+
* [Trema::PortStatsRequest](http://rubydoc.info/github/trema/trema/master/Trema/PortStatsRequest)
|
102
|
+
* [Trema::QueueStatsRequest](http://rubydoc.info/github/trema/trema/master/Trema/QueueStatsRequest)
|
103
|
+
* [Trema::VendorStatsRequest](http://rubydoc.info/github/trema/trema/master/Trema/VendorStatsRequest)
|
104
|
+
* [Trema::BarrierRequest](http://rubydoc.info/github/trema/trema/master/Trema/BarrierRequest)
|
105
|
+
* [Trema::PortMod](http://rubydoc.info/github/trema/trema/master/Trema/PortMod)
|
106
|
+
* [Trema::Vendor](http://rubydoc.info/github/trema/trema/master/Trema/Vendor)
|
107
|
+
|
108
|
+
### Actions
|
109
|
+
|
110
|
+
Each flow table entry contains a list of actions that will be executed when a packet matches the entry.
|
111
|
+
|
112
|
+
* [Trema::SendOutPort](http://rubydoc.info/github/trema/trema/master/Trema/SendOutPort)
|
113
|
+
* [Trema::SetEthSrcAddr](http://rubydoc.info/github/trema/trema/master/Trema/SetEthSrcAddr)
|
114
|
+
* [Trema::SetEthDstAddr](http://rubydoc.info/github/trema/trema/master/Trema/SetEthDstAddr)
|
115
|
+
* [Trema::SetIpSrcAddr](http://rubydoc.info/github/trema/trema/master/Trema/SetIpSrcAddr)
|
116
|
+
* [Trema::SetIpDstAddr](http://rubydoc.info/github/trema/trema/master/Trema/SetIpDstAddr)
|
117
|
+
* [Trema::SetIpTos](http://rubydoc.info/github/trema/trema/master/Trema/SetIpTos)
|
118
|
+
* [Trema::SetTransportSrcPort](http://rubydoc.info/github/trema/trema/master/Trema/SetTransportSrcPort)
|
119
|
+
* [Trema::SetTransportDstPort](http://rubydoc.info/github/trema/trema/master/Trema/SetTransportDstPort)
|
120
|
+
* [Trema::SetVlanVid](http://rubydoc.info/github/trema/trema/master/Trema/SetVlanVid)
|
121
|
+
* [Trema::SetVlanPriority](http://rubydoc.info/github/trema/trema/master/Trema/SetVlanPriority)
|
122
|
+
* [Trema::StripVlanHeader](http://rubydoc.info/github/trema/trema/master/Trema/StripVlanHeader)
|
123
|
+
* [Trema::VendorAction](http://rubydoc.info/github/trema/trema/master/Trema/VendorAction)
|
124
|
+
|
125
|
+
|
40
126
|
Meta
|
41
127
|
----
|
42
128
|
|
@@ -46,18 +132,6 @@ Meta
|
|
46
132
|
* Twitter: http://twitter.com/trema_news
|
47
133
|
|
48
134
|
|
49
|
-
Supported Platforms
|
50
|
-
-------------------
|
51
|
-
|
52
|
-
Trema has been tested ONLY on the following environments:
|
53
|
-
|
54
|
-
* Ubuntu 12.04, 11.10, 11.04, 10.10, and 10.04 (i386/amd64, Desktop Edition)
|
55
|
-
* Debian GNU/Linux 6.0 (i386/amd64)
|
56
|
-
|
57
|
-
It may also run on other GNU/Linux distributions but is not tested and
|
58
|
-
NOT SUPPORTED at this moment.
|
59
|
-
|
60
|
-
|
61
135
|
Contributors
|
62
136
|
------------
|
63
137
|
|
data/ruby/trema/barrier-reply.c
CHANGED
@@ -1,6 +1,4 @@
|
|
1
1
|
/*
|
2
|
-
* Author: Nick Karanatsios <nickkaranatsios@gmail.com>
|
3
|
-
*
|
4
2
|
* Copyright (C) 2008-2012 NEC Corporation
|
5
3
|
*
|
6
4
|
* This program is free software; you can redistribute it and/or modify
|
@@ -87,7 +85,7 @@ handle_barrier_reply( uint64_t datapath_id, uint32_t transaction_id, void *user_
|
|
87
85
|
}
|
88
86
|
|
89
87
|
VALUE barrier_reply = rb_funcall( cBarrierReply, rb_intern( "new" ), 2, ULL2NUM( datapath_id ), UINT2NUM( transaction_id ) );
|
90
|
-
rb_funcall( controller, rb_intern( "barrier_reply" ),
|
88
|
+
rb_funcall( controller, rb_intern( "barrier_reply" ), 2, ULL2NUM( datapath_id ), barrier_reply );
|
91
89
|
}
|
92
90
|
|
93
91
|
|
data/ruby/trema/controller.rb
CHANGED
@@ -25,7 +25,7 @@ require "trema/timers"
|
|
25
25
|
|
26
26
|
module Trema
|
27
27
|
#
|
28
|
-
# The base class of Trema controller.
|
28
|
+
# @abstract The base class of Trema controller. Subclass and override handlers to implement a custom OpenFlow controller.
|
29
29
|
#
|
30
30
|
class Controller < App
|
31
31
|
include Logger
|
@@ -33,14 +33,176 @@ module Trema
|
|
33
33
|
|
34
34
|
|
35
35
|
#
|
36
|
-
#
|
37
|
-
#
|
36
|
+
# @private Just a placeholder for YARD.
|
37
|
+
#
|
38
|
+
def self.handler name
|
39
|
+
# Do nothing.
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
#
|
44
|
+
# @!method switch_ready( datapath_id )
|
45
|
+
#
|
46
|
+
# @abstract Switch Ready event handler. Override this to implement a custom handler.
|
47
|
+
#
|
48
|
+
# @param [Integer] datapath_id
|
49
|
+
# the datapath ID of connected OpenFlow switch.
|
50
|
+
#
|
51
|
+
handler :switch_ready
|
52
|
+
|
53
|
+
|
54
|
+
#
|
55
|
+
# @!method switch_disconnected( datapath_id )
|
56
|
+
#
|
57
|
+
# @abstract Switch Disconnected event handler. Override this to implement a custom handler.
|
58
|
+
#
|
59
|
+
# @param [Integer] datapath_id
|
60
|
+
# the datapath ID of disconnected OpenFlow switch.
|
61
|
+
#
|
62
|
+
handler :switch_disconnected
|
63
|
+
|
64
|
+
|
65
|
+
#
|
66
|
+
# @!method packet_in( datapath_id, message )
|
67
|
+
#
|
68
|
+
# @abstract Packet In message handler. Override this to implement a custom handler.
|
69
|
+
#
|
70
|
+
# @param [Integer] datapath_id
|
71
|
+
# the datapath from which a message is sent.
|
72
|
+
# @param [PacketIn] message
|
73
|
+
# the Packet In message.
|
74
|
+
#
|
75
|
+
handler :packet_in
|
76
|
+
|
77
|
+
|
78
|
+
#
|
79
|
+
# @!method flow_removed( datapath_id, message )
|
80
|
+
#
|
81
|
+
# @abstract Flow Removed message handler. Override this to implement a custom handler.
|
82
|
+
#
|
83
|
+
# @param [Integer] datapath_id
|
84
|
+
# the datapath from which a message is sent.
|
85
|
+
# @param [FlowRemoved] message
|
86
|
+
# the Flow Removed message.
|
87
|
+
#
|
88
|
+
handler :flow_removed
|
89
|
+
|
90
|
+
|
91
|
+
#
|
92
|
+
# @!method port_status( datapath_id, message )
|
93
|
+
#
|
94
|
+
# @abstract Port Status message handler. Override this to implement a custom handler.
|
95
|
+
#
|
96
|
+
# @param [Integer] datapath_id
|
97
|
+
# the datapath from which a message is sent.
|
98
|
+
# @param [PortStatus] message
|
99
|
+
# the Port Status message.
|
100
|
+
#
|
101
|
+
handler :port_status
|
102
|
+
|
103
|
+
|
104
|
+
#
|
105
|
+
# @!method openflow_error( datapath_id, message )
|
106
|
+
#
|
107
|
+
# @abstract OpenFlow Error message handler. Override this to implement a custom handler.
|
108
|
+
#
|
109
|
+
# @param [Integer] datapath_id
|
110
|
+
# the datapath from which a message is sent.
|
111
|
+
# @param [OpenflowError] message
|
112
|
+
# the OpenFlow Error message.
|
113
|
+
#
|
114
|
+
handler :openflow_error
|
115
|
+
|
116
|
+
|
117
|
+
#
|
118
|
+
# @!method features_reply( datapath_id, message )
|
119
|
+
#
|
120
|
+
# @abstract Features Reply message handler. Override this to implement a custom handler.
|
121
|
+
#
|
122
|
+
# @param [Integer] datapath_id
|
123
|
+
# the datapath from which a message is sent.
|
124
|
+
# @param [FeaturesReply] message
|
125
|
+
# the Features Reply message.
|
126
|
+
#
|
127
|
+
handler :features_reply
|
128
|
+
|
129
|
+
|
130
|
+
#
|
131
|
+
# @!method stats_reply( datapath_id, message )
|
132
|
+
#
|
133
|
+
# @abstract Stats Reply message handler. Override this to implement a custom handler.
|
134
|
+
#
|
135
|
+
# @param [Integer] datapath_id
|
136
|
+
# the datapath from which a message is sent.
|
137
|
+
# @param [StatsReply] message
|
138
|
+
# the Stats Reply message.
|
139
|
+
#
|
140
|
+
handler :stats_reply
|
141
|
+
|
142
|
+
|
143
|
+
#
|
144
|
+
# @!method barrier_reply( datapath_id, message )
|
145
|
+
#
|
146
|
+
# @abstract Barrier Reply message handler. Override this to implement a custom handler.
|
147
|
+
#
|
148
|
+
# @param [Integer] datapath_id
|
149
|
+
# the datapath from which a message is sent.
|
150
|
+
# @param [BarrierReply] message
|
151
|
+
# the Barrier Reply message.
|
152
|
+
#
|
153
|
+
handler :barrier_reply
|
154
|
+
|
155
|
+
|
156
|
+
#
|
157
|
+
# @!method get_config_reply( datapath_id, message )
|
158
|
+
#
|
159
|
+
# @abstract Get Config Reply message handler. Override this to implement a custom handler.
|
160
|
+
#
|
161
|
+
# @param [Integer] datapath_id
|
162
|
+
# the datapath from which a message is sent.
|
163
|
+
# @param [GetConfigReply] message
|
164
|
+
# the Get Config Reply message.
|
165
|
+
#
|
166
|
+
handler :get_config_reply
|
167
|
+
|
168
|
+
|
169
|
+
#
|
170
|
+
# @!method queue_get_config_reply( datapath_id, message )
|
171
|
+
#
|
172
|
+
# @abstract Queue Get Config Reply message handler. Override this to implement a custom handler.
|
173
|
+
#
|
174
|
+
# @param [Integer] datapath_id
|
175
|
+
# the datapath from which a message is sent.
|
176
|
+
# @param [QueueGetConfigReply] message
|
177
|
+
# the Queue Get Config Reply message.
|
178
|
+
#
|
179
|
+
handler :queue_get_config_reply
|
180
|
+
|
181
|
+
|
182
|
+
#
|
183
|
+
# @!method vendor( datapath_id, message )
|
184
|
+
#
|
185
|
+
# @abstract Vendor message handler. Override this to implement a custom handler.
|
186
|
+
#
|
187
|
+
# @param [Integer] datapath_id
|
188
|
+
# the datapath from which a message is sent.
|
189
|
+
# @param [Vendor] message
|
190
|
+
# the Vendor message.
|
191
|
+
#
|
192
|
+
handler :vendor
|
193
|
+
|
194
|
+
|
195
|
+
#
|
196
|
+
# @private
|
38
197
|
#
|
39
198
|
def self.inherited subclass
|
40
199
|
subclass.new
|
41
200
|
end
|
42
201
|
|
43
202
|
|
203
|
+
#
|
204
|
+
# @private
|
205
|
+
#
|
44
206
|
def initialize
|
45
207
|
App.add self
|
46
208
|
end
|
@@ -1,6 +1,4 @@
|
|
1
1
|
/*
|
2
|
-
* Author: Nick Karanatsios <nickkaranatsios@gmail.com>
|
3
|
-
*
|
4
2
|
* Copyright (C) 2008-2012 NEC Corporation
|
5
3
|
*
|
6
4
|
* This program is free software; you can redistribute it and/or modify
|
@@ -29,12 +27,12 @@ VALUE cGetConfigReply;
|
|
29
27
|
/*
|
30
28
|
* Handles the response to +OFPT_GET_CONFIG_REQUEST+ message. The user would not
|
31
29
|
* explicitly instantiate a {GetConfigReply} object but would be created while
|
32
|
-
* parsing the +OFPT_GET_CONFIG_REPLY+ message. The {GetConfigReply} object is
|
30
|
+
* parsing the +OFPT_GET_CONFIG_REPLY+ message. The {GetConfigReply} object is
|
33
31
|
* an object whose attributes represent the return values of the message.
|
34
32
|
*
|
35
33
|
* @overload initialize(options={})
|
36
34
|
*
|
37
|
-
* @example
|
35
|
+
* @example
|
38
36
|
* GetConfigReply.new(
|
39
37
|
* :datapath_id => 2748
|
40
38
|
* :transaction_id => 1,
|
@@ -55,11 +53,11 @@ VALUE cGetConfigReply;
|
|
55
53
|
* indicates how IP fragments are treated.
|
56
54
|
*
|
57
55
|
* @option options [Number] :miss_send_len
|
58
|
-
* the maximum number of bytes to send on a flow table miss or
|
56
|
+
* the maximum number of bytes to send on a flow table miss or
|
59
57
|
* flow destined to controller.
|
60
58
|
*
|
61
|
-
* @return [GetConfigReply]
|
62
|
-
* an object that encapsulates the +OFPT_GET_CONFIG_REPLY+ OpenFlow message.
|
59
|
+
* @return [GetConfigReply]
|
60
|
+
* an object that encapsulates the +OFPT_GET_CONFIG_REPLY+ OpenFlow message.
|
63
61
|
*/
|
64
62
|
static VALUE
|
65
63
|
get_config_reply_init( VALUE self, VALUE options ) {
|
@@ -147,7 +145,7 @@ handle_get_config_reply(
|
|
147
145
|
rb_hash_aset( attributes, ID2SYM( rb_intern( "miss_send_len" ) ), UINT2NUM( miss_send_len ) );
|
148
146
|
|
149
147
|
VALUE get_config_reply = rb_funcall( cGetConfigReply, rb_intern( "new" ), 1, attributes );
|
150
|
-
rb_funcall( controller, rb_intern( "get_config_reply" ),
|
148
|
+
rb_funcall( controller, rb_intern( "get_config_reply" ), 2, ULL2NUM( datapath_id ), get_config_reply );
|
151
149
|
}
|
152
150
|
|
153
151
|
|
data/ruby/trema/link.rb
CHANGED
@@ -98,8 +98,8 @@ module Trema
|
|
98
98
|
def add!
|
99
99
|
return if real_eth?
|
100
100
|
sh "sudo ip link add name #{ @name } type veth peer name #{ @name_peer }"
|
101
|
-
sh "sudo sysctl -w net.ipv6.conf.#{ @name }.disable_ipv6=1 >/dev/null 2>&1"
|
102
|
-
sh "sudo sysctl -w net.ipv6.conf.#{ @name_peer }.disable_ipv6=1 >/dev/null 2>&1"
|
101
|
+
sh "sudo /sbin/sysctl -w net.ipv6.conf.#{ @name }.disable_ipv6=1 >/dev/null 2>&1"
|
102
|
+
sh "sudo /sbin/sysctl -w net.ipv6.conf.#{ @name_peer }.disable_ipv6=1 >/dev/null 2>&1"
|
103
103
|
end
|
104
104
|
|
105
105
|
|
data/ruby/trema/openflow-error.c
CHANGED
@@ -1,6 +1,4 @@
|
|
1
1
|
/*
|
2
|
-
* Author: Nick Karanatsios <nickkaranatsios@gmail.com>
|
3
|
-
*
|
4
2
|
* Copyright (C) 2008-2012 NEC Corporation
|
5
3
|
*
|
6
4
|
* This program is free software; you can redistribute it and/or modify
|
@@ -28,7 +26,7 @@ VALUE cOpenflowError;
|
|
28
26
|
|
29
27
|
/*
|
30
28
|
* The occurence of reported errors/exceptions manifested as an instance - a
|
31
|
-
* {OpenflowError} object. The user would not explicitly instantiate
|
29
|
+
* {OpenflowError} object. The user would not explicitly instantiate
|
32
30
|
* a {OpenflowError} but would be created while parsing the +OFPT_ERROR+ message.
|
33
31
|
*
|
34
32
|
* @overload initialize(options={})
|
@@ -179,7 +177,7 @@ handle_openflow_error(
|
|
179
177
|
break;
|
180
178
|
}
|
181
179
|
VALUE openflow_error = rb_funcall( cOpenflowError, rb_intern( "new" ), 1, attributes );
|
182
|
-
rb_funcall( controller, rb_intern( "openflow_error" ),
|
180
|
+
rb_funcall( controller, rb_intern( "openflow_error" ), 2, ULL2NUM( datapath_id ), openflow_error );
|
183
181
|
}
|
184
182
|
|
185
183
|
|
@@ -1,6 +1,4 @@
|
|
1
1
|
/*
|
2
|
-
* Author: Nick Karanatsios <nickkaranatsios@gmail.com>
|
3
|
-
*
|
4
2
|
* Copyright (C) 2008-2012 NEC Corporation
|
5
3
|
*
|
6
4
|
* This program is free software; you can redistribute it and/or modify
|
@@ -48,7 +46,7 @@ VALUE cQueueGetConfigReply;
|
|
48
46
|
*
|
49
47
|
* @option options [Number] :transaction_id
|
50
48
|
* value copied from +OPFT_QUEUE_SET_CONFIG_REQUEST+ message.
|
51
|
-
*
|
49
|
+
*
|
52
50
|
* @option options [Number] :port
|
53
51
|
* the port the queue is attached to.
|
54
52
|
*
|
@@ -100,7 +98,7 @@ queue_get_config_reply_port( VALUE self ) {
|
|
100
98
|
|
101
99
|
/*
|
102
100
|
* An array of {PacketQueue} objects. A packet queue is further classified
|
103
|
-
* depending on its properties. Currently only a minimum-rate type queue
|
101
|
+
* depending on its properties. Currently only a minimum-rate type queue
|
104
102
|
* supported.
|
105
103
|
*
|
106
104
|
* @return [Array<PacketQueue>] the value of queues.
|
@@ -188,7 +186,7 @@ handle_queue_get_config_reply(
|
|
188
186
|
rb_hash_aset( attributes, ID2SYM( rb_intern( "queues" ) ), rb_eval_string( "PacketQueue.queues" ) );
|
189
187
|
}
|
190
188
|
VALUE queue_get_config_reply = rb_funcall( cQueueGetConfigReply, rb_intern( "new" ), 1, attributes );
|
191
|
-
rb_funcall( controller, rb_intern( "queue_get_config_reply" ),
|
189
|
+
rb_funcall( controller, rb_intern( "queue_get_config_reply" ), 2, ULL2NUM( datapath_id ), queue_get_config_reply );
|
192
190
|
}
|
193
191
|
|
194
192
|
|
data/ruby/trema/send-out-port.rb
CHANGED
@@ -25,6 +25,9 @@ module Trema
|
|
25
25
|
# An action to output a packet to a port.
|
26
26
|
#
|
27
27
|
class SendOutPort < Action
|
28
|
+
DEFAULT_MAX_LEN = 2 ** 16 - 1
|
29
|
+
|
30
|
+
|
28
31
|
attr_reader :max_len
|
29
32
|
attr_reader :port_number
|
30
33
|
|
@@ -59,29 +62,37 @@ module Trema
|
|
59
62
|
case options
|
60
63
|
when Hash
|
61
64
|
@port_number = options[ :port_number ] || options[ :port ]
|
62
|
-
@max_len = options[ :max_len ]
|
63
|
-
if @port_number.nil?
|
64
|
-
raise ArgumentError, ":port_number is a mandatory option"
|
65
|
-
end
|
66
|
-
if not @port_number.unsigned_16bit?
|
67
|
-
raise ArgumentError, "Port number must be an unsigned 16-bit integer"
|
68
|
-
end
|
69
|
-
if @max_len
|
70
|
-
if not @max_len.unsigned_16bit?
|
71
|
-
raise ArgumentError, ":max_len must be an unsigned 16-bit integer"
|
72
|
-
end
|
73
|
-
else
|
74
|
-
@max_len = 2 ** 16 - 1
|
75
|
-
end
|
65
|
+
@max_len = options[ :max_len ] || DEFAULT_MAX_LEN
|
76
66
|
when Integer
|
77
|
-
if not options.unsigned_16bit?
|
78
|
-
raise ArgumentError, "Port number must be an unsigned 16-bit integer"
|
79
|
-
end
|
80
67
|
@port_number = options
|
81
|
-
@max_len =
|
68
|
+
@max_len = DEFAULT_MAX_LEN
|
82
69
|
else
|
83
70
|
raise "Invalid option"
|
84
71
|
end
|
72
|
+
check_port_number
|
73
|
+
check_max_len
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
|
78
|
+
##############################################################################
|
79
|
+
private
|
80
|
+
##############################################################################
|
81
|
+
|
82
|
+
|
83
|
+
def check_port_number
|
84
|
+
if @port_number.nil?
|
85
|
+
raise ArgumentError, "Port number is a mandatory option"
|
86
|
+
end
|
87
|
+
if not @port_number.unsigned_16bit?
|
88
|
+
raise ArgumentError, "Port number must be an unsigned 16-bit integer"
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
|
93
|
+
def check_max_len
|
94
|
+
if not @max_len.unsigned_16bit?
|
95
|
+
raise ArgumentError, "Max length must be an unsigned 16-bit integer"
|
85
96
|
end
|
86
97
|
end
|
87
98
|
|
data/ruby/trema/set-eth-addr.rb
CHANGED
data/ruby/trema/set-ip-addr.rb
CHANGED
data/ruby/trema/set-ip-tos.rb
CHANGED
@@ -34,7 +34,7 @@ module Trema
|
|
34
34
|
# @example
|
35
35
|
# SetIpTos.new(32)
|
36
36
|
#
|
37
|
-
# @param [Integer]
|
37
|
+
# @param [Integer] type_of_service
|
38
38
|
# the ToS/DSCP field to set to.
|
39
39
|
#
|
40
40
|
# @raise [ArgumentError] if type_of_service argument is not an unsigned 8-bit Integer.
|
@@ -22,7 +22,7 @@ require "trema/monkey-patch/integer"
|
|
22
22
|
|
23
23
|
module Trema
|
24
24
|
#
|
25
|
-
#
|
25
|
+
# @abstract The base class of {SetTransportSrcPort} and {SetTransportDstPort} action.
|
26
26
|
#
|
27
27
|
class SetTransportPort < Action
|
28
28
|
attr_reader :port_number
|
data/ruby/trema/switch-daemon.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# The controller class of switch daemon.
|
3
3
|
#
|
4
|
-
# Author: Yasuhito Takamiya <yasuhito@gmail.com>
|
5
|
-
#
|
6
4
|
# Copyright (C) 2008-2012 NEC Corporation
|
7
5
|
#
|
8
6
|
# This program is free software; you can redistribute it and/or modify
|
@@ -29,7 +27,7 @@ module Trema
|
|
29
27
|
|
30
28
|
|
31
29
|
def options
|
32
|
-
|
30
|
+
portstatus_queue + packetin_queue + statenotify_queue + vendor_queue
|
33
31
|
end
|
34
32
|
|
35
33
|
|
@@ -46,22 +44,35 @@ module Trema
|
|
46
44
|
|
47
45
|
|
48
46
|
def portstatus_queue
|
49
|
-
|
47
|
+
controllers = @queues[ :port_status ].split( "," )
|
48
|
+
controllers.collect do | each |
|
49
|
+
"port_status::#{ each }"
|
50
|
+
end
|
50
51
|
end
|
51
52
|
|
52
53
|
|
53
54
|
def packetin_queue
|
54
|
-
|
55
|
+
controllers = @queues[ :packet_in ].split( "," )
|
56
|
+
controllers.collect do | each |
|
57
|
+
"packet_in::#{ each }"
|
58
|
+
end
|
55
59
|
end
|
56
60
|
|
57
61
|
|
58
62
|
def statenotify_queue
|
59
|
-
|
63
|
+
controllers = @queues[ :state_notify ].split( "," )
|
64
|
+
controllers.collect do | each |
|
65
|
+
"state_notify::#{ each }"
|
66
|
+
end
|
60
67
|
end
|
61
68
|
|
62
69
|
|
63
70
|
def vendor_queue
|
64
|
-
|
71
|
+
return [] if not @queues[ :vendor ]
|
72
|
+
controllers = @queues[ :vendor ].split( "," )
|
73
|
+
controllers.collect do | each |
|
74
|
+
"vendor::#{ each }"
|
75
|
+
end
|
65
76
|
end
|
66
77
|
end
|
67
78
|
end
|
data/ruby/trema/vendor.c
CHANGED
@@ -209,7 +209,7 @@ handle_vendor(
|
|
209
209
|
rb_hash_aset( attributes, ID2SYM( rb_intern( "data" ) ), rb_str_new( data->data, ( long ) data->length ) );
|
210
210
|
}
|
211
211
|
VALUE vendor_r = rb_funcall( cVendor, rb_intern( "new" ), 1, attributes );
|
212
|
-
rb_funcall( controller, rb_intern( "vendor" ),
|
212
|
+
rb_funcall( controller, rb_intern( "vendor" ), 2, ULL2NUM( datapath_id ), vendor_r );
|
213
213
|
}
|
214
214
|
|
215
215
|
|
data/ruby/trema/version.rb
CHANGED
@@ -1,6 +1,4 @@
|
|
1
1
|
#
|
2
|
-
# Author: Yasuhito Takamiya <yasuhito@gmail.com>
|
3
|
-
#
|
4
2
|
# Copyright (C) 2008-2012 NEC Corporation
|
5
3
|
#
|
6
4
|
# This program is free software; you can redistribute it and/or modify
|
@@ -19,7 +17,7 @@
|
|
19
17
|
|
20
18
|
|
21
19
|
module Trema
|
22
|
-
VERSION = "0.2.
|
20
|
+
VERSION = "0.2.4"
|
23
21
|
end
|
24
22
|
|
25
23
|
|
@@ -1,6 +1,4 @@
|
|
1
1
|
#
|
2
|
-
# Author: Nick Karanatsios <nickkaranatsios@gmail.com>
|
3
|
-
#
|
4
2
|
# Copyright (C) 2008-2012 NEC Corporation
|
5
3
|
#
|
6
4
|
# This program is free software; you can redistribute it and/or modify
|
@@ -54,8 +52,8 @@ describe BarrierRequest, ".new( OPTIONAL OPTION ) - transaction_id" do
|
|
54
52
|
network {
|
55
53
|
vswitch { datapath_id 0xabc }
|
56
54
|
}.run( BarrierController ) {
|
57
|
-
controller( "BarrierController" ).should_receive( :barrier_reply ) do | message |
|
58
|
-
|
55
|
+
controller( "BarrierController" ).should_receive( :barrier_reply ) do | datapath_id, message |
|
56
|
+
datapath_id.should == 0xabc
|
59
57
|
message.transaction_id.should == 1234
|
60
58
|
end
|
61
59
|
barrier_request = BarrierRequest.new( :transaction_id => 1234 )
|
@@ -1,6 +1,4 @@
|
|
1
1
|
#
|
2
|
-
# Author: Nick Karanatsios <nickkaranatsios@gmail.com>
|
3
|
-
#
|
4
2
|
# Copyright (C) 2008-2012 NEC Corporation
|
5
3
|
#
|
6
4
|
# This program is free software; you can redistribute it and/or modify
|
@@ -61,8 +59,8 @@ describe GetConfigRequest, ".new( VALID OPTION )" do
|
|
61
59
|
vswitch { datapath_id 0xabc }
|
62
60
|
}.run( GetConfigController ) {
|
63
61
|
get_config_request = GetConfigRequest.new( :transaction_id => 1234 )
|
64
|
-
controller( "GetConfigController" ).should_receive( :get_config_reply ) do | message |
|
65
|
-
|
62
|
+
controller( "GetConfigController" ).should_receive( :get_config_reply ) do | datapath_id, message |
|
63
|
+
datapath_id.should == 0xabc
|
66
64
|
message.transaction_id.should == 1234
|
67
65
|
message.flags.should >= 0 and message.flags.should <= 3
|
68
66
|
message.miss_send_len.should == 65535
|
data/spec/trema/link_spec.rb
CHANGED
@@ -1,6 +1,4 @@
|
|
1
1
|
#
|
2
|
-
# Author: Yasuhito Takamiya <yasuhito@gmail.com>
|
3
|
-
#
|
4
2
|
# Copyright (C) 2008-2012 NEC Corporation
|
5
3
|
#
|
6
4
|
# This program is free software; you can redistribute it and/or modify
|
@@ -38,8 +36,8 @@ module Trema
|
|
38
36
|
|
39
37
|
it "executes ip and ifconfig command" do
|
40
38
|
@link.should_receive( :sh ).once.ordered.with( "sudo ip link add name trema0-0 type veth peer name trema0-1" )
|
41
|
-
@link.should_receive( :sh ).once.ordered.with( "sudo sysctl -w net.ipv6.conf.trema0-0.disable_ipv6=1 >/dev/null 2>&1" )
|
42
|
-
@link.should_receive( :sh ).once.ordered.with( "sudo sysctl -w net.ipv6.conf.trema0-1.disable_ipv6=1 >/dev/null 2>&1" )
|
39
|
+
@link.should_receive( :sh ).once.ordered.with( "sudo /sbin/sysctl -w net.ipv6.conf.trema0-0.disable_ipv6=1 >/dev/null 2>&1" )
|
40
|
+
@link.should_receive( :sh ).once.ordered.with( "sudo /sbin/sysctl -w net.ipv6.conf.trema0-1.disable_ipv6=1 >/dev/null 2>&1" )
|
43
41
|
@link.should_receive( :sh ).once.ordered.with( "sudo /sbin/ifconfig trema0-0 up" )
|
44
42
|
@link.should_receive( :sh ).once.ordered.with( "sudo /sbin/ifconfig trema0-1 up" )
|
45
43
|
|
@@ -1,6 +1,4 @@
|
|
1
1
|
#
|
2
|
-
# Author: Nick Karanatsios <nickkaranatsios@gmail.com>
|
3
|
-
#
|
4
2
|
# Copyright (C) 2008-2012 NEC Corporation
|
5
3
|
#
|
6
4
|
# This program is free software; you can redistribute it and/or modify
|
@@ -35,10 +33,10 @@ describe Trema::OpenflowError, "new" do
|
|
35
33
|
:mask => 1,
|
36
34
|
:advertise => 0
|
37
35
|
)
|
38
|
-
controller( "OpenflowErrorController" ).should_receive( :openflow_error ) do |
|
39
|
-
|
40
|
-
|
41
|
-
|
36
|
+
controller( "OpenflowErrorController" ).should_receive( :openflow_error ) do | datapath_id, message |
|
37
|
+
datapath_id.should == 0xabc
|
38
|
+
message.type.should == Error::OFPET_PORT_MOD_FAILED
|
39
|
+
message.code.should == Error::OFPPMFC_BAD_PORT
|
42
40
|
end
|
43
41
|
controller( "OpenflowErrorController" ).send_message( 0xabc, port_mod )
|
44
42
|
sleep 2 # FIXME: wait to send_message
|
@@ -63,10 +61,10 @@ describe Trema::OpenflowError, "new" do
|
|
63
61
|
:mask => 1,
|
64
62
|
:advertise => 0
|
65
63
|
)
|
66
|
-
controller( "OpenflowErrorController" ).should_receive( :openflow_error ) do |
|
67
|
-
|
68
|
-
|
69
|
-
|
64
|
+
controller( "OpenflowErrorController" ).should_receive( :openflow_error ) do | datapath_id, message |
|
65
|
+
datapath_id.should == 0xabc
|
66
|
+
message.type.should == Error::OFPET_PORT_MOD_FAILED
|
67
|
+
message.code.should == Error::OFPPMFC_BAD_HW_ADDR
|
70
68
|
end
|
71
69
|
controller( "OpenflowErrorController" ).send_message( 0xabc, port_mod )
|
72
70
|
sleep 2 # FIXME: wait to send_message
|
@@ -85,10 +83,10 @@ describe Trema::OpenflowError, "new" do
|
|
85
83
|
link "host1", "error-port"
|
86
84
|
link "host2", "error-port"
|
87
85
|
}.run( OpenflowErrorController ) {
|
88
|
-
controller( "OpenflowErrorController" ).should_receive( :openflow_error ) do |
|
89
|
-
|
90
|
-
|
91
|
-
|
86
|
+
controller( "OpenflowErrorController" ).should_receive( :openflow_error ) do | datapath_id, message |
|
87
|
+
datapath_id.should == 0xabc
|
88
|
+
message.type.should == Error::OFPET_BAD_ACTION
|
89
|
+
message.code.should == Error::OFPBAC_BAD_OUT_PORT
|
92
90
|
end
|
93
91
|
controller( "OpenflowErrorController" ).send_flow_mod_add( 0xabc, :actions => ActionOutput.new( :port => 0x5555 ) )
|
94
92
|
sleep 2 # FIXME: wait to send_flow_mod_add
|
@@ -104,7 +102,7 @@ describe Trema::OpenflowError, "new" do
|
|
104
102
|
vswitch( "error-request") { datapath_id 0xabc }
|
105
103
|
}.run( OpenflowController ) {
|
106
104
|
queue_get_config_request = Trema::QueueGetConfigRequest.new( :port => 1 )
|
107
|
-
controller( "OpenflowController" ).should_receive( :openflow_error ) do | message |
|
105
|
+
controller( "OpenflowController" ).should_receive( :openflow_error ) do | datapath_id, message |
|
108
106
|
message.datapath_id.should == 0xabc
|
109
107
|
message.type.should satisfy { | n |
|
110
108
|
n >= 0 && n <= 5
|
@@ -58,7 +58,7 @@ describe SetConfig, ".new( VALID OPTIONS )" do
|
|
58
58
|
network {
|
59
59
|
vswitch { datapath_id 0xabc }
|
60
60
|
}.run( SetConfigController ) {
|
61
|
-
controller( "SetConfigController" ).should_receive( :get_config_reply ) do | arg |
|
61
|
+
controller( "SetConfigController" ).should_receive( :get_config_reply ) do | dpid, arg |
|
62
62
|
arg.flags.should == 0
|
63
63
|
arg.miss_send_len.should == 0
|
64
64
|
end
|
@@ -23,10 +23,52 @@ require "trema/switch-daemon"
|
|
23
23
|
module Trema
|
24
24
|
describe SwitchDaemon do
|
25
25
|
it "should be initialized with proper options" do
|
26
|
-
rule = {
|
26
|
+
rule = {
|
27
|
+
:port_status => "topology",
|
28
|
+
:packet_in => "controller",
|
29
|
+
:state_notify => "topology",
|
30
|
+
:vendor => "controller"
|
31
|
+
}
|
27
32
|
switch_daemon = SwitchDaemon.new( rule )
|
28
33
|
|
29
|
-
switch_daemon.options.should
|
34
|
+
switch_daemon.options.should include( "port_status::topology" )
|
35
|
+
switch_daemon.options.should include( "packet_in::controller" )
|
36
|
+
switch_daemon.options.should include( "state_notify::topology" )
|
37
|
+
switch_daemon.options.should include( "vendor::controller" )
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
it "should be initialized with options which have multiple controllers" do
|
42
|
+
rule = {
|
43
|
+
:port_status => "topology0,topology1",
|
44
|
+
:packet_in => "controller0,controller1",
|
45
|
+
:state_notify => "topology0,topology1",
|
46
|
+
:vendor => "controller0,controller1"
|
47
|
+
}
|
48
|
+
switch_daemon = SwitchDaemon.new( rule )
|
49
|
+
|
50
|
+
switch_daemon.options.should include( "port_status::topology0" )
|
51
|
+
switch_daemon.options.should include( "port_status::topology1" )
|
52
|
+
switch_daemon.options.should include( "packet_in::controller0" )
|
53
|
+
switch_daemon.options.should include( "packet_in::controller1" )
|
54
|
+
switch_daemon.options.should include( "state_notify::topology0" )
|
55
|
+
switch_daemon.options.should include( "state_notify::topology1" )
|
56
|
+
switch_daemon.options.should include( "vendor::controller0" )
|
57
|
+
switch_daemon.options.should include( "vendor::controller1" )
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
it "should be initialized without vendor options" do
|
62
|
+
rule = {
|
63
|
+
:port_status => "topology",
|
64
|
+
:packet_in => "controller",
|
65
|
+
:state_notify => "topology"
|
66
|
+
}
|
67
|
+
switch_daemon = SwitchDaemon.new( rule )
|
68
|
+
|
69
|
+
switch_daemon.options.should include( "port_status::topology" )
|
70
|
+
switch_daemon.options.should include( "packet_in::controller" )
|
71
|
+
switch_daemon.options.should include( "state_notify::topology" )
|
30
72
|
end
|
31
73
|
end
|
32
74
|
end
|
@@ -1,8 +1,4 @@
|
|
1
1
|
#
|
2
|
-
# Openflow message event dumper.
|
3
|
-
#
|
4
|
-
# Author: Nick Karanatsios <nickkaranatsios@gmail.com>
|
5
|
-
#
|
6
2
|
# Copyright (C) 2008-2012 NEC Corporation
|
7
3
|
#
|
8
4
|
# This program is free software; you can redistribute it and/or modify
|
@@ -20,6 +16,9 @@
|
|
20
16
|
#
|
21
17
|
|
22
18
|
|
19
|
+
#
|
20
|
+
# Openflow message event dumper.
|
21
|
+
#
|
23
22
|
class Dumper < Controller
|
24
23
|
def switch_ready datapath_id
|
25
24
|
info "[switch_ready]"
|
@@ -33,9 +32,9 @@ class Dumper < Controller
|
|
33
32
|
end
|
34
33
|
|
35
34
|
|
36
|
-
def openflow_error message
|
35
|
+
def openflow_error datapath_id, message
|
37
36
|
info "[error]"
|
38
|
-
info "datapath_id: #{
|
37
|
+
info "datapath_id: #{ datapath_id.to_hex }"
|
39
38
|
info "transaction_id: #{ message.transaction_id.to_hex }"
|
40
39
|
info "type: #{ message.type.to_hex }"
|
41
40
|
info "code: #{ message.code.to_hex }"
|
@@ -43,9 +42,9 @@ class Dumper < Controller
|
|
43
42
|
end
|
44
43
|
|
45
44
|
|
46
|
-
def vendor message
|
45
|
+
def vendor datapath_id, message
|
47
46
|
info "[vendor]"
|
48
|
-
info "datapath_id: #{
|
47
|
+
info "datapath_id: #{ datapath_id.to_hex }"
|
49
48
|
info "transaction_id: #{ message.transaction_id.to_hex }"
|
50
49
|
info "data:"
|
51
50
|
info "#{ message.buffer.unpack "H*" }"
|
@@ -66,9 +65,9 @@ class Dumper < Controller
|
|
66
65
|
end
|
67
66
|
|
68
67
|
|
69
|
-
def get_config_reply message
|
68
|
+
def get_config_reply datapath_id, message
|
70
69
|
info "[get_config_reply]"
|
71
|
-
info "datapath_id: #{
|
70
|
+
info "datapath_id: #{ datapath_id.to_hex }"
|
72
71
|
info "transaction_id: #{ message.transaction_id.to_hex }"
|
73
72
|
info "flags: #{ message.flags.to_hex }"
|
74
73
|
info "miss_send_len: #{ message.miss_send_len }"
|
@@ -127,9 +126,9 @@ class Dumper < Controller
|
|
127
126
|
end
|
128
127
|
|
129
128
|
|
130
|
-
def stats_reply message
|
129
|
+
def stats_reply datapath_id, message
|
131
130
|
info "[stats_reply]"
|
132
|
-
info "datapath_id: #{
|
131
|
+
info "datapath_id: #{ datapath_id.to_hex }"
|
133
132
|
info "transaction_id: #{ message.transaction_id.to_hex }"
|
134
133
|
info "type: #{ message.type.to_hex }"
|
135
134
|
info "flags: #{ message.flags.to_hex }"
|
@@ -137,16 +136,16 @@ class Dumper < Controller
|
|
137
136
|
end
|
138
137
|
|
139
138
|
|
140
|
-
def barrier_reply message
|
139
|
+
def barrier_reply datapath_id, message
|
141
140
|
info "[barrier_reply]"
|
142
|
-
info "datapath_id: #{
|
141
|
+
info "datapath_id: #{ datapath_id.to_hex }"
|
143
142
|
info "transaction_id: #{ message.transaction_id.to_hex }"
|
144
143
|
end
|
145
144
|
|
146
145
|
|
147
|
-
def queue_get_config_reply message
|
146
|
+
def queue_get_config_reply datapath_id, message
|
148
147
|
info "[queue_get_config_reply]"
|
149
|
-
info "datapath_id: #{
|
148
|
+
info "datapath_id: #{ datapath_id.to_hex }"
|
150
149
|
info "transaction_id: #{ message.transaction_id.to_hex }"
|
151
150
|
info "port: #{ message.port }"
|
152
151
|
info( "queues:" );
|
data/src/lib/openflow_message.c
CHANGED
@@ -3979,19 +3979,13 @@ set_match_from_packet( struct ofp_match *match, const uint16_t in_port,
|
|
3979
3979
|
if ( !( wildcards & OFPFW_NW_PROTO ) ) {
|
3980
3980
|
match->nw_proto = ( ( packet_info * ) packet->user_data )->ipv4_protocol;
|
3981
3981
|
}
|
3982
|
-
|
3983
|
-
|
3982
|
+
unsigned int nw_src_mask_len = ( wildcards & OFPFW_NW_SRC_MASK ) >> OFPFW_NW_SRC_SHIFT;
|
3983
|
+
if ( nw_src_mask_len < 32 ) {
|
3984
|
+
match->nw_src = ( ( packet_info * ) packet->user_data )->ipv4_saddr & ( 0xffffffff << nw_src_mask_len );
|
3984
3985
|
}
|
3985
|
-
|
3986
|
-
|
3987
|
-
|
3988
|
-
}
|
3989
|
-
if ( ( wildcards & OFPFW_NW_DST_MASK ) == 0 ) {
|
3990
|
-
match->nw_dst = ( ( packet_info * ) packet->user_data )->ipv4_daddr;
|
3991
|
-
}
|
3992
|
-
else {
|
3993
|
-
match->nw_dst = ( ( packet_info * ) packet->user_data )->ipv4_daddr &
|
3994
|
-
( ( wildcards & OFPFW_NW_DST_MASK ) >> OFPFW_NW_DST_SHIFT );
|
3986
|
+
unsigned int nw_dst_mask_len = ( wildcards & OFPFW_NW_DST_MASK ) >> OFPFW_NW_DST_SHIFT;
|
3987
|
+
if ( nw_dst_mask_len < 32 ) {
|
3988
|
+
match->nw_dst = ( ( packet_info * ) packet->user_data )->ipv4_daddr & ( 0xffffffff << nw_dst_mask_len );
|
3995
3989
|
}
|
3996
3990
|
|
3997
3991
|
switch ( match->nw_proto ) {
|
@@ -4028,17 +4022,13 @@ set_match_from_packet( struct ofp_match *match, const uint16_t in_port,
|
|
4028
4022
|
if ( !( wildcards & OFPFW_NW_PROTO ) ) {
|
4029
4023
|
match->nw_proto = ( uint8_t ) ( ( ( packet_info * ) packet->user_data )->arp_ar_op & ARP_OP_MASK );
|
4030
4024
|
}
|
4031
|
-
|
4032
|
-
|
4025
|
+
unsigned int nw_src_mask_len = ( wildcards & OFPFW_NW_SRC_MASK ) >> OFPFW_NW_SRC_SHIFT;
|
4026
|
+
if ( nw_src_mask_len < 32 ) {
|
4027
|
+
match->nw_src = ( ( packet_info * ) packet->user_data )->arp_spa & ( 0xffffffff << nw_src_mask_len );
|
4033
4028
|
}
|
4034
|
-
|
4035
|
-
|
4036
|
-
|
4037
|
-
if ( ( wildcards & OFPFW_NW_DST_MASK ) == 0 ) {
|
4038
|
-
match->nw_dst = ( ( packet_info * ) packet->user_data )->arp_tpa;
|
4039
|
-
}
|
4040
|
-
else {
|
4041
|
-
match->nw_dst = ( ( packet_info * ) packet->user_data )->arp_tpa & ( ( wildcards & OFPFW_NW_DST_MASK ) >> OFPFW_NW_DST_SHIFT );
|
4029
|
+
unsigned int nw_dst_mask_len = ( wildcards & OFPFW_NW_DST_MASK ) >> OFPFW_NW_DST_SHIFT;
|
4030
|
+
if ( nw_dst_mask_len < 32 ) {
|
4031
|
+
match->nw_dst = ( ( packet_info * ) packet->user_data )->arp_tpa & ( 0xffffffff << nw_dst_mask_len );
|
4042
4032
|
}
|
4043
4033
|
}
|
4044
4034
|
}
|
@@ -5881,8 +5881,7 @@ test_set_match_from_packet_succeeds_if_datatype_is_ipv4_udp_and_wildcards_is_OFP
|
|
5881
5881
|
assert_int_equal( match.dl_type, packet_info0->eth_type );
|
5882
5882
|
assert_int_equal( match.nw_tos, ipv4->tos );
|
5883
5883
|
assert_int_equal( match.nw_proto, packet_info0->ipv4_protocol );
|
5884
|
-
|
5885
|
-
assert_int_equal( match.nw_src, ip_source_address_flag );
|
5884
|
+
assert_int_equal( match.nw_src, 0 );
|
5886
5885
|
assert_int_equal( match.nw_dst, ntohl( ipv4->daddr ) );
|
5887
5886
|
assert_int_equal( match.tp_src, ntohs( udp->src_port ) );
|
5888
5887
|
assert_int_equal( match.tp_dst, ntohs( udp->dst_port ) );
|
@@ -5912,8 +5911,7 @@ test_set_match_from_packet_succeeds_if_datatype_is_ipv4_udp_and_wildcards_is_OFP
|
|
5912
5911
|
assert_int_equal( match.nw_tos, ipv4->tos );
|
5913
5912
|
assert_int_equal( match.nw_proto, packet_info0->ipv4_protocol );
|
5914
5913
|
assert_int_equal( match.nw_src, ntohl( ipv4->saddr ) );
|
5915
|
-
|
5916
|
-
assert_int_equal( match.nw_dst, ip_destination_address_flag );
|
5914
|
+
assert_int_equal( match.nw_dst, 0 );
|
5917
5915
|
assert_int_equal( match.tp_src, ntohs( udp->src_port ) );
|
5918
5916
|
assert_int_equal( match.tp_dst, ntohs( udp->dst_port ) );
|
5919
5917
|
|
@@ -6301,8 +6299,7 @@ test_set_match_from_packet_succeeds_if_datatype_is_ipv4_tcp_and_wildcards_is_OFP
|
|
6301
6299
|
assert_int_equal( match.dl_type, packet_info0->eth_type );
|
6302
6300
|
assert_int_equal( match.nw_tos, ipv4->tos );
|
6303
6301
|
assert_int_equal( match.nw_proto, packet_info0->ipv4_protocol );
|
6304
|
-
|
6305
|
-
assert_int_equal( match.nw_src, ip_source_address_flag );
|
6302
|
+
assert_int_equal( match.nw_src, 0 );
|
6306
6303
|
assert_int_equal( match.nw_dst, ntohl( ipv4->daddr ) );
|
6307
6304
|
assert_int_equal( match.tp_src, ntohs( tcp->src_port ) );
|
6308
6305
|
assert_int_equal( match.tp_dst, ntohs( tcp->dst_port ) );
|
@@ -6332,8 +6329,7 @@ test_set_match_from_packet_succeeds_if_datatype_is_ipv4_tcp_and_wildcards_is_OFP
|
|
6332
6329
|
assert_int_equal( match.nw_tos, ipv4->tos );
|
6333
6330
|
assert_int_equal( match.nw_proto, packet_info0->ipv4_protocol );
|
6334
6331
|
assert_int_equal( match.nw_src, ntohl( ipv4->saddr ) );
|
6335
|
-
|
6336
|
-
assert_int_equal( match.nw_dst, ip_destination_address_flag );
|
6332
|
+
assert_int_equal( match.nw_dst, 0 );
|
6337
6333
|
assert_int_equal( match.tp_src, ntohs( tcp->src_port ) );
|
6338
6334
|
assert_int_equal( match.tp_dst, ntohs( tcp->dst_port ) );
|
6339
6335
|
|
@@ -6720,8 +6716,7 @@ test_set_match_from_packet_succeeds_if_datatype_is_ipv4_icmp_and_wildcards_is_OF
|
|
6720
6716
|
assert_int_equal( match.dl_type, packet_info0->eth_type );
|
6721
6717
|
assert_int_equal( match.nw_tos, ipv4->tos );
|
6722
6718
|
assert_int_equal( match.nw_proto, packet_info0->ipv4_protocol );
|
6723
|
-
|
6724
|
-
assert_int_equal( match.nw_src, ip_source_address_flag );
|
6719
|
+
assert_int_equal( match.nw_src, 0 );
|
6725
6720
|
assert_int_equal( match.nw_dst, ntohl( ipv4->daddr ) );
|
6726
6721
|
assert_int_equal( match.icmp_type, icmp->type );
|
6727
6722
|
assert_int_equal( match.icmp_code, icmp->code );
|
@@ -6751,8 +6746,7 @@ test_set_match_from_packet_succeeds_if_datatype_is_ipv4_icmp_and_wildcards_is_OF
|
|
6751
6746
|
assert_int_equal( match.nw_tos, ipv4->tos );
|
6752
6747
|
assert_int_equal( match.nw_proto, packet_info0->ipv4_protocol );
|
6753
6748
|
assert_int_equal( match.nw_src, ntohl( ipv4->saddr ) );
|
6754
|
-
|
6755
|
-
assert_int_equal( match.nw_dst, ip_destination_address_flag );
|
6749
|
+
assert_int_equal( match.nw_dst, 0 );
|
6756
6750
|
assert_int_equal( match.icmp_type, icmp->type );
|
6757
6751
|
assert_int_equal( match.icmp_code, icmp->code );
|
6758
6752
|
|
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:
|
4
|
+
hash: 31
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 4
|
10
|
+
version: 0.2.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Yasuhito Takamiya
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: .
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-07-
|
18
|
+
date: 2012-07-31 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: rake
|
@@ -700,7 +700,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
700
700
|
requirements: []
|
701
701
|
|
702
702
|
rubyforge_project:
|
703
|
-
rubygems_version: 1.8.
|
703
|
+
rubygems_version: 1.8.24
|
704
704
|
signing_key:
|
705
705
|
specification_version: 3
|
706
706
|
summary: Full-Stack OpenFlow Framework for Ruby and C
|