trema 0.3.19 → 0.3.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +7 -7
  3. data/README.md +3 -3
  4. data/Rakefile +13 -4
  5. data/cruise.rb +1 -1
  6. data/features/examples/switch_monitor.feature +2 -0
  7. data/features/switch_event/C-add_forward_entry.feature +4 -24
  8. data/features/switch_event/C-delete_forward_entry.feature +3 -18
  9. data/features/switch_event/C-dump_forward_entries.feature +2 -12
  10. data/features/switch_event/C-set_forward_entries.feature +2 -12
  11. data/features/switch_event/add_forward_entry.feature +44 -29
  12. data/features/switch_event/delete_forward_entry.feature +31 -16
  13. data/features/switch_event/dump_forward_entries.feature +23 -13
  14. data/features/switch_event/set_forward_entries.feature +17 -7
  15. data/features/trema_commands/dump_flows.feature +1 -0
  16. data/features/trema_commands/reset_stats.feature +1 -0
  17. data/features/trema_commands/show_stats.feature +1 -0
  18. data/ruby/trema/features-reply.c +9 -6
  19. data/ruby/trema/monkey-patch/integer/validators.rb +36 -0
  20. data/ruby/trema/monkey-patch/integer.rb +2 -0
  21. data/ruby/trema/packet-in.c +140 -0
  22. data/ruby/trema/packet-queue.rb +130 -126
  23. data/ruby/trema/port.c +11 -0
  24. data/ruby/trema/queue-get-config-reply.c +8 -5
  25. data/ruby/trema/set-ip-tos.rb +3 -3
  26. data/ruby/trema/vendor-action.rb +5 -1
  27. data/ruby/trema/version.rb +1 -1
  28. data/spec/trema/echo-reply_spec.rb +8 -8
  29. data/spec/trema/echo-request_spec.rb +1 -1
  30. data/spec/trema/hello_spec.rb +6 -6
  31. data/spec/trema/packet-in_spec.rb +131 -0
  32. data/spec/trema/queue-get-config-reply_spec.rb +1 -1
  33. data/spec/trema/set-ip-tos_spec.rb +5 -0
  34. data/spec/trema/vendor-action_spec.rb +5 -0
  35. data/src/examples/switch_event_config/.gitignore +0 -1
  36. data/src/examples/switch_event_config/network.conf +2 -0
  37. data/src/lib/arp.h +3 -1
  38. data/src/lib/ether.h +1 -0
  39. data/src/lib/event_forward_interface.c +9 -4
  40. data/src/lib/openflow_message.c +6 -0
  41. data/src/lib/openflow_message.h +1 -0
  42. data/src/lib/packet_info.c +23 -0
  43. data/src/lib/packet_info.h +5 -0
  44. data/src/lib/packet_parser.c +8 -3
  45. data/src/lib/utility.c +13 -13
  46. data/src/lib/utility.h +15 -0
  47. data/src/switch_manager/event_forward_entry_manipulation.c +1 -1
  48. data/src/switch_manager/secure_channel_listener.c +3 -6
  49. data/src/switch_manager/switch.c +68 -9
  50. data/trema.gemspec +4 -4
  51. data/unittests/lib/event_forward_interface_test.c +30 -0
  52. data/unittests/lib/openflow_message_test.c +19 -0
  53. data/unittests/lib/packet_info_test.c +16 -0
  54. data/unittests/lib/packet_parser_test.c +37 -0
  55. data/unittests/lib/test_packets/rarp_req.cap +0 -0
  56. metadata +9 -6
@@ -28,7 +28,7 @@ Feature: Ruby methods for setting switch event forwarding entry
28
28
 
29
29
  @slow_process
30
30
  Scenario Outline: set_forward_entries_to_switch dpid, event_type, trema_names
31
- Given a file named "nw_dsl.conf" with:
31
+ Given a file named "network.conf" with:
32
32
  """
33
33
  vswitch { datapath_id 0x1 }
34
34
  """
@@ -37,15 +37,20 @@ Feature: Ruby methods for setting switch event forwarding entry
37
37
  class SetEntriesToSwitchDaemonTest < Controller
38
38
  include SwitchEvent
39
39
 
40
+ def start
41
+ @event_type = ARGV[0].delete(":").to_sym
42
+ @event_type_string = ":#{@event_type.to_s}"
43
+ end
44
+
40
45
  def switch_ready datapath_id
41
- set_forward_entries_to_switch datapath_id, <event_type>, ["SetEntriesToSwitchDaemonTest","Another"] do | success, services |
46
+ set_forward_entries_to_switch datapath_id, @event_type, ["SetEntriesToSwitchDaemonTest","Another"] do | success, services |
42
47
  raise "Failed to set forwarding entry to switch" if not success
43
- info "Successfully set a forwarding entries of <event_type> to switch #{datapath_id.to_hex} : #{services.inspect}"
48
+ info "Successfully set a forwarding entries of #{@event_type_string} to switch #{datapath_id.to_hex} : #{services.inspect}"
44
49
  end
45
50
  end
46
51
  end
47
52
  """
48
- When I successfully run `trema run ./SetEntriesToSwitchDaemonTest.rb -c nw_dsl.conf -d`
53
+ When I successfully run `trema run "./SetEntriesToSwitchDaemonTest.rb <event_type>" -c network.conf -d`
49
54
  And wait until "SetEntriesToSwitchDaemonTest" is up
50
55
  And *** sleep 1 ***
51
56
  Then the file "../../tmp/log/SetEntriesToSwitchDaemonTest.log" should contain:
@@ -67,16 +72,21 @@ Feature: Ruby methods for setting switch event forwarding entry
67
72
  class SetEntriesToSwitchManagerTest < Controller
68
73
  include SwitchEvent
69
74
 
75
+ def start
76
+ @event_type = ARGV[0].delete(":").to_sym
77
+ @event_type_string = ":#{@event_type.to_s}"
78
+ end
79
+
70
80
  oneshot_timer_event :test_start, 0
71
81
  def test_start
72
- set_forward_entries_to_switch_manager <event_type>, ["SetEntriesToSwitchManagerTest","Another"] do | success, services |
82
+ set_forward_entries_to_switch_manager @event_type, ["SetEntriesToSwitchManagerTest","Another"] do | success, services |
73
83
  raise "Failed to set forwarding entry to switch manager" if not success
74
- info "Successfully set a forwarding entries of <event_type> to switch manager : #{services.inspect}"
84
+ info "Successfully set a forwarding entries of #{@event_type_string} to switch manager : #{services.inspect}"
75
85
  end
76
86
  end
77
87
  end
78
88
  """
79
- When I successfully run `trema run ./SetEntriesToSwitchManagerTest.rb -d`
89
+ When I successfully run `trema run "./SetEntriesToSwitchManagerTest.rb <event_type>" -d`
80
90
  And wait until "SetEntriesToSwitchManagerTest" is up
81
91
  And *** sleep 1 ***
82
92
  Then the file "../../tmp/log/SetEntriesToSwitchManagerTest.log" should contain:
@@ -22,6 +22,7 @@ Feature: dump_flows command
22
22
  @slow_process
23
23
  Scenario: dump a flow entry
24
24
  Given I run `trema send_packets --source host1 --dest host2`
25
+ And *** sleep 1 ***
25
26
  When I run `trema dump_flows repeater_hub`
26
27
  Then the output should contain "actions=FLOOD"
27
28
 
@@ -17,6 +17,7 @@ Feature: reset_stats command
17
17
  """
18
18
  And I run `trema run ../../src/examples/learning_switch/learning-switch.rb -c learning_switch.conf -d`
19
19
  And I run `trema send_packets --source host1 --dest host2`
20
+ And *** sleep 1 ***
20
21
 
21
22
  @slow_process
22
23
  Scenario: reset_stats host1
@@ -42,6 +42,7 @@ Feature: show_stats command
42
42
  @slow_process
43
43
  Scenario: show_stats hostname --rx
44
44
  When I run `trema send_packets --source host1 --dest host2`
45
+ And *** sleep 1 ***
45
46
  And I run `trema show_stats host2 --rx`
46
47
  Then the output should contain:
47
48
  """
@@ -47,7 +47,7 @@ features_reply_alloc( VALUE klass ) {
47
47
  * :n_tables => 1,
48
48
  * :capabilities => 135,
49
49
  * :actions => 2048,
50
- * :port => [ port1, port2, ... ]
50
+ * :ports => [ port1, port2, ... ]
51
51
  * )
52
52
  * @param [Hash] options
53
53
  * the options to create a message with.
@@ -67,7 +67,7 @@ features_reply_alloc( VALUE klass ) {
67
67
  * IP address lookup in APR packets.
68
68
  * @option options [Number] :actions
69
69
  * supported actions expressed as a 32-bit bitmap.
70
- * @option options [Port] :port
70
+ * @option options [Port] :ports
71
71
  * an array of {Port} objects detailing port description and function.
72
72
  * @return [FeaturesReply]
73
73
  */
@@ -305,14 +305,17 @@ handle_features_reply(
305
305
  rb_hash_aset( attributes, ID2SYM( rb_intern( "actions" ) ), UINT2NUM( actions ) );
306
306
  rb_hash_aset( attributes, ID2SYM( rb_intern( "ports" ) ), ports_from( ports ) );
307
307
 
308
- list_element *tmp_ports = xmalloc( sizeof( list_element ) );
309
- memcpy( tmp_ports, ports, sizeof( list_element ) );
310
308
  list_element *physical_ports = xmalloc( sizeof( list_element ) );
311
309
  create_list( &physical_ports );
312
- iterate_list( tmp_ports, append_physical_port, &physical_ports );
310
+ if ( ports != NULL ) {
311
+ // use memcpy() to walk over the const qualifier
312
+ list_element *tmp_ports = xmalloc( sizeof( list_element ) );
313
+ memcpy( tmp_ports, ports, sizeof( list_element ) );
314
+ iterate_list( tmp_ports, append_physical_port, &physical_ports );
315
+ xfree( tmp_ports );
316
+ }
313
317
  rb_hash_aset( attributes, ID2SYM( rb_intern( "physical_ports" ) ), ports_from( physical_ports ) );
314
318
  xfree( physical_ports );
315
- xfree( tmp_ports );
316
319
 
317
320
  VALUE features_reply = rb_funcall( cFeaturesReply, rb_intern( "new" ), 1, attributes );
318
321
  rb_funcall( ( VALUE ) controller, rb_intern( "features_reply" ), 2, ULL2NUM( datapath_id ), features_reply );
@@ -0,0 +1,36 @@
1
+ #
2
+ # Copyright (C) 2008-2013 NEC Corporation
3
+ #
4
+ # This program is free software; you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License, version 2, as
6
+ # published by the Free Software Foundation.
7
+ #
8
+ # This program is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License along
14
+ # with this program; if not, write to the Free Software Foundation, Inc.,
15
+ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16
+ #
17
+
18
+
19
+ module MonkeyPatch
20
+ module Integer
21
+ module Validators
22
+ # nw_tos (IP ToS) value consists of 8 bits, of which only the 6 high-order
23
+ # bits belong to DSCP, the 2 low-order bits must be zero.
24
+ def valid_nw_tos?
25
+ unsigned_8bit? and self % 4 == 0
26
+ end
27
+ end
28
+ end
29
+ end
30
+
31
+
32
+ ### Local variables:
33
+ ### mode: Ruby
34
+ ### coding: utf-8-unix
35
+ ### indent-tabs-mode: nil
36
+ ### End:
@@ -18,11 +18,13 @@
18
18
 
19
19
  require "trema/monkey-patch/integer/base-conversions"
20
20
  require "trema/monkey-patch/integer/ranges"
21
+ require "trema/monkey-patch/integer/validators"
21
22
 
22
23
 
23
24
  class Integer
24
25
  include MonkeyPatch::Integer::BaseConversions
25
26
  include MonkeyPatch::Integer::Ranges
27
+ include MonkeyPatch::Integer::Validators
26
28
  end
27
29
 
28
30
 
@@ -442,6 +442,137 @@ packet_in_arp_tpa( VALUE self ) {
442
442
  }
443
443
 
444
444
 
445
+ /*
446
+ * Is it an RARP packet?
447
+ *
448
+ * @return [Boolean] whether the packet is an RARP packet or not.
449
+ */
450
+ static VALUE
451
+ packet_in_is_rarp( VALUE self ) {
452
+ if ( ( get_packet_in_info( self )->format & NW_RARP ) ) {
453
+ return Qtrue;
454
+ }
455
+ else {
456
+ return Qfalse;
457
+ }
458
+ }
459
+
460
+
461
+ /*
462
+ * Is it an RARP request packet?
463
+ *
464
+ * @return [Boolean] whether the packet is an RARP request packet or not.
465
+ */
466
+ static VALUE
467
+ packet_in_is_rarp_request( VALUE self ) {
468
+ if ( packet_type_rarp_request( get_packet_in( self )->data ) ) {
469
+ return Qtrue;
470
+ }
471
+ else {
472
+ return Qfalse;
473
+ }
474
+ }
475
+
476
+
477
+ /*
478
+ * Is it an RARP reply packet?
479
+ *
480
+ * @return [Boolean] whether the packet is an RARP reply packet or not.
481
+ */
482
+ static VALUE
483
+ packet_in_is_rarp_reply( VALUE self ) {
484
+ if ( packet_type_rarp_reply( get_packet_in( self )->data ) ) {
485
+ return Qtrue;
486
+ }
487
+ else {
488
+ return Qfalse;
489
+ }
490
+ }
491
+
492
+
493
+ /*
494
+ * The RARP operation code.
495
+ *
496
+ * @return [Integer] the value of the RARP opcode field.
497
+ */
498
+ static VALUE
499
+ packet_in_rarp_oper( VALUE self ) {
500
+ PACKET_IN_RETURN_NUM( NW_RARP, UINT2NUM, arp_ar_op );
501
+ }
502
+
503
+
504
+ /*
505
+ * The RARP source hardware address of a packet.
506
+ *
507
+ * @return [Trema::Mac, nil]
508
+ * the value of the RARP source hardware address as a Trema::Mac object or nil
509
+ * if packet not an RARP.
510
+ */
511
+ static VALUE
512
+ packet_in_rarp_sha( VALUE self ) {
513
+ if ( ( get_packet_in_info( self )->format & NW_RARP ) ) {
514
+ PACKET_IN_RETURN_MAC( arp_sha );
515
+ }
516
+ else {
517
+ return Qnil;
518
+ }
519
+ }
520
+
521
+
522
+ /*
523
+ * The RARP source protocol address of a packet.
524
+ *
525
+ * @return [Trema::IP, nil]
526
+ * the value of RARP source protocol address as a Trema::IP object or nil if
527
+ * packet is not an RARP.
528
+ */
529
+ static VALUE
530
+ packet_in_rarp_spa( VALUE self ) {
531
+ if ( ( get_packet_in_info( self )->format & NW_RARP ) ) {
532
+ PACKET_IN_RETURN_IP( arp_spa );
533
+ }
534
+ else {
535
+ return Qnil;
536
+ }
537
+ }
538
+
539
+
540
+ /*
541
+ * The RARP target hardware address of a packet.
542
+ *
543
+ * @return [Trema::Mac]
544
+ * the value of RARP target hardware address as a Trema::Mac object or nil if
545
+ * packet is not an RARP.
546
+ */
547
+ static VALUE
548
+ packet_in_rarp_tha( VALUE self ) {
549
+ if ( ( get_packet_in_info( self )->format & NW_RARP ) ) {
550
+ PACKET_IN_RETURN_MAC( arp_tha );
551
+ }
552
+ else {
553
+ return Qnil;
554
+ }
555
+ }
556
+
557
+
558
+ /*
559
+ * The ARP target protocol address of a packet.
560
+ *
561
+ * @return [Trema::IP]
562
+ * the value of RARP target protocol address as a Trema::IP object or nil if
563
+ * packet is not an RARP.
564
+ */
565
+ static VALUE
566
+ packet_in_rarp_tpa( VALUE self ) {
567
+ if ( ( get_packet_in_info( self )->format & NW_RARP ) ) {
568
+ PACKET_IN_RETURN_IP( arp_tpa );
569
+ }
570
+ else {
571
+ return Qnil;
572
+ }
573
+ }
574
+
575
+
445
576
  /*
446
577
  * Is it an IPv4 packet?
447
578
  *
@@ -1121,6 +1252,7 @@ Init_packet_in() {
1121
1252
 
1122
1253
  rb_define_method( cPacketIn, "vtag?", packet_in_is_vtag, 0 );
1123
1254
  rb_define_method( cPacketIn, "arp?", packet_in_is_arp, 0 );
1255
+ rb_define_method( cPacketIn, "rarp?", packet_in_is_rarp, 0 );
1124
1256
  rb_define_method( cPacketIn, "ipv4?", packet_in_is_ipv4, 0 );
1125
1257
  rb_define_method( cPacketIn, "lldp?", packet_in_is_lldp, 0 );
1126
1258
  rb_define_method( cPacketIn, "icmpv4?", packet_in_is_icmpv4, 0 );
@@ -1142,6 +1274,14 @@ Init_packet_in() {
1142
1274
  rb_define_method( cPacketIn, "arp_request?", packet_in_is_arp_request, 0 );
1143
1275
  rb_define_method( cPacketIn, "arp_reply?", packet_in_is_arp_reply, 0 );
1144
1276
 
1277
+ rb_define_method( cPacketIn, "rarp_oper", packet_in_rarp_oper, 0 );
1278
+ rb_define_method( cPacketIn, "rarp_sha", packet_in_rarp_sha, 0 );
1279
+ rb_define_method( cPacketIn, "rarp_spa", packet_in_rarp_spa, 0 );
1280
+ rb_define_method( cPacketIn, "rarp_tha", packet_in_rarp_tha, 0 );
1281
+ rb_define_method( cPacketIn, "rarp_tpa", packet_in_rarp_tpa, 0 );
1282
+ rb_define_method( cPacketIn, "rarp_request?", packet_in_is_rarp_request, 0 );
1283
+ rb_define_method( cPacketIn, "rarp_reply?", packet_in_is_rarp_reply, 0 );
1284
+
1145
1285
  rb_define_method( cPacketIn, "ipv4_version", packet_in_ipv4_version, 0 );
1146
1286
  rb_define_method( cPacketIn, "ipv4_ihl", packet_in_ipv4_ihl, 0 );
1147
1287
  rb_define_method( cPacketIn, "ipv4_tos", packet_in_ipv4_tos, 0 );
@@ -15,157 +15,161 @@
15
15
  # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16
16
  #
17
17
 
18
-
19
- class Queue
20
- class << self
21
- #
22
- # The {PacketQueue} to append to the list.
23
- #
24
- attr_accessor :queues
25
- end
18
+ module Trema
19
+ class Queue
20
+ class << self
21
+ #
22
+ # The {PacketQueue} to append to the list.
23
+ #
24
+ attr_accessor :queues
25
+ end
26
26
 
27
27
 
28
- # Add queue to list.
29
- # @param [PacketQueue] queue a {PacketQueue} instance.
30
- def self.append queue
31
- @queues ||= []
32
- @queues << queue unless @queues.include?(queue)
33
- end
28
+ # Add queue to list.
29
+ # @param [PacketQueue] queue a {PacketQueue} instance.
30
+ def self.append queue
31
+ @queues ||= []
32
+ @queues << queue unless @queues.include?(queue)
33
+ end
34
34
 
35
35
 
36
- # @return [Array]
37
- # an array of {PacketQueue} objects.
38
- def self.queues
39
- @queues
40
- end
36
+ # @return [Array]
37
+ # an array of {PacketQueue} objects.
38
+ def self.queues
39
+ @queues
40
+ end
41
41
 
42
42
 
43
- # Iterate over each {PacketQueue} item.
44
- # @return [Array] a list of {PacketQueue} items.
45
- def self.each &block
46
- @queues.each do | each |
47
- block.call each
43
+ # Iterate over each {PacketQueue} item.
44
+ # @return [Array] a list of {PacketQueue} items.
45
+ def self.each &block
46
+ @queues.each do | each |
47
+ block.call each
48
+ end
48
49
  end
49
50
  end
50
- end
51
51
 
52
52
 
53
- class PacketQueue
54
- # No property for queue.
55
- OFPQT_NONE = 0
56
- # Minimum datarate guaranteed.
57
- OFPQT_MIN_RATE = 1
58
-
59
-
60
- # Id for the specific queue.
61
- # @return [Number] queue_id
62
- # the value of attribute queue_id.
63
- attr_accessor :queue_id
64
- # Queue description's length in bytes.
65
- # @return [Number] len
66
- # the value of attribute len.
67
- attr_accessor :len
68
- # List of queue properties.
69
- # @return [Array] properties
70
- # the value of attribute properties.
71
- attr_accessor :properties
72
-
73
-
74
- # @overload initialize(options={})
75
- # @param [Hash] options ths options hash.
76
- # @option options [Symbol] :queue_id
77
- # id for the specific queue.
78
- # @option options [Symbol] :len
79
- # queue description's length in bytes.
80
- #
81
- def initialize options
82
- @queue_id = options[ :queue_id ]
83
- @len = options[ :len ]
84
- @properties = []
85
- end
53
+ class PacketQueue
54
+ # No property for queue.
55
+ OFPQT_NONE = 0
86
56
 
57
+ # Minimum datarate guaranteed.
58
+ OFPQT_MIN_RATE = 1
87
59
 
88
- # @param [MinRateQueue] queue
89
- # a property queue {MinRateQueue} object to append to the properties list.
90
- def append queue
91
- @properties << queue
92
- end
60
+ # Id for the specific queue.
61
+ # @return [Number] queue_id
62
+ # the value of attribute queue_id.
63
+ attr_accessor :queue_id
93
64
 
65
+ # Queue description's length in bytes.
66
+ # @return [Number] len
67
+ # the value of attribute len.
68
+ attr_accessor :len
94
69
 
95
- # @return [String]
96
- # text representation of {PacketQueue}'s attributes and all its properties
97
- # queue object's attributes.
98
- def to_s
99
- str = "queue_id: #{@queue_id} len: #{@len} "
100
- @properties.each do | each |
101
- str += each.to_s
70
+ # List of queue properties.
71
+ # @return [Array] properties
72
+ # the value of attribute properties.
73
+ attr_accessor :properties
74
+
75
+
76
+ # @overload initialize(options={})
77
+ # @param [Hash] options ths options hash.
78
+ # @option options [Symbol] :queue_id
79
+ # id for the specific queue.
80
+ # @option options [Symbol] :len
81
+ # queue description's length in bytes.
82
+ #
83
+ def initialize options
84
+ @queue_id = options[ :queue_id ]
85
+ @len = options[ :len ]
86
+ @properties = []
102
87
  end
103
- str
104
- end
105
- end
106
88
 
107
89
 
108
- class QueueProperty
109
- # Property queue id.
110
- # For minimum-rate type queue the property value is set to 1, otherwise defaults
111
- # to zero.
112
- # @return [Number]
113
- # the value of attribute property.
114
- attr_accessor :property
115
- # length of property. If >= 8 minimum-rate type queue is defined.
116
- # @return [Number]
117
- # the value of attribute len.
118
- attr_accessor :len
119
-
120
-
121
- # Each queue is described by a set of properties, each of a specific type and
122
- # configuration.
123
- # @param [Number] property
124
- # property queue id.
125
- # @param [Number] len
126
- # length in bytes of the property queue.
127
- def initialize property, len
128
- @property = property
129
- @len = len
130
- end
90
+ # @param [MinRateQueue] queue
91
+ # a property queue {MinRateQueue} object to append to the properties list.
92
+ def append queue
93
+ @properties << queue
94
+ end
131
95
 
132
96
 
133
- # @return [String]
134
- # text representation of its attributes (property,len).
135
- def to_s
136
- "property: #{@property} len: #{@len} "
97
+ # @return [String]
98
+ # text representation of {PacketQueue}'s attributes and all its properties
99
+ # queue object's attributes.
100
+ def to_s
101
+ str = "queue_id: #{@queue_id} len: #{@len} "
102
+ @properties.each do | each |
103
+ str += each.to_s
104
+ end
105
+ str
106
+ end
137
107
  end
138
- end
139
108
 
140
109
 
141
- class MinRateQueue < QueueProperty
142
- # the rate value of the minimum rate queue.
143
- # @return [Number]
144
- # the value of attribute rate.
145
- attr_accessor :rate
146
-
147
-
148
- # An object that encapsulates the minimum rate queue property description.
149
- # @param [Number] property
150
- # property queue id.
151
- # @param [Number] len
152
- # length in bytes of the property queue.
153
- # @param [Number] rate
154
- # the rate value of the mimimum rate queue.
155
- # @param [PacketQueue] packet_queue
156
- # A {PacketQueue} instance to use to save the minimum rate queue.
157
- def initialize property, len, rate, packet_queue
158
- super property, len
159
- @rate = rate
160
- packet_queue.append self
161
- Queue.append packet_queue
110
+ class QueueProperty
111
+ # Property queue id.
112
+ # For minimum-rate type queue the property value is set to 1, otherwise defaults
113
+ # to zero.
114
+ # @return [Number]
115
+ # the value of attribute property.
116
+ attr_accessor :property
117
+
118
+ # length of property. If >= 8 minimum-rate type queue is defined.
119
+ # @return [Number]
120
+ # the value of attribute len.
121
+ attr_accessor :len
122
+
123
+
124
+ # Each queue is described by a set of properties, each of a specific type and
125
+ # configuration.
126
+ # @param [Number] property
127
+ # property queue id.
128
+ # @param [Number] len
129
+ # length in bytes of the property queue.
130
+ def initialize property, len
131
+ @property = property
132
+ @len = len
133
+ end
134
+
135
+
136
+ # @return [String]
137
+ # text representation of its attributes (property,len).
138
+ def to_s
139
+ "property: #{@property} len: #{@len} "
140
+ end
162
141
  end
163
142
 
164
143
 
165
- # @return [String]
166
- # text representation of rate prefixed by property and length attributes.
167
- def to_s
168
- super.to_s + " rate: #{rate} "
144
+ class MinRateQueue < QueueProperty
145
+ # the rate value of the minimum rate queue.
146
+ # @return [Number]
147
+ # the value of attribute rate.
148
+ attr_accessor :rate
149
+
150
+
151
+ # An object that encapsulates the minimum rate queue property description.
152
+ # @param [Number] property
153
+ # property queue id.
154
+ # @param [Number] len
155
+ # length in bytes of the property queue.
156
+ # @param [Number] rate
157
+ # the rate value of the mimimum rate queue.
158
+ # @param [PacketQueue] packet_queue
159
+ # A {PacketQueue} instance to use to save the minimum rate queue.
160
+ def initialize property, len, rate, packet_queue
161
+ super property, len
162
+ @rate = rate
163
+ packet_queue.append self
164
+ Trema::Queue.append packet_queue
165
+ end
166
+
167
+
168
+ # @return [String]
169
+ # text representation of rate prefixed by property and length attributes.
170
+ def to_s
171
+ super.to_s + " rate: #{rate} "
172
+ end
169
173
  end
170
174
  end
171
175
 
data/ruby/trema/port.c CHANGED
@@ -305,7 +305,18 @@ Init_port() {
305
305
  cPort = rb_define_class_under( mTrema, "Port", rb_cObject );
306
306
 
307
307
  rb_define_const( cPort, "OFPPC_PORT_DOWN", INT2NUM( OFPPC_PORT_DOWN ) );
308
+ rb_define_const( cPort, "OFPPC_NO_STP", INT2NUM( OFPPC_NO_STP ) );
309
+ rb_define_const( cPort, "OFPPC_NO_RECV", INT2NUM( OFPPC_NO_RECV ) );
310
+ rb_define_const( cPort, "OFPPC_NO_RECV_STP", INT2NUM( OFPPC_NO_RECV_STP ) );
311
+ rb_define_const( cPort, "OFPPC_NO_FLOOD", INT2NUM( OFPPC_NO_FLOOD ) );
312
+ rb_define_const( cPort, "OFPPC_NO_FWD", INT2NUM( OFPPC_NO_FWD ) );
313
+ rb_define_const( cPort, "OFPPC_NO_PACKET_IN", INT2NUM( OFPPC_NO_PACKET_IN ) );
308
314
  rb_define_const( cPort, "OFPPS_LINK_DOWN", INT2NUM( OFPPS_LINK_DOWN ) );
315
+ rb_define_const( cPort, "OFPPS_STP_LISTEN", INT2NUM( OFPPS_STP_LISTEN ) );
316
+ rb_define_const( cPort, "OFPPS_STP_LEARN", INT2NUM( OFPPS_STP_LEARN ) );
317
+ rb_define_const( cPort, "OFPPS_STP_FORWARD", INT2NUM( OFPPS_STP_FORWARD ) );
318
+ rb_define_const( cPort, "OFPPS_STP_BLOCK", INT2NUM( OFPPS_STP_BLOCK ) );
319
+ rb_define_const( cPort, "OFPPS_STP_MASK", INT2NUM( OFPPS_STP_MASK ) );
309
320
  rb_define_const( cPort, "OFPPF_10MB_HD", INT2NUM( OFPPF_10MB_HD ) );
310
321
  rb_define_const( cPort, "OFPPF_10MB_FD", INT2NUM( OFPPF_10MB_FD ) );
311
322
  rb_define_const( cPort, "OFPPF_100MB_HD", INT2NUM( OFPPF_100MB_HD ) );