trema 0.3.12 → 0.3.13

Sign up to get free protection for your applications and to get access to all the features.
data/bin/trema CHANGED
@@ -21,7 +21,6 @@
21
21
 
22
22
  $LOAD_PATH.unshift File.expand_path( File.join File.dirname( __FILE__ ), "..", "ruby" )
23
23
 
24
-
25
24
  require "rubygems"
26
25
 
27
26
  require "gli"
@@ -30,257 +29,274 @@ require "trema/util"
30
29
  require "trema/version"
31
30
 
32
31
 
33
- include GLI::App
34
- include Trema::Util
35
- include Trema::Command
32
+ class BinTrema
33
+ include Trema::Command
34
+ include Trema::Util
35
+ include GLI::App
36
36
 
37
37
 
38
- program_desc "Trema command-line tool"
38
+ def initialize
39
+ program_desc "Trema command-line tool"
39
40
 
40
41
 
41
- desc "Displays the current runtime version"
42
- version Trema::VERSION
42
+ desc "Displays the current runtime version"
43
+ version Trema::VERSION
43
44
 
44
45
 
45
- desc "Be verbose"
46
- switch [ :v, :verbose ], :negatable => false
46
+ desc "Be verbose"
47
+ switch [ :v, :verbose ], :negatable => false
47
48
 
48
49
 
49
- desc "Runs a trema application"
50
- arg_name "controller"
51
- command :run do | c |
52
- c.desc "Runs as a daemon"
53
- c.switch [ :d, :daemonize ], :negatable => false
50
+ desc "Runs a trema application"
51
+ arg_name "controller"
52
+ command :run do | c |
53
+ c.desc "Runs as a daemon"
54
+ c.switch [ :d, :daemonize ], :negatable => false
54
55
 
55
- c.desc "Enables Trema wireshark plugin"
56
- c.switch [ :s, :tremashark ], :negatable => false
56
+ c.desc "Enables Trema wireshark plugin"
57
+ c.switch [ :s, :tremashark ], :negatable => false
57
58
 
58
- c.desc "Specifies emulated network configuration"
59
- c.flag [ :c, :conf ]
59
+ c.desc "Specifies emulated network configuration"
60
+ c.flag [ :c, :conf ]
60
61
 
61
- c.action do | global_options, options, args |
62
- trema_run options
63
- end
64
- end
62
+ c.action do | global_options, options, args |
63
+ trema_run options
64
+ end
65
+ end
65
66
 
66
67
 
67
- desc "Terminates a trema process"
68
- arg_name "name"
69
- command :kill do | c |
70
- c.action do | global_options, options, args |
71
- help_now!( "name is required" ) if args.empty?
72
- args.each do | each |
73
- trema_kill each
68
+ desc "Terminates a trema process"
69
+ arg_name "name"
70
+ command :kill do | c |
71
+ c.action do | global_options, options, args |
72
+ help_now!( "name is required" ) if args.empty?
73
+ args.each do | each |
74
+ trema_kill each
75
+ end
76
+ end
74
77
  end
75
- end
76
- end
77
78
 
78
79
 
79
- desc "Starts a killed trema process again"
80
- arg_name "name"
81
- command :up do | c |
82
- c.action do | global_options, options, args |
83
- trema_up args[ 0 ]
84
- end
85
- end
80
+ desc "Starts a killed trema process again"
81
+ arg_name "name"
82
+ command :up do | c |
83
+ c.action do | global_options, options, args |
84
+ trema_up args[ 0 ]
85
+ end
86
+ end
86
87
 
87
88
 
88
- desc "Terminates all trema processes"
89
- command :killall do | c |
90
- c.action do
91
- trema_killall
92
- end
93
- end
89
+ desc "Terminates all trema processes"
90
+ command :killall do | c |
91
+ c.action do
92
+ trema_killall
93
+ end
94
+ end
94
95
 
95
96
 
96
- desc "Sends UDP packets to destination host"
97
- command :send_packets do | c |
98
- c.desc "host that sends packets"
99
- c.flag [ :s, :source ]
97
+ desc "Sends UDP packets to destination host"
98
+ command :send_packets do | c |
99
+ c.desc "host that sends packets"
100
+ c.flag [ :s, :source ]
100
101
 
101
- c.desc "host that receives packets"
102
- c.flag [ :d, :dest ]
102
+ c.desc "host that receives packets"
103
+ c.flag [ :d, :dest ]
103
104
 
104
- c.desc "number of times to increment the IP source address"
105
- c.default_value nil
106
- c.flag [ :inc_ip_src ]
105
+ c.desc "number of times to increment the IP source address"
106
+ c.default_value nil
107
+ c.flag [ :inc_ip_src ]
107
108
 
108
- c.desc "number of times to increment the IP destination address"
109
- c.default_value nil
110
- c.flag [ :inc_ip_dst ]
109
+ c.desc "number of times to increment the IP destination address"
110
+ c.default_value nil
111
+ c.flag [ :inc_ip_dst ]
111
112
 
112
- c.desc "set the initial UDP source port"
113
- c.flag [ :tp_src ]
113
+ c.desc "set the initial UDP source port"
114
+ c.flag [ :tp_src ]
114
115
 
115
- c.desc "number of times to increment the UDP source port"
116
- c.default_value nil
117
- c.flag [ :inc_tp_src ]
116
+ c.desc "number of times to increment the UDP source port"
117
+ c.default_value nil
118
+ c.flag [ :inc_tp_src ]
118
119
 
119
- c.desc "set the initial UDP destination port"
120
- c.flag [ :tp_dst ]
120
+ c.desc "set the initial UDP destination port"
121
+ c.flag [ :tp_dst ]
121
122
 
122
- c.desc "number of times to increment the UDP destination port"
123
- c.default_value nil
124
- c.flag [ :inc_tp_dst ]
123
+ c.desc "number of times to increment the UDP destination port"
124
+ c.default_value nil
125
+ c.flag [ :inc_tp_dst ]
125
126
 
126
- c.desc "send packet rate - packets per second"
127
- c.flag [ :pps ]
127
+ c.desc "send packet rate - packets per second"
128
+ c.flag [ :pps ]
128
129
 
129
- c.desc "number of packets to send"
130
- c.flag [ :n_pkts ]
130
+ c.desc "number of packets to send"
131
+ c.flag [ :n_pkts ]
131
132
 
132
- c.desc "time duration to send packets"
133
- c.flag [ :duration ]
133
+ c.desc "time duration to send packets"
134
+ c.flag [ :duration ]
134
135
 
135
- c.desc "length of UDP payload"
136
- c.flag [ :length ]
136
+ c.desc "length of UDP payload"
137
+ c.flag [ :length ]
137
138
 
138
- c.desc "increment UDP payload"
139
- c.default_value nil
140
- c.flag [ :inc_payload ]
139
+ c.desc "increment UDP payload"
140
+ c.default_value nil
141
+ c.flag [ :inc_payload ]
141
142
 
142
- c.action do | global_options, options, args |
143
- raise "--source option is mandatory" if options[ :source ].nil?
144
- raise "--dest option is mandatory" if options[ :dest ].nil?
143
+ c.action do | global_options, options, args |
144
+ raise "--source option is mandatory" if options[ :source ].nil?
145
+ raise "--dest option is mandatory" if options[ :dest ].nil?
145
146
 
146
- trema_send_packets options[ :source ], options[ :dest ], options
147
- end
148
- end
147
+ trema_send_packets options[ :source ], options[ :dest ], options
148
+ end
149
+ end
149
150
 
150
151
 
151
- desc "Brings a switch's specified port up"
152
- command :port_up do | c |
153
- c.desc "switch name"
154
- c.flag [ :s, :switch ]
152
+ desc "Brings a switch's specified port up"
153
+ command :port_up do | c |
154
+ c.desc "switch name"
155
+ c.flag [ :s, :switch ]
155
156
 
156
- c.desc "port"
157
- c.flag [ :p, :port ]
157
+ c.desc "port"
158
+ c.flag [ :p, :port ]
158
159
 
159
- c.action do | global_options, options, args |
160
- raise "--switch option is mandatory" if options[ :switch ].nil?
161
- raise "--port option is mandatory" if options[ :port ].nil?
160
+ c.action do | global_options, options, args |
161
+ raise "--switch option is mandatory" if options[ :switch ].nil?
162
+ raise "--port option is mandatory" if options[ :port ].nil?
162
163
 
163
- trema_port_up options[ :switch ], options[ :port ]
164
- end
165
- end
164
+ trema_port_up options[ :switch ], options[ :port ]
165
+ end
166
+ end
166
167
 
167
168
 
168
- desc "Brings a switch's specified port down"
169
- command :port_down do | c |
170
- c.desc "switch name"
171
- c.flag [ :s, :switch ]
169
+ desc "Brings a switch's specified port down"
170
+ command :port_down do | c |
171
+ c.desc "switch name"
172
+ c.flag [ :s, :switch ]
172
173
 
173
- c.desc "port"
174
- c.flag [ :p, :port ]
174
+ c.desc "port"
175
+ c.flag [ :p, :port ]
175
176
 
176
- c.action do | global_options, options, args |
177
- raise "--switch option is mandatory" if options[ :switch ].nil?
178
- raise "--port option is mandatory" if options[ :port ].nil?
177
+ c.action do | global_options, options, args |
178
+ raise "--switch option is mandatory" if options[ :switch ].nil?
179
+ raise "--port option is mandatory" if options[ :port ].nil?
179
180
 
180
- trema_port_down options[ :switch ], options[ :port ]
181
- end
182
- end
181
+ trema_port_down options[ :switch ], options[ :port ]
182
+ end
183
+ end
183
184
 
184
185
 
185
- desc "Shows stats of packets"
186
- arg_name "host"
187
- command :show_stats do | c |
188
- c.desc "Show stats of packets sent"
189
- c.switch [ :t, :tx ], :negatable => false
190
- c.desc "Show stats of packets received"
191
- c.switch [ :r, :rx ], :negatable => false
186
+ desc "Shows stats of packets"
187
+ arg_name "host"
188
+ command :show_stats do | c |
189
+ c.desc "Show stats of packets sent"
190
+ c.switch [ :t, :tx ], :negatable => false
191
+ c.desc "Show stats of packets received"
192
+ c.switch [ :r, :rx ], :negatable => false
192
193
 
193
- c.action do | global_options, options, args |
194
- help_now!( "host is required" ) if args.empty?
195
- trema_show_stats args[ 0 ], options[ :tx ], options[ :rx ]
196
- end
197
- end
194
+ c.action do | global_options, options, args |
195
+ help_now!( "host is required" ) if args.empty?
196
+ trema_show_stats args[ 0 ], options[ :tx ], options[ :rx ]
197
+ end
198
+ end
198
199
 
199
200
 
200
- desc "Resets stats of packets"
201
- arg_name "hosts..."
202
- command :reset_stats do | c |
203
- c.action do | global_options, options, args |
204
- hosts = args
205
- if hosts.empty?
206
- hosts = Trema::DSL::Context.load_current.hosts.keys
201
+ desc "Resets stats of packets"
202
+ arg_name "hosts..."
203
+ command :reset_stats do | c |
204
+ c.action do | global_options, options, args |
205
+ hosts = args
206
+ if hosts.empty?
207
+ hosts = Trema::DSL::Context.load_current.hosts.keys
208
+ end
209
+ hosts.each do | each |
210
+ trema_reset_stats each
211
+ end
212
+ end
207
213
  end
208
- hosts.each do | each |
209
- trema_reset_stats each
214
+
215
+
216
+ desc "Print all flow entries"
217
+ arg_name "switches..."
218
+ command :dump_flows do | c |
219
+ c.action do | global_options, options, args |
220
+ help_now!( "switches is required" ) if args.empty?
221
+ trema_dump_flows args
222
+ end
210
223
  end
211
- end
212
- end
213
224
 
214
225
 
215
- desc "Print all flow entries"
216
- arg_name "switches..."
217
- command :dump_flows do | c |
218
- c.action do | global_options, options, args |
219
- help_now!( "switches is required" ) if args.empty?
220
- trema_dump_flows args
221
- end
222
- end
226
+ desc "Opens a new shell in the specified network namespace"
227
+ arg_name "name"
228
+ command :netns do | c |
229
+ c.action do | global_options, options, args |
230
+ trema_netns args[ 0 ]
231
+ end
232
+ end
223
233
 
224
234
 
225
- desc "Opens a new shell in the specified network namespace"
226
- arg_name "name"
227
- command :netns do | c |
228
- c.action do | global_options, options, args |
229
- trema_netns args[ 0 ]
230
- end
231
- end
235
+ desc "Opens in your browser Trema's Ruby API documentation"
236
+ command :ruby do | c |
237
+ c.action do
238
+ trema_ruby
239
+ end
240
+ end
232
241
 
233
242
 
234
- desc "Opens in your browser Trema's Ruby API documentation"
235
- command :ruby do | c |
236
- c.action do
237
- trema_ruby
238
- end
239
- end
243
+ desc "Displays the current runtime version"
244
+ command :version do | c |
245
+ c.action do
246
+ trema_version
247
+ end
248
+ end
240
249
 
241
250
 
242
- desc "Displays the current runtime version"
243
- command :version do | c |
244
- c.action do
245
- trema_version
246
- end
247
- end
251
+ GLI::Commands::Help.skips_pre = false
248
252
 
249
253
 
250
- GLI::Commands::Help.skips_pre = false
254
+ pre do | global, command, options, args |
255
+ $verbose = global[ :verbose ]
251
256
 
257
+ if global[ :version ]
258
+ trema_version
259
+ exit_now! nil, 0
260
+ end
252
261
 
253
- pre do | global, command, options, args |
254
- $verbose = global[ :verbose ]
262
+ assert_trema_is_built
255
263
 
256
- if global[ :version ]
257
- trema_version
258
- exit_now! nil, 0
259
- end
264
+ if FileTest.exist?( Trema.tmp ) and not FileTest.writable?( Trema.tmp )
265
+ # Trema is system widely installed with gem command
266
+ sh "sudo chmod o+w -R #{ Trema.tmp }"
267
+ end
260
268
 
261
- assert_trema_is_built
269
+ FileUtils.mkdir_p Trema.log
270
+ FileUtils.mkdir_p Trema.pid
271
+ FileUtils.mkdir_p Trema.sock
262
272
 
263
- if FileTest.exist?( Trema.tmp ) and not FileTest.writable?( Trema.tmp )
264
- # Trema is system widely installed with gem command
265
- sh "sudo chmod o+w -R #{ Trema.tmp }"
266
- end
273
+ true
274
+ end
267
275
 
268
- FileUtils.mkdir_p Trema.log
269
- FileUtils.mkdir_p Trema.pid
270
- FileUtils.mkdir_p Trema.sock
271
276
 
272
- true
273
- end
277
+ on_error do | exception |
278
+ # Error logic here
279
+ # return false to skip default error handling
280
+ true
281
+ end
282
+ end
274
283
 
275
284
 
276
- on_error do | exception |
277
- # Error logic here
278
- # return false to skip default error handling
279
- true
285
+ def start argv
286
+ begin
287
+ run argv
288
+ rescue
289
+ puts $!
290
+ $!.backtrace.each do | each |
291
+ puts each
292
+ end
293
+ exit
294
+ end
295
+ end
280
296
  end
281
297
 
282
298
 
283
- exit run( ARGV )
299
+ exit BinTrema.new.start( ARGV )
284
300
 
285
301
 
286
302
  ### Local variables:
@@ -72,7 +72,7 @@ module Trema
72
72
  controller_file = ARGV[ 0 ].split.first
73
73
  if ruby_controller?
74
74
  require "trema"
75
- include Trema
75
+ Object.__send__ :include, Trema
76
76
  ARGV.replace ARGV[ 0 ].split[ 1..-1 ]
77
77
  $LOAD_PATH << File.dirname( controller_file )
78
78
  load controller_file
@@ -68,7 +68,7 @@ features_reply_alloc( VALUE klass ) {
68
68
  * @option options [Number] :actions
69
69
  * supported actions expressed as a 32-bit bitmap.
70
70
  * @option options [Port] :port
71
- * an array of {Port} objects detailing physical port description and function.
71
+ * an array of {Port} objects detailing port description and function.
72
72
  * @return [FeaturesReply]
73
73
  */
74
74
  static VALUE
@@ -117,8 +117,6 @@ features_reply_init( VALUE self, VALUE options ) {
117
117
  features_reply->actions = htonl( ( uint32_t ) NUM2UINT( tmp ) );
118
118
  }
119
119
 
120
- // TODO: ports
121
-
122
120
  rb_iv_set( self, "@attribute", options );
123
121
 
124
122
  return self;
@@ -203,7 +201,7 @@ features_reply_actions( VALUE self ) {
203
201
 
204
202
 
205
203
  /*
206
- * An array of {Port} objects detailing physical port description and function.
204
+ * An array of {Port} objects detailing port description and function.
207
205
  *
208
206
  * @return [Array<Port>] the value of ports.
209
207
  */
@@ -213,6 +211,17 @@ features_reply_ports( VALUE self ) {
213
211
  }
214
212
 
215
213
 
214
+ /*
215
+ * An array of {Port} objects detailing physical port description and function.
216
+ *
217
+ * @return [Array<Port>] the value of ports.
218
+ */
219
+ static VALUE
220
+ features_reply_physical_ports( VALUE self ) {
221
+ return rb_hash_aref( rb_iv_get( self, "@attribute" ), ID2SYM( rb_intern( "physical_ports" ) ) );
222
+ }
223
+
224
+
216
225
  void
217
226
  Init_features_reply() {
218
227
  mTrema = rb_define_module( "Trema" );
@@ -227,6 +236,7 @@ Init_features_reply() {
227
236
  rb_define_method( cFeaturesReply, "capabilities", features_reply_capabilities, 0 );
228
237
  rb_define_method( cFeaturesReply, "actions", features_reply_actions, 0 );
229
238
  rb_define_method( cFeaturesReply, "ports", features_reply_ports, 0 );
239
+ rb_define_method( cFeaturesReply, "physical_ports", features_reply_physical_ports, 0 );
230
240
  }
231
241
 
232
242
 
@@ -242,11 +252,15 @@ handle_switch_ready( uint64_t datapath_id, void *controller ) {
242
252
  * Extract and map {Port} to +ofp_phy_port+ structure.
243
253
  */
244
254
  static VALUE
245
- ports_from( const list_element *phy_ports ) {
255
+ ports_from( const list_element *c_ports ) {
246
256
  VALUE ports = rb_ary_new();
247
257
 
258
+ if ( c_ports == NULL ) {
259
+ return ports;
260
+ }
261
+
248
262
  list_element *port_head = xmalloc( sizeof( list_element ) );
249
- memcpy( port_head, phy_ports, sizeof( list_element ) );
263
+ memcpy( port_head, c_ports, sizeof( list_element ) );
250
264
  list_element *port = NULL;
251
265
  for ( port = port_head; port != NULL; port = port->next ) {
252
266
  rb_ary_push( ports, port_from( ( struct ofp_phy_port * ) port->data ) );
@@ -256,6 +270,14 @@ ports_from( const list_element *phy_ports ) {
256
270
  }
257
271
 
258
272
 
273
+ static void
274
+ append_physical_port( void *port, void *physical_ports ) {
275
+ if ( ( ( struct ofp_phy_port * ) port )->port_no <= OFPP_MAX ) {
276
+ append_to_tail( ( list_element ** ) physical_ports, port );
277
+ }
278
+ }
279
+
280
+
259
281
  void
260
282
  handle_features_reply(
261
283
  uint64_t datapath_id,
@@ -264,7 +286,7 @@ handle_features_reply(
264
286
  uint8_t n_tables,
265
287
  uint32_t capabilities,
266
288
  uint32_t actions,
267
- const list_element *phy_ports,
289
+ const list_element *ports,
268
290
  void *controller
269
291
  ) {
270
292
  if ( rb_respond_to( ( VALUE ) controller, rb_intern( "features_reply" ) ) == Qfalse ) {
@@ -278,7 +300,16 @@ handle_features_reply(
278
300
  rb_hash_aset( attributes, ID2SYM( rb_intern( "n_tables" ) ), UINT2NUM( n_tables ) );
279
301
  rb_hash_aset( attributes, ID2SYM( rb_intern( "capabilities" ) ), UINT2NUM( capabilities ) );
280
302
  rb_hash_aset( attributes, ID2SYM( rb_intern( "actions" ) ), UINT2NUM( actions ) );
281
- rb_hash_aset( attributes, ID2SYM( rb_intern( "ports" ) ), ports_from( phy_ports ) );
303
+ rb_hash_aset( attributes, ID2SYM( rb_intern( "ports" ) ), ports_from( ports ) );
304
+
305
+ list_element *tmp_ports = xmalloc( sizeof( list_element ) );
306
+ memcpy( tmp_ports, ports, sizeof( list_element ) );
307
+ list_element *physical_ports = xmalloc( sizeof( list_element ) );
308
+ create_list( &physical_ports );
309
+ iterate_list( tmp_ports, append_physical_port, &physical_ports );
310
+ rb_hash_aset( attributes, ID2SYM( rb_intern( "physical_ports" ) ), ports_from( physical_ports ) );
311
+ xfree( physical_ports );
312
+ xfree( tmp_ports );
282
313
 
283
314
  VALUE features_reply = rb_funcall( cFeaturesReply, rb_intern( "new" ), 1, attributes );
284
315
  rb_funcall( ( VALUE ) controller, rb_intern( "features_reply" ), 2, ULL2NUM( datapath_id ), features_reply );
@@ -593,6 +593,22 @@ packet_in_ipv4_daddr( VALUE self ) {
593
593
  }
594
594
 
595
595
 
596
+ /*
597
+ * Is it a LLDP packet?
598
+ *
599
+ * @return [Boolean] whether the packet is a LLDP packet or not.
600
+ */
601
+ static VALUE
602
+ packet_in_is_lldp( VALUE self ) {
603
+ if ( ( get_packet_in_info( self )->format & NW_LLDP ) ) {
604
+ return Qtrue;
605
+ }
606
+ else {
607
+ return Qfalse;
608
+ }
609
+ }
610
+
611
+
596
612
  /*
597
613
  * Is it an ICMPv4 packet?
598
614
  *
@@ -1103,6 +1119,7 @@ Init_packet_in() {
1103
1119
  rb_define_method( cPacketIn, "vtag?", packet_in_is_vtag, 0 );
1104
1120
  rb_define_method( cPacketIn, "arp?", packet_in_is_arp, 0 );
1105
1121
  rb_define_method( cPacketIn, "ipv4?", packet_in_is_ipv4, 0 );
1122
+ rb_define_method( cPacketIn, "lldp?", packet_in_is_lldp, 0 );
1106
1123
  rb_define_method( cPacketIn, "icmpv4?", packet_in_is_icmpv4, 0 );
1107
1124
  rb_define_method( cPacketIn, "igmp?", packet_in_is_igmp, 0 );
1108
1125
  rb_define_method( cPacketIn, "tcp?", packet_in_is_tcp, 0 );
@@ -17,7 +17,7 @@
17
17
 
18
18
 
19
19
  module Trema
20
- VERSION = "0.3.12"
20
+ VERSION = "0.3.13"
21
21
  end
22
22
 
23
23
 
@@ -131,6 +131,7 @@ describe Trema::PacketIn do
131
131
  expect( message.vtag? ).to be_false
132
132
  expect( message.arp? ).to be_true
133
133
  expect( message.ipv4? ).to be_false
134
+ expect( message.lldp? ).to be_false
134
135
  expect( message.tcp? ).to be_false
135
136
  expect( message.udp? ).to be_false
136
137
  expect( message.icmpv4? ).to be_false
@@ -241,6 +242,7 @@ describe Trema::PacketIn do
241
242
  expect( message.vtag? ).to be_false
242
243
  expect( message.arp? ).to be_false
243
244
  expect( message.ipv4? ).to be_true
245
+ expect( message.lldp? ).to be_false
244
246
  expect( message.udp? ).to be_false
245
247
  expect( message.tcp? ).to be_true
246
248
  expect( message.icmpv4? ).to be_false
@@ -324,6 +326,7 @@ describe Trema::PacketIn do
324
326
  expect( message.vtag? ).to be_false
325
327
  expect( message.arp? ).to be_false
326
328
  expect( message.ipv4? ).to be_true
329
+ expect( message.lldp? ).to be_false
327
330
  expect( message.tcp? ).to be_false
328
331
  expect( message.udp? ).to be_true
329
332
  expect( message.icmpv4? ).to be_false
@@ -404,6 +407,7 @@ describe Trema::PacketIn do
404
407
  expect( message.vtag? ).to be_true
405
408
  expect( message.arp? ).to be_false
406
409
  expect( message.ipv4? ).to be_true
410
+ expect( message.lldp? ).to be_false
407
411
  expect( message.udp? ).to be_false
408
412
  expect( message.tcp? ).to be_false
409
413
  expect( message.icmpv4? ).to be_true
@@ -487,6 +491,7 @@ describe Trema::PacketIn do
487
491
  expect( message.vtag? ).to be_false
488
492
  expect( message.arp? ).to be_false
489
493
  expect( message.ipv4? ).to be_true
494
+ expect( message.lldp? ).to be_false
490
495
  expect( message.udp? ).to be_false
491
496
  expect( message.tcp? ).to be_false
492
497
  expect( message.icmpv4? ).to be_false
@@ -523,6 +528,50 @@ describe Trema::PacketIn do
523
528
  }
524
529
  end
525
530
 
531
+ it "should have correct LLDP packet fields" do
532
+ network {
533
+ vswitch( "packet-in" ) { datapath_id 0xabc }
534
+ vhost "host1"
535
+ vhost "host2"
536
+ link "host1", "packet-in"
537
+ link "host2", "packet-in"
538
+ }.run( PacketInSendController ) {
539
+ data = [
540
+ 0x01, 0x80, 0xC2, 0x00, 0x00, 0x0E, # dst
541
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, # src
542
+ 0x88, 0xcc, # ether type
543
+ 0x02, 0x05, 0x07, 0x30, 0x78, 0x65, 0x31, # Chasis ID
544
+ 0x04, 0x02, 0x07, 0x31, # Port ID
545
+ 0x06, 0x02, 0x00, 0xb4, # TTL
546
+ 0x00, 0x00, # EOF
547
+ 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5,
548
+ 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5,
549
+ 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5,
550
+ 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5,
551
+ 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5,
552
+ 0xa5, 0xa5, 0xa5, 0xa5, 0xa5
553
+ ].pack( "C*" )
554
+ controller( "PacketInSendController" ).should_receive( :packet_in ) do | datapath_id, message |
555
+ expect( message.in_port ).to be > 0
556
+ expect( message.vtag? ).to be_false
557
+ expect( message.arp? ).to be_false
558
+ expect( message.ipv4? ).to be_false
559
+ expect( message.lldp? ).to be_true
560
+ expect( message.udp? ).to be_false
561
+ expect( message.tcp? ).to be_false
562
+ expect( message.icmpv4? ).to be_false
563
+ expect( message.igmp? ).to be_false
564
+ end
565
+
566
+ controller( "PacketInSendController" ).send_packet_out(
567
+ 0xabc,
568
+ :data => data,
569
+ :actions => Trema::ActionOutput.new( :port => Controller::OFPP_CONTROLLER )
570
+ )
571
+ sleep 2
572
+ }
573
+ end
574
+
526
575
  end
527
576
 
528
577
  end
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: 11
4
+ hash: 9
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 12
10
- version: 0.3.12
9
+ - 13
10
+ version: 0.3.13
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: 2013-02-15 00:00:00 Z
18
+ date: 2013-02-18 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  prerelease: false
@@ -31,8 +31,8 @@ dependencies:
31
31
  - 2
32
32
  - 3
33
33
  version: 1.2.3
34
- requirement: *id001
35
34
  type: :runtime
35
+ requirement: *id001
36
36
  - !ruby/object:Gem::Dependency
37
37
  prerelease: false
38
38
  name: gli
@@ -47,8 +47,8 @@ dependencies:
47
47
  - 5
48
48
  - 4
49
49
  version: 2.5.4
50
- requirement: *id002
51
50
  type: :runtime
51
+ requirement: *id002
52
52
  - !ruby/object:Gem::Dependency
53
53
  prerelease: false
54
54
  name: rake
@@ -63,8 +63,8 @@ dependencies:
63
63
  - 0
64
64
  - 3
65
65
  version: 10.0.3
66
- requirement: *id003
67
66
  type: :runtime
67
+ requirement: *id003
68
68
  - !ruby/object:Gem::Dependency
69
69
  prerelease: false
70
70
  name: rdoc
@@ -79,8 +79,8 @@ dependencies:
79
79
  - 12
80
80
  - 1
81
81
  version: 3.12.1
82
- requirement: *id004
83
82
  type: :runtime
83
+ requirement: *id004
84
84
  description: Trema is a full-stack, easy-to-use framework for developing OpenFlow controllers in Ruby and C.
85
85
  email:
86
86
  - yasuhito@gmail.com
@@ -787,7 +787,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
787
787
  requirements: []
788
788
 
789
789
  rubyforge_project:
790
- rubygems_version: 1.8.24
790
+ rubygems_version: 1.8.25
791
791
  signing_key:
792
792
  specification_version: 3
793
793
  summary: Full-stack OpenFlow framework.