trema 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (292) hide show
  1. data/.gitignore +1 -1
  2. data/Doxyfile +1 -1
  3. data/Gemfile +18 -6
  4. data/README.md +112 -5
  5. data/Rakefile +3 -1
  6. data/Rantfile +88 -1
  7. data/bin/trema +248 -0
  8. data/bin/trema-config +59 -0
  9. data/cruise.rb +1 -1
  10. data/features/example.dumper.feature +45 -65
  11. data/features/example.hello_trema.feature +21 -0
  12. data/features/example.learning_switch.feature +26 -28
  13. data/features/example.list_switches.feature +19 -33
  14. data/features/example.message.echo_reply.feature +10 -10
  15. data/features/example.message.echo_request.feature +2 -2
  16. data/features/example.message.features_request.feature +6 -5
  17. data/features/example.message.hello.feature +47 -13
  18. data/features/example.message.set_config.feature +4 -4
  19. data/features/example.message.vendor-action.feature +23 -0
  20. data/features/example.multi_learning_switch.feature +14 -42
  21. data/features/example.packet_in.feature +31 -0
  22. data/features/example.packetin_filter_config.feature +11 -7
  23. data/features/example.patch_panel.feature +29 -0
  24. data/features/example.repeater_hub.feature +43 -40
  25. data/features/example.switch_info.feature +51 -0
  26. data/features/example.switch_monitor.feature +24 -42
  27. data/features/packetin_filter.feature +28 -22
  28. data/features/step_definitions/misc_steps.rb +19 -8
  29. data/features/step_definitions/send_packets_steps.rb +1 -10
  30. data/features/step_definitions/stats_steps.rb +4 -4
  31. data/features/support/env.rb +2 -1
  32. data/features/support/hooks.rb +35 -2
  33. data/features/switch_manager.feature +18 -12
  34. data/features/trema-config.feature +26 -39
  35. data/features/trema.dump_flows.feature +26 -12
  36. data/features/trema.help.feature +26 -0
  37. data/features/trema.kill.feature +39 -41
  38. data/features/trema.killall.feature +23 -23
  39. data/features/trema.reset_stats.feature +50 -10
  40. data/features/trema.run.feature +28 -39
  41. data/features/trema.send_packets.feature +29 -40
  42. data/features/trema.show_stats.feature +30 -33
  43. data/features/trema.up.feature +33 -0
  44. data/features/trema.version.feature +9 -0
  45. data/ruby/extconf.rb +7 -0
  46. data/ruby/trema/aggregate-stats-reply.rb +3 -3
  47. data/ruby/trema/app.rb +5 -1
  48. data/ruby/trema/barrier-request.c +55 -30
  49. data/ruby/trema/cli.rb +8 -8
  50. data/ruby/trema/command.rb +1 -3
  51. data/ruby/trema/command/dump_flows.rb +5 -24
  52. data/ruby/trema/command/kill.rb +31 -36
  53. data/ruby/trema/command/killall.rb +1 -19
  54. data/{features/step_definitions/kill_steps.rb → ruby/trema/command/netns.rb} +13 -5
  55. data/ruby/trema/command/reset_stats.rb +3 -23
  56. data/ruby/trema/command/ruby.rb +2 -19
  57. data/ruby/trema/command/run.rb +6 -27
  58. data/ruby/trema/command/send_packets.rb +6 -90
  59. data/ruby/trema/command/show_stats.rb +21 -40
  60. data/ruby/trema/command/up.rb +5 -26
  61. data/ruby/trema/command/version.rb +1 -5
  62. data/ruby/trema/controller.c +14 -16
  63. data/ruby/trema/custom-switch.rb +56 -0
  64. data/ruby/trema/desc-stats-reply.rb +5 -5
  65. data/ruby/trema/dsl/configuration.rb +4 -0
  66. data/{features/step_definitions/up_steps.rb → ruby/trema/dsl/custom-switch.rb} +18 -4
  67. data/ruby/trema/dsl/netns.rb +78 -0
  68. data/ruby/trema/dsl/parser.rb +2 -0
  69. data/ruby/trema/dsl/runner.rb +8 -0
  70. data/ruby/trema/dsl/syntax.rb +18 -0
  71. data/ruby/trema/echo-reply.h +2 -2
  72. data/ruby/trema/echo-request.c +3 -5
  73. data/ruby/trema/enqueue.rb +2 -2
  74. data/ruby/trema/error.c +3 -3
  75. data/ruby/trema/executables.rb +26 -2
  76. data/ruby/trema/features-request.c +3 -5
  77. data/ruby/trema/flow-removed.c +6 -6
  78. data/ruby/trema/flow-stats-reply.rb +6 -8
  79. data/ruby/trema/flow.rb +12 -1
  80. data/ruby/trema/get-config-request.c +55 -28
  81. data/ruby/trema/hello.c +3 -5
  82. data/ruby/trema/host.rb +8 -0
  83. data/ruby/trema/list-switches-reply.c +1 -1
  84. data/ruby/trema/mac.rb +1 -1
  85. data/ruby/trema/match.c +15 -14
  86. data/ruby/trema/monkey-patch/module/deprecation.rb +0 -2
  87. data/ruby/trema/netns.rb +127 -0
  88. data/ruby/trema/ordered-hash.rb +5 -4
  89. data/ruby/trema/packet-in.c +136 -113
  90. data/ruby/trema/packet-queue.rb +9 -9
  91. data/ruby/trema/packetin-filter.rb +1 -1
  92. data/ruby/trema/phost.rb +16 -7
  93. data/ruby/trema/port-mod.c +6 -5
  94. data/ruby/trema/port-stats-reply.rb +2 -2
  95. data/ruby/trema/process.rb +29 -0
  96. data/ruby/trema/queue-stats-reply.rb +2 -4
  97. data/ruby/trema/send-out-port.rb +5 -3
  98. data/ruby/trema/set-eth-addr.rb +4 -0
  99. data/ruby/trema/set-ip-addr.rb +4 -2
  100. data/ruby/trema/set-ip-dst-addr.rb +2 -1
  101. data/ruby/trema/set-ip-src-addr.rb +2 -1
  102. data/ruby/trema/set-ip-tos.rb +3 -2
  103. data/ruby/trema/set-transport-port.rb +3 -2
  104. data/ruby/trema/set-vlan-priority.rb +3 -2
  105. data/ruby/trema/set-vlan-vid.rb +5 -4
  106. data/ruby/trema/shell/reset_stats.rb +2 -1
  107. data/ruby/trema/shell/run.rb +1 -1
  108. data/ruby/trema/shell/send_packets.rb +1 -1
  109. data/ruby/trema/shell/show_stats.rb +1 -1
  110. data/ruby/trema/stats-helper.rb +3 -3
  111. data/ruby/trema/stats-reply.c +26 -17
  112. data/ruby/trema/stats-request.c +39 -41
  113. data/ruby/trema/switch-daemon.rb +36 -31
  114. data/ruby/trema/switch.c +1 -1
  115. data/ruby/trema/table-stats-reply.rb +1 -1
  116. data/ruby/trema/timers.rb +13 -13
  117. data/ruby/trema/trema.c +3 -3
  118. data/ruby/trema/tremashark.rb +9 -2
  119. data/ruby/trema/util.rb +39 -15
  120. data/ruby/trema/vendor-action.rb +8 -3
  121. data/ruby/trema/vendor-stats-reply.rb +4 -6
  122. data/ruby/trema/vendor.c +1 -1
  123. data/ruby/trema/version.rb +1 -1
  124. data/spec/trema/barrier-request_spec.rb +47 -37
  125. data/spec/trema/controller_spec.rb +1 -0
  126. data/spec/trema/dsl/runner_spec.rb +8 -3
  127. data/spec/trema/dsl/vhost_spec.rb +8 -8
  128. data/spec/trema/echo-request_spec.rb +1 -0
  129. data/spec/trema/features-request_spec.rb +1 -0
  130. data/spec/trema/flow-removed_spec.rb +9 -9
  131. data/spec/trema/get-config-request_spec.rb +51 -39
  132. data/spec/trema/match_spec.rb +1 -1
  133. data/spec/trema/openflow-error_spec.rb +11 -11
  134. data/spec/trema/packet-out_spec.rb +5 -5
  135. data/spec/trema/queue-get-config-reply_spec.rb +1 -1
  136. data/spec/trema/queue-get-config-request_spec.rb +1 -1
  137. data/spec/trema/set-eth-dst-addr_spec.rb +1 -1
  138. data/spec/trema/set-eth-src-addr_spec.rb +1 -1
  139. data/spec/trema/set-ip-dst-addr_spec.rb +1 -0
  140. data/spec/trema/set-ip-src-addr_spec.rb +1 -0
  141. data/spec/trema/set-ip-tos_spec.rb +1 -0
  142. data/spec/trema/set-transport-dst-port_spec.rb +1 -0
  143. data/spec/trema/set-transport-src-port_spec.rb +1 -0
  144. data/spec/trema/set-vlan-priority_spec.rb +1 -0
  145. data/spec/trema/set-vlan-vid_spec.rb +2 -1
  146. data/spec/trema/stats-reply_spec.rb +38 -36
  147. data/spec/trema/stats-request_spec.rb +6 -6
  148. data/spec/trema/strip-vlan-header_spec.rb +1 -0
  149. data/spec/trema/util_spec.rb +3 -2
  150. data/spec/trema/vendor-action_spec.rb +9 -8
  151. data/src/examples/dumper/dumper.c +8 -6
  152. data/src/examples/dumper/dumper.rb +1 -1
  153. data/{features/step_definitions/killall_steps.rb → src/examples/hello_trema/hello-trema.rb} +6 -5
  154. data/src/examples/hello_trema/hello_trema.c +4 -4
  155. data/src/examples/learning_switch/learning_switch.c +1 -1
  156. data/src/examples/list_switches/list_switches.c +2 -2
  157. data/src/examples/match_compare/match-compare.rb +2 -2
  158. data/src/examples/multi_learning_switch/multi-learning-switch.rb +1 -1
  159. data/src/examples/multi_learning_switch/multi_learning_switch.c +3 -3
  160. data/src/examples/openflow_message/README +1 -1
  161. data/src/examples/openflow_message/echo-request.rb +1 -1
  162. data/src/examples/openflow_message/features_request.c +21 -21
  163. data/src/examples/openflow_message/hello.c +1 -3
  164. data/src/examples/openflow_message/hello.rb +9 -24
  165. data/src/examples/{hello_trema/hello_trema.rb → openflow_message/vendor-action.rb} +17 -7
  166. data/src/examples/openflow_message/vendor_action.c +105 -0
  167. data/src/examples/openflow_switch/hello_switch.c +81 -0
  168. data/src/examples/packet_in/packet-in.rb +9 -13
  169. data/src/examples/packetin_filter_config/packetin_filter_config.c +2 -2
  170. data/src/examples/patch_panel/network.conf +14 -0
  171. data/src/examples/patch_panel/patch-panel.conf +1 -0
  172. data/{features/step_definitions/show_stats_steps.rb → src/examples/patch_panel/patch-panel.rb} +29 -13
  173. data/src/examples/switch_info/{switch_info.rb → switch-info.rb} +2 -2
  174. data/src/examples/switch_info/switch_info.c +4 -4
  175. data/src/examples/switch_monitor/switch_monitor.c +3 -3
  176. data/src/examples/traffic_monitor/counter.c +9 -9
  177. data/src/examples/traffic_monitor/fdb.c +9 -9
  178. data/src/lib/arp.h +1 -1
  179. data/src/lib/buffer.c +4 -3
  180. data/src/lib/byteorder.c +31 -5
  181. data/src/lib/byteorder.h +2 -2
  182. data/src/lib/chibach.c +8 -6
  183. data/src/lib/daemon.c +29 -3
  184. data/src/lib/doubly_linked_list.c +6 -1
  185. data/src/lib/ether.c +1 -1
  186. data/src/lib/ether.h +1 -1
  187. data/src/lib/event_handler.c +3 -3
  188. data/src/lib/hash_table.c +1 -1
  189. data/src/lib/linked_list.c +50 -2
  190. data/src/lib/linked_list.h +2 -2
  191. data/src/lib/log.c +122 -22
  192. data/src/lib/log.h +13 -9
  193. data/src/lib/management_interface.c +361 -0
  194. data/src/lib/management_interface.h +42 -0
  195. data/src/lib/management_service_interface.c +104 -0
  196. data/src/lib/management_service_interface.h +136 -0
  197. data/src/lib/match_table.c +5 -5
  198. data/src/lib/message_queue.c +5 -3
  199. data/src/lib/message_queue.h +1 -1
  200. data/src/lib/messenger.c +73 -39
  201. data/src/lib/messenger.h +3 -2
  202. data/src/lib/openflow_application_interface.c +17 -17
  203. data/src/lib/openflow_message.c +175 -23
  204. data/src/lib/openflow_message.h +2 -1
  205. data/src/lib/openflow_switch_interface.c +12 -12
  206. data/src/lib/packet_parser.c +11 -32
  207. data/src/lib/packetin_filter_interface.c +5 -5
  208. data/src/lib/persistent_storage.c +7 -7
  209. data/src/lib/secure_channel.c +6 -6
  210. data/src/lib/secure_channel.h +1 -1
  211. data/src/lib/stat.c +54 -17
  212. data/src/lib/stat.h +9 -0
  213. data/src/lib/timer.c +11 -10
  214. data/src/lib/trema.c +38 -9
  215. data/src/lib/trema.h +1 -0
  216. data/src/lib/trema_private.h +6 -0
  217. data/src/lib/trema_wrapper.c +4 -4
  218. data/src/lib/trema_wrapper.h +10 -10
  219. data/src/lib/utility.c +6 -6
  220. data/src/management/application.c +224 -0
  221. data/src/management/echo.c +185 -0
  222. data/src/management/set_logging_level.c +153 -0
  223. data/src/management/show_stats.c +150 -0
  224. data/src/management/trema_manager +184 -0
  225. data/src/packetin_filter/packetin_filter.c +31 -29
  226. data/src/switch_manager/cookie_table.c +7 -7
  227. data/src/switch_manager/dpid_table.c +3 -3
  228. data/src/switch_manager/dpid_table.h +0 -1
  229. data/src/switch_manager/management_interface.h +0 -1
  230. data/src/switch_manager/ofpmsg_recv.c +3 -3
  231. data/src/switch_manager/ofpmsg_recv.h +0 -1
  232. data/src/switch_manager/ofpmsg_send.c +2 -2
  233. data/src/switch_manager/ofpmsg_send.h +0 -1
  234. data/src/switch_manager/secure_channel_listener.c +2 -2
  235. data/src/switch_manager/secure_channel_receiver.c +2 -2
  236. data/src/switch_manager/secure_channel_receiver.h +0 -1
  237. data/src/switch_manager/secure_channel_sender.c +8 -1
  238. data/src/switch_manager/service_interface.c +5 -4
  239. data/src/switch_manager/switch.c +79 -53
  240. data/src/switch_manager/switch_manager.c +24 -22
  241. data/src/switch_manager/xid_table.c +6 -6
  242. data/src/switch_manager/xid_table.h +0 -1
  243. data/src/tremashark/README +4 -3
  244. data/src/tremashark/packet_capture.c +11 -9
  245. data/src/tremashark/pcap_queue.c +2 -2
  246. data/src/tremashark/pcap_queue.h +2 -2
  247. data/src/tremashark/plugin/packet-trema/Makefile +1 -1
  248. data/src/tremashark/plugin/packet-trema/Makefile.common +1 -1
  249. data/src/tremashark/plugin/packet-trema/packet-trema.c +50 -37
  250. data/src/tremashark/queue.c +5 -4
  251. data/src/tremashark/queue.h +1 -1
  252. data/src/tremashark/stdin_relay.c +10 -8
  253. data/src/tremashark/syslog_relay.c +14 -12
  254. data/src/tremashark/tremashark.c +15 -18
  255. data/trema +2 -96
  256. data/trema-config +2 -52
  257. data/trema.gemspec +12 -1
  258. data/unittests/cmockery_trema.h +14 -13
  259. data/unittests/lib/buffer_test.c +1 -1
  260. data/unittests/lib/byteorder_test.c +108 -25
  261. data/unittests/lib/daemon_test.c +141 -5
  262. data/unittests/lib/doubly_linked_list_test.c +5 -1
  263. data/unittests/lib/ether_test.c +4 -4
  264. data/unittests/lib/hash_table_test.c +5 -3
  265. data/unittests/lib/linked_list_test.c +82 -4
  266. data/unittests/lib/log_test.c +96 -5
  267. data/unittests/lib/management_interface_test.c +240 -0
  268. data/unittests/lib/management_service_interface_test.c +319 -0
  269. data/unittests/lib/message_queue_test.c +6 -2
  270. data/unittests/lib/messenger_test.c +167 -2
  271. data/unittests/lib/openflow_application_interface_test.c +16 -22
  272. data/unittests/lib/openflow_message_test.c +721 -24
  273. data/unittests/lib/packet_info_test.c +2 -2
  274. data/unittests/lib/packet_parser_test.c +15 -16
  275. data/unittests/lib/packetin_filter_interface_test.c +6 -6
  276. data/unittests/lib/persistent_storage_test.c +11 -11
  277. data/unittests/lib/stat_test.c +151 -7
  278. data/unittests/lib/timer_test.c +1 -1
  279. data/unittests/lib/trema_private_test.c +2 -2
  280. data/unittests/lib/trema_test.c +40 -12
  281. data/unittests/lib/utility_test.c +3 -3
  282. data/unittests/lib/wrapper_test.c +3 -3
  283. data/unittests/packetin_filter/packetin_filter_test.c +12 -11
  284. data/unittests/switch_manager/switch_manager_test.c +29 -22
  285. metadata +99 -20
  286. data/features/step_definitions/log_steps.rb +0 -90
  287. data/features/step_definitions/run_steps.rb +0 -91
  288. data/features/trema.feature +0 -27
  289. data/features/tutorial.hello_trema.feature +0 -27
  290. data/features/tutorial.packet_in.feature +0 -47
  291. data/features/tutorial.switch_info.feature +0 -55
  292. data/ruby/trema/command/usage.rb +0 -63
@@ -30,7 +30,7 @@ describe StatsReply, ".new( VALID OPTIONS )" do
30
30
  :hw_desc => "no hardware description",
31
31
  :sw_desc => "version xx.xx",
32
32
  :serial_num => "1234",
33
- :dp_desc => "nec01"
33
+ :dp_desc => "nec01"
34
34
  )
35
35
  end
36
36
 
@@ -62,14 +62,14 @@ describe StatsReply, ".new( VALID OPTIONS )" do
62
62
  :actions => actions
63
63
  )
64
64
  end
65
-
65
+
66
66
  it { should respond_to( :to_s ) }
67
67
  its ( :length ) { should == 96 }
68
68
  its ( :table_id ) { should == 0 }
69
69
  its ( :match ) { should be_an_instance_of Match }
70
70
  its ( :duration_sec ) { should == 3 }
71
71
  its ( :duration_nsec ) { should == 106000000 }
72
- its ( :priority ) { should == 65535 }
72
+ its ( :priority ) { should == 65535 }
73
73
  its ( :idle_timeout ) { should == 0 }
74
74
  its ( :hard_timeout ) { should == 0 }
75
75
  its ( :cookie ) { should == 866942928268820481 }
@@ -78,23 +78,23 @@ describe StatsReply, ".new( VALID OPTIONS )" do
78
78
  its ( :actions ) { should_not be_empty }
79
79
  end
80
80
 
81
-
81
+
82
82
  context "when aggregate-stats-reply is created" do
83
83
  subject do
84
84
  AggregateStatsReply.new(
85
85
  :packet_count => 2,
86
86
  :byte_count => 128,
87
- :flow_count => 10
87
+ :flow_count => 10
88
88
  )
89
89
  end
90
-
90
+
91
91
  it { should respond_to( :to_s ) }
92
92
  its( :packet_count ) { should == 2 }
93
93
  its( :byte_count ) { should == 128 }
94
94
  its ( :flow_count ) { should == 10 }
95
95
  end
96
-
97
-
96
+
97
+
98
98
  context "when table-stats-reply is created" do
99
99
  subject do
100
100
  TableStatsReply.new(
@@ -107,7 +107,7 @@ describe StatsReply, ".new( VALID OPTIONS )" do
107
107
  :matched_count => 1
108
108
  )
109
109
  end
110
-
110
+
111
111
  it { should respond_to( :to_s ) }
112
112
  its( :table_id ) { should == 1 }
113
113
  its( :name ) { should eq( "classifier" ) }
@@ -117,8 +117,8 @@ describe StatsReply, ".new( VALID OPTIONS )" do
117
117
  its( :lookup_count ) { should == 4 }
118
118
  its( :matched_count ) { should == 1 }
119
119
  end
120
-
121
-
120
+
121
+
122
122
  context "when port-stats-reply is created" do
123
123
  subject do
124
124
  PortStatsReply.new(
@@ -137,7 +137,7 @@ describe StatsReply, ".new( VALID OPTIONS )" do
137
137
  :collisions => 1
138
138
  )
139
139
  end
140
-
140
+
141
141
  it { should respond_to( :to_s ) }
142
142
  its( :port_no ) { should == 1 }
143
143
  its( :rx_packets ) { should == 7 }
@@ -154,7 +154,7 @@ describe StatsReply, ".new( VALID OPTIONS )" do
154
154
  its( :collisions ) { should == 1 }
155
155
  end
156
156
 
157
-
157
+
158
158
  context "when queue-stats-reply is created" do
159
159
  subject do
160
160
  QueueStatsReply.new(
@@ -162,10 +162,10 @@ describe StatsReply, ".new( VALID OPTIONS )" do
162
162
  :queue_id => 2,
163
163
  :tx_bytes => 1024,
164
164
  :tx_packets => 16,
165
- :tx_errors => 5
165
+ :tx_errors => 5
166
166
  )
167
167
  end
168
-
168
+
169
169
  it { should respond_to( :to_s ) }
170
170
  its( :port_no ) { should == 1 }
171
171
  its( :queue_id ) { should == 2 }
@@ -173,16 +173,16 @@ describe StatsReply, ".new( VALID OPTIONS )" do
173
173
  its( :tx_packets ) { should == 16 }
174
174
  its( :tx_errors ) { should == 5 }
175
175
  end
176
-
177
-
176
+
177
+
178
178
  context "when vendor-stats-reply is created" do
179
179
  subject { VendorStatsReply.new( :vendor_id => 123 ) }
180
180
 
181
181
  it { should respond_to( :to_s ) }
182
182
  its( :vendor_id ) { should == 123 }
183
183
  end
184
-
185
-
184
+
185
+
186
186
  context "when #stats_request(desc-stats) is sent" do
187
187
  it "should #stats_reply(desc-stats)" do
188
188
  class DescStatsController < Controller; end
@@ -190,13 +190,13 @@ describe StatsReply, ".new( VALID OPTIONS )" do
190
190
  vswitch( "desc-stats" ) { datapath_id 0xabc }
191
191
  }.run( DescStatsController ) {
192
192
  controller( "DescStatsController" ).should_receive( :stats_reply ) do | datapath_id, message |
193
- datapath_id.should == 0xabc
193
+ datapath_id.should == 0xabc
194
194
  message.type.should == 0
195
195
  message.stats[ 0 ].mfr_desc.should eq( "Nicira Networks, Inc." )
196
196
  message.stats[ 0 ].hw_desc.should eq( "Open vSwitch" )
197
197
  message.stats[ 0 ].should respond_to :to_s
198
198
  end
199
-
199
+
200
200
  controller( "DescStatsController" ).send_message( 0xabc,
201
201
  DescStatsRequest.new( :transaction_id => 1234 ) )
202
202
  sleep 2 # FIXME: wait to send_message
@@ -216,11 +216,11 @@ describe StatsReply, ".new( VALID OPTIONS )" do
216
216
  link "host2", "flow-stats"
217
217
  }.run( FlowStatsController ) {
218
218
  controller( "FlowStatsController" ).send_flow_mod_add(
219
- 0xabc,
219
+ 0xabc,
220
220
  # match the UDP packet
221
221
  :match => Match.new( :dl_type => 0x800, :nw_proto => 17 ),
222
222
  # flood the packet
223
- :actions => ActionOutput.new( :port => FlowStatsController::OFPP_FLOOD )
223
+ :actions => ActionOutput.new( :port => FlowStatsController::OFPP_FLOOD )
224
224
  )
225
225
  sleep 1 # FIXME: wait to send_flow_mod_add
226
226
  # send two packets
@@ -240,8 +240,8 @@ describe StatsReply, ".new( VALID OPTIONS )" do
240
240
  }
241
241
  end
242
242
  end
243
-
244
-
243
+
244
+
245
245
  context "when #stats_request(aggregate_stats) is sent" do
246
246
  it "should #stats_reply(aggregate-stats) attributes" do
247
247
  class AggregateStatsController < Controller; end
@@ -257,7 +257,7 @@ describe StatsReply, ".new( VALID OPTIONS )" do
257
257
  # match the UDP packet
258
258
  :match => Match.new( :dl_type => 0x800, :nw_proto => 17 ),
259
259
  # flood the packet
260
- :actions => ActionOutput.new( :port => AggregateStatsController::OFPP_FLOOD )
260
+ :actions => ActionOutput.new( :port => AggregateStatsController::OFPP_FLOOD )
261
261
  )
262
262
  sleep 1 # FIXME: wait to send_flow_mod_add
263
263
  # send ten packets
@@ -278,8 +278,8 @@ describe StatsReply, ".new( VALID OPTIONS )" do
278
278
  }
279
279
  end
280
280
  end
281
-
282
-
281
+
282
+
283
283
  context "when #stats_request(port-stats) is sent" do
284
284
  it "should #stats_reply(port-stats)" do
285
285
  class PortStatsController < Controller; end
@@ -293,15 +293,16 @@ describe StatsReply, ".new( VALID OPTIONS )" do
293
293
  controller( "PortStatsController" ).send_flow_mod_add(
294
294
  0xabc,
295
295
  :match => Match.new( :dl_type => 0x800, :nw_proto => 17 ),
296
- :actions => ActionOutput.new( :port => PortStatsController::OFPP_FLOOD )
296
+ :actions => ActionOutput.new( :port => PortStatsController::OFPP_FLOOD )
297
297
  )
298
+ sleep 1 # FIXME: wait to send_flow_mod_add
298
299
  send_packets "host1", "host2"
299
300
  sleep 2 # FIXME: wait to send_packets
300
-
301
+
301
302
  controller( "PortStatsController" ).should_receive( :stats_reply ) do | datapath_id, message |
302
303
  datapath_id.should == 0xabc
303
304
  message.type.should == 4
304
- message.stats[ 0 ].should be_an_instance_of(Trema::PortStatsReply)
305
+ message.stats[ 0 ].should be_an_instance_of( Trema::PortStatsReply )
305
306
  message.stats[ 0 ].should respond_to :to_s
306
307
  end
307
308
  controller( "PortStatsController" ).send_message( 0xabc,
@@ -310,8 +311,8 @@ describe StatsReply, ".new( VALID OPTIONS )" do
310
311
  }
311
312
  end
312
313
  end
313
-
314
-
314
+
315
+
315
316
  context "when #stats_request(table-stats) is sent" do
316
317
  it "should #stats_reply(table-stats)" do
317
318
  class TableStatsController < Controller; end
@@ -322,13 +323,14 @@ describe StatsReply, ".new( VALID OPTIONS )" do
322
323
  link "host1", "table-stats"
323
324
  link "host2", "table-stats"
324
325
  }.run( TableStatsController) {
325
- controller( "TableStatsController" ).send_flow_mod_add(
326
+ controller( "TableStatsController" ).send_flow_mod_add(
326
327
  0xabc,
327
- :actions => ActionOutput.new( :port => TableStatsController::OFPP_FLOOD )
328
+ :actions => ActionOutput.new( :port => TableStatsController::OFPP_FLOOD )
328
329
  )
330
+ sleep 1 # FIXME: wait to send_flow_mod_add
329
331
  send_packets "host1", "host2"
330
332
  sleep 2 # FIXME: wait to send_packets
331
-
333
+
332
334
  controller( "TableStatsController" ).should_receive( :stats_reply ) do | datapath_id, message |
333
335
  datapath_id.should == 0xabc
334
336
  message.type.should == 3
@@ -38,7 +38,7 @@ describe StatsRequest do
38
38
  context "when .FlowStatsRequest.new( MANDATORY OPTION MISSING )" do
39
39
  subject { FlowStatsRequest.new }
40
40
  it "should raise ArgumentError" do
41
- expect { subject }.to raise_error( ArgumentError )
41
+ expect { subject }.to raise_error( ArgumentError )
42
42
  end
43
43
  end
44
44
 
@@ -53,8 +53,8 @@ describe StatsRequest do
53
53
 
54
54
 
55
55
  context "when .FlowStatsRequest.new( VALID OPTIONS )" do
56
- subject do
57
- FlowStatsRequest.new(
56
+ subject do
57
+ FlowStatsRequest.new(
58
58
  :match => Match.new( :dl_type => 0x800, :nw_proto => 17 ),
59
59
  :table_id => 1,
60
60
  :out_port => 2
@@ -70,7 +70,7 @@ describe StatsRequest do
70
70
  context "when .AggregateStatsRequest.new( MANDATORY OPTION MISSING )" do
71
71
  subject { AggregateStatsRequest.new }
72
72
  it "should raise ArgumentError" do
73
- expect { subject }.to raise_error( ArgumentError )
73
+ expect { subject }.to raise_error( ArgumentError )
74
74
  end
75
75
  end
76
76
 
@@ -85,8 +85,8 @@ describe StatsRequest do
85
85
 
86
86
 
87
87
  context "when .AggregateStatsRequest.new( VALID OPTIONS )" do
88
- subject do
89
- AggregateStatsRequest.new(
88
+ subject do
89
+ AggregateStatsRequest.new(
90
90
  :match => Match.new( :dl_type => 0x800, :nw_proto => 17 ),
91
91
  :table_id => 1,
92
92
  :out_port => 2
@@ -28,6 +28,7 @@ describe StripVlanHeader, ".new" do
28
28
  vswitch { datapath_id 0xabc }
29
29
  }.run( FlowModAddController ) {
30
30
  controller( "FlowModAddController" ).send_flow_mod_add( 0xabc, :actions => StripVlanHeader.new )
31
+ sleep 2 # FIXME: wait to send_flow_mod_add
31
32
  vswitch( "0xabc" ).should have( 1 ).flows
32
33
  vswitch( "0xabc" ).flows[ 0 ].actions.should match( /strip_vlan/ )
33
34
  }
@@ -28,11 +28,11 @@ include Trema::Util
28
28
 
29
29
 
30
30
  describe Trema::Util do
31
- it "should check the sanity of trema" do
31
+ it "should assert that trema is built" do
32
32
  Trema::Executables.stub!( :compiled? ).and_return( false )
33
33
  $stderr.should_receive( :puts ).with( /^ERROR/ )
34
34
  lambda do
35
- sanity_check
35
+ assert_trema_is_built
36
36
  end.should raise_error( SystemExit )
37
37
  end
38
38
 
@@ -70,6 +70,7 @@ describe Trema::Util do
70
70
  last_session.stub!( :switches ).and_return( switches )
71
71
  last_session.stub!( :hosts ).and_return( hosts )
72
72
  last_session.stub!( :links ).and_return( links )
73
+ last_session.stub!( :netnss ).and_return( {} )
73
74
  Trema::DSL::Context.stub!( :load_current ).and_return( last_session )
74
75
 
75
76
  pid_files = [ mock( "PID file #0" ), mock( "PID file #1" ), mock( "PID file #2" ) ]
@@ -44,24 +44,25 @@ end
44
44
 
45
45
  describe VendorAction, ".new( vendor_id, body )" do
46
46
  subject { VendorAction.new vendor_id, body }
47
- let( :vendor_id ) { 0x00004cff }
47
+ let( :vendor_id ) { 0x00002320 }
48
48
 
49
- context %{when body == "deadbeef".unpack( "C*" )} do
50
- let( :body ) { "deadbeef".unpack( "C*" ) }
49
+ context %{when body == [ 0x00, 0x08, 0x54, 0x72, 0x65, 0x6d, 0x61, 0x00 ]} do
50
+ let( :body ) { [ 0x00, 0x08, 0x54, 0x72, 0x65, 0x6d, 0x61, 0x00 ] }
51
51
 
52
- its( :vendor_id ) { should == 0x00004cff }
53
- its( :body ) { should == [ 100, 101, 97, 100, 98, 101, 101, 102 ] }
52
+ its( :vendor_id ) { should == 0x00002320 }
53
+ its( :body ) { should == [ 0, 8, 84, 114, 101, 109, 97, 0 ] }
54
54
 
55
55
  context "when sending Flow Mod Add with action set to VendorAction" do
56
56
  it "should have a flow with action set to VendorAction" do
57
57
  class FlowModAddController < Controller; end
58
- pending "Use Nicira's vendor ID and body"
59
58
  network {
60
59
  vswitch { datapath_id 0xabc }
61
60
  }.run( FlowModAddController ) {
62
- controller( "FlowModAddController" ).send_flow_mod_add( 0xabc, :actions => VendorAction.new( 0x00004cff, "deadbeef".unpack( "C*" ) ) )
61
+ body = [ 0x00, 0x08, 0x54, 0x72, 0x65, 0x6d, 0x61, 0x00 ]
62
+ controller( "FlowModAddController" ).send_flow_mod_add( 0xabc, :actions => VendorAction.new( 0x00002320, body ) )
63
+ sleep 2 # FIXME: wait to send_flow_mod_add
63
64
  vswitch( "0xabc" ).should have( 1 ).flows
64
- vswitch( "0xabc" ).flows[ 0 ].actions.should match( /mod_vendor/ )
65
+ vswitch( "0xabc" ).flows[ 0 ].actions.should match( /note:54.72.65.6d.61.00/ )
65
66
  }
66
67
  end
67
68
  end
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Sample OpenFlow event dumper.
3
- *
3
+ *
4
4
  * Author: Yasunobu Chiba
5
5
  *
6
6
  * Copyright (C) 2008-2012 NEC Corporation
@@ -36,10 +36,12 @@ usage() {
36
36
  "OpenFlow Event Dumper.\n"
37
37
  "Usage: %s [OPTION]...\n"
38
38
  "\n"
39
- " -n, --name=SERVICE_NAME service name\n"
40
- " -d, --daemonize run in the background\n"
41
- " -l, --logging_level=LEVEL set logging level\n"
42
- " -h, --help display this help and exit\n"
39
+ " -n, --name=SERVICE_NAME service name\n"
40
+ " -d, --daemonize run in the background\n"
41
+ " -l, --logging_level=LEVEL set logging level\n"
42
+ " -g, --syslog output log messages to syslog\n"
43
+ " -f, --logging_facility=FACILITY set syslog facility\n"
44
+ " -h, --help display this help and exit\n"
43
45
  , get_executable_name()
44
46
  );
45
47
  }
@@ -325,7 +327,7 @@ handle_queue_get_config_reply( uint64_t datapath_id, uint32_t transaction_id,
325
327
  }
326
328
 
327
329
  xfree( queues_head );
328
- }
330
+ }
329
331
 
330
332
 
331
333
  int
@@ -160,7 +160,7 @@ class Dumper < Controller
160
160
 
161
161
  def dump_phy_port port
162
162
  # for testing port-status record the mac address if port.number == 2.
163
- @hw_addr = port.hw_addr if port.number == 2
163
+ @hw_addr = port.hw_addr if port.number == 2
164
164
  info "port_no: #{ port.number }"
165
165
  info " hw_addr: #{ port.hw_addr }"
166
166
  info " name: #{ port.name }"
@@ -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
@@ -18,13 +16,16 @@
18
16
  #
19
17
 
20
18
 
21
- Given /^I terminated all trema services$/ do
22
- run "./trema killall"
19
+ class HelloTrema < Controller
20
+ def switch_ready datapath_id
21
+ info "Hello %#x!" % datapath_id
22
+ shutdown!
23
+ end
23
24
  end
24
25
 
25
26
 
26
27
  ### Local variables:
27
28
  ### mode: Ruby
28
- ### coding: utf-8-unix
29
+ ### coding: utf-8
29
30
  ### indent-tabs-mode: nil
30
31
  ### End:
@@ -1,6 +1,4 @@
1
1
  /*
2
- * Hello trema world!
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
@@ -24,7 +22,9 @@
24
22
 
25
23
  static void
26
24
  handle_switch_ready( uint64_t datapath_id, void *user_data ) {
27
- info( "Hello %#" PRIx64 " from %s!", datapath_id, user_data );
25
+ UNUSED( user_data );
26
+
27
+ info( "Hello %#" PRIx64 "!", datapath_id );
28
28
  stop_trema();
29
29
  }
30
30
 
@@ -33,7 +33,7 @@ int
33
33
  main( int argc, char *argv[] ) {
34
34
  init_trema( &argc, &argv );
35
35
 
36
- set_switch_ready_handler( handle_switch_ready, argv[ 0 ] );
36
+ set_switch_ready_handler( handle_switch_ready, NULL );
37
37
 
38
38
  start_trema();
39
39
 
@@ -20,8 +20,8 @@
20
20
  */
21
21
 
22
22
 
23
- #include <time.h>
24
23
  #include <assert.h>
24
+ #include <time.h>
25
25
  #include "trema.h"
26
26
 
27
27
 
@@ -28,7 +28,7 @@ join( char *result, const list_element *switches ) {
28
28
  const list_element *element;
29
29
  for ( element = switches; element != NULL; element = element->next ) {
30
30
  char tmp[ 19 ]; // "0x" + 64bits in hex + '\0'
31
- snprintf( tmp, sizeof( tmp ), "%#" PRIx64, * ( uint64_t *) element->data );
31
+ snprintf( tmp, sizeof( tmp ), "%#" PRIx64, *( uint64_t * ) element->data );
32
32
  strcat( result, tmp );
33
33
  strcat( result, comma );
34
34
  }
@@ -66,7 +66,7 @@ main( int argc, char *argv[] ) {
66
66
  init_trema( &argc, &argv );
67
67
  add_periodic_event_callback( 30, timeout, NULL );
68
68
 
69
- add_periodic_event_callback( 2, ( void ( * ) ( void * ) )send_list_switches_request, NULL );
69
+ add_periodic_event_callback( 2, ( void ( * )( void * ) ) send_list_switches_request, NULL );
70
70
  set_list_switches_reply_handler( handle_list_switches_reply );
71
71
 
72
72
  start_trema();