trema 0.2.5 → 0.2.6

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 (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
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Unit tests for trema_private.[ch]
3
- *
3
+ *
4
4
  * Author: Yasuhito Takamiya <yasuhito@gmail.com>
5
5
  *
6
6
  * Copyright (C) 2008-2012 NEC Corporation
@@ -303,7 +303,7 @@ main() {
303
303
  unit_test_setup_teardown( test_set_trema_tmp_when_TREMA_TMP_is_NOT_set_and_TREMA_HOME_is_NOT_ROOT, reset, reset ),
304
304
  unit_test_setup_teardown( test_set_trema_tmp_falls_back_to_default_if_TREMA_TMP_is_invalid, reset, reset ),
305
305
  unit_test_setup_teardown( test_set_trema_tmp_when_TREMA_HOME_and_TREMA_TMP_are_set, reset, reset ),
306
-
306
+
307
307
  // get_trema_tmp() tests.
308
308
  unit_test_setup_teardown( test_get_trema_tmp, reset, reset ),
309
309
  unit_test_setup_teardown( test_get_trema_tmp_if_not_initialized, reset, reset ),
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Unit tests for trema.[ch]
3
- *
3
+ *
4
4
  * Author: Yasuhito Takamiya <yasuhito@gmail.com>
5
5
  *
6
6
  * Copyright (C) 2008-2012 NEC Corporation
@@ -66,6 +66,7 @@ static bool messenger_started;
66
66
  static bool messenger_flushed;
67
67
  static bool messenger_dump_started;
68
68
  static bool stat_initialized;
69
+ static bool management_interface_initialized;
69
70
 
70
71
 
71
72
  bool
@@ -329,7 +330,7 @@ mock_clock_gettime( clockid_t clk_id, struct timespec *tp ) {
329
330
 
330
331
 
331
332
  bool
332
- mock_set_external_callback( void ( *callback ) ( void ) ) {
333
+ mock_set_external_callback( void ( *callback )( void ) ) {
333
334
  UNUSED( callback );
334
335
  return true;
335
336
  }
@@ -362,6 +363,27 @@ mock_finalize_packetin_filter_interface() {
362
363
  }
363
364
 
364
365
 
366
+ bool
367
+ mock_init_management_interface() {
368
+ assert_false( management_interface_initialized );
369
+
370
+ management_interface_initialized = true;
371
+
372
+ return true;
373
+ }
374
+
375
+
376
+ bool
377
+ mock_finalize_management_interface() {
378
+ assert_true( management_interface_initialized );
379
+
380
+ management_interface_initialized = false;
381
+
382
+ return true;
383
+ }
384
+
385
+
386
+
365
387
  /********************************************************************************
366
388
  * Setup and teardown.
367
389
  ********************************************************************************/
@@ -390,6 +412,8 @@ reset_trema() {
390
412
 
391
413
  stat_initialized = false;
392
414
 
415
+ management_interface_initialized = false;
416
+
393
417
  errno = 0;
394
418
  }
395
419
 
@@ -408,6 +432,7 @@ test_init_trema_initializes_submodules_in_right_order() {
408
432
  assert_true( messenger_initialized );
409
433
  assert_true( initialized );
410
434
  assert_true( stat_initialized );
435
+ assert_true( management_interface_initialized );
411
436
  assert_string_equal( _get_trema_home(), "/" );
412
437
  assert_string_equal( _get_trema_tmp(), "/tmp" );
413
438
 
@@ -531,6 +556,7 @@ test_finalize_trema_finalizes_submodules_in_right_order() {
531
556
  assert_false( messenger_initialized );
532
557
  assert_false( initialized );
533
558
  assert_false( stat_initialized );
559
+ assert_false( management_interface_initialized );
534
560
  assert_true( _get_trema_home() == NULL );
535
561
  assert_true( _get_trema_tmp() == NULL );
536
562
  }
@@ -716,11 +742,12 @@ test_parse_help_option() {
716
742
  format,
717
743
  "Usage: %s [OPTION]...\n"
718
744
  "\n"
719
- " -n, --name=SERVICE_NAME service name\n"
720
- " -d, --daemonize run in the background\n"
721
- " -l, --logging_level=LEVEL set logging level\n"
722
- " -g, --syslog output log messages to syslog\n"
723
- " -h, --help display this help and exit\n"
745
+ " -n, --name=SERVICE_NAME service name\n"
746
+ " -d, --daemonize run in the background\n"
747
+ " -l, --logging_level=LEVEL set logging level\n"
748
+ " -g, --syslog output log messages to syslog\n"
749
+ " -f, --logging_facility=FACILITY set syslog facility\n"
750
+ " -h, --help display this help and exit\n"
724
751
  );
725
752
  expect_value( mock_exit, status, EXIT_SUCCESS );
726
753
 
@@ -740,11 +767,12 @@ test_parse_h_option() {
740
767
  format,
741
768
  "Usage: %s [OPTION]...\n"
742
769
  "\n"
743
- " -n, --name=SERVICE_NAME service name\n"
744
- " -d, --daemonize run in the background\n"
745
- " -l, --logging_level=LEVEL set logging level\n"
746
- " -g, --syslog output log messages to syslog\n"
747
- " -h, --help display this help and exit\n"
770
+ " -n, --name=SERVICE_NAME service name\n"
771
+ " -d, --daemonize run in the background\n"
772
+ " -l, --logging_level=LEVEL set logging level\n"
773
+ " -g, --syslog output log messages to syslog\n"
774
+ " -f, --logging_facility=FACILITY set syslog facility\n"
775
+ " -h, --help display this help and exit\n"
748
776
  );
749
777
  expect_value( mock_exit, status, EXIT_SUCCESS );
750
778
 
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Unit tests for utility functions.
3
- *
3
+ *
4
4
  * Author: Yasuhito Takamiya <yasuhito@gmail.com>
5
5
  *
6
6
  * Copyright (C) 2008-2012 NEC Corporation
@@ -20,6 +20,7 @@
20
20
  */
21
21
 
22
22
 
23
+ #include <arpa/inet.h>
23
24
  #include <setjmp.h>
24
25
  #include <stdarg.h>
25
26
  #include <stddef.h>
@@ -27,7 +28,6 @@
27
28
  #include <stdio.h>
28
29
  #include <stdlib.h>
29
30
  #include <string.h>
30
- #include <arpa/inet.h>
31
31
  #include "cmockery_trema.h"
32
32
  #include "log.h"
33
33
  #include "ipv4.h"
@@ -258,7 +258,7 @@ test_wildcards_to_string_fails_with_insufficient_buffer() {
258
258
  static void
259
259
  test_match_to_string() {
260
260
  char match_str[ 256 ];
261
- char expected_match_str[] = "wildcards = 0(none), in_port = 1, dl_src = 01:02:03:04:05:07, dl_dst = 08:09:0a:0b:0c:0d, dl_vlan = 1, dl_vlan_pcp = 1, dl_type = 0x800, nw_tos = 1, nw_proto = 6, nw_src = 10.9.8.7/32, nw_dst = 6.5.4.3/32, tp_src = 1024, tp_dst = 2048";
261
+ char expected_match_str[] = "wildcards = 0(none), in_port = 1, dl_src = 01:02:03:04:05:07, dl_dst = 08:09:0a:0b:0c:0d, dl_vlan = 0x1, dl_vlan_pcp = 0x1, dl_type = 0x800, nw_tos = 1, nw_proto = 6, nw_src = 10.9.8.7/32, nw_dst = 6.5.4.3/32, tp_src = 1024, tp_dst = 2048";
262
262
  struct ofp_match match = { 0, 1,
263
263
  { 0x01, 0x02, 0x03, 0x04, 0x05, 0x07 },
264
264
  { 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d },
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Unit tests for x-wrappers.
3
- *
3
+ *
4
4
  * Author: Yasuhito Takamiya <yasuhito@gmail.com>
5
5
  *
6
6
  * Copyright (C) 2008-2012 NEC Corporation
@@ -157,9 +157,9 @@ test_xstrdup_fail() {
157
157
  static char *
158
158
  test_xvasprintf_helper( const char *fmt, ... ) {
159
159
  va_list ap;
160
- va_start(ap, fmt);
160
+ va_start(ap, fmt );
161
161
  char *str = xvasprintf( fmt, ap );
162
- va_end(ap);
162
+ va_end( ap );
163
163
  return str;
164
164
  }
165
165
 
@@ -27,6 +27,7 @@
27
27
  #include "trema.h"
28
28
  #include "match_table.h"
29
29
 
30
+
30
31
  void usage();
31
32
  void handle_packet_in( uint64_t datapath_id, uint32_t transaction_id,
32
33
  uint32_t buffer_id, uint16_t total_len,
@@ -40,7 +41,7 @@ int packetin_filter_main( int argc, char *argv[] );
40
41
 
41
42
 
42
43
  /*************************************************************************
43
- * Setup and teardown function.
44
+ * Setup and teardown function.
44
45
  *************************************************************************/
45
46
 
46
47
 
@@ -80,7 +81,7 @@ mock_error( const char *format, ... ) {
80
81
  va_list args;
81
82
  va_start( args, format );
82
83
  vsnprintf( buffer, sizeof( buffer ) - 1, format, args );
83
- va_end( args );
84
+ va_end( args );
84
85
 
85
86
  check_expected( buffer );
86
87
  ( void ) mock();
@@ -231,8 +232,8 @@ test_handle_packet_in_successed() {
231
232
  will_return_void( mock_set_match_from_packet );
232
233
 
233
234
  memset( &match_entry, 0, sizeof( match_entry ) );
234
- match_entry.service_name = ( char * )( uintptr_t )( "service_name" );
235
- match_entry.entry_name = ( char * )( uintptr_t )( "entry_name" );
235
+ match_entry.service_name = ( char * ) ( uintptr_t ) ( "service_name" );
236
+ match_entry.entry_name = ( char * ) ( uintptr_t ) ( "entry_name" );
236
237
  expect_not_value( mock_lookup_match_entry, match, NULL );
237
238
  will_return( mock_lookup_match_entry, &match_entry );
238
239
 
@@ -317,8 +318,8 @@ test_handle_packet_in_send_failed() {
317
318
  will_return_void( mock_set_match_from_packet );
318
319
 
319
320
  memset( &match_entry, 0, sizeof( match_entry ) );
320
- match_entry.service_name = ( char * )( uintptr_t )( "service_name" );
321
- match_entry.entry_name = ( char * )( uintptr_t )( "entry_name" );
321
+ match_entry.service_name = ( char * ) ( uintptr_t ) ( "service_name" );
322
+ match_entry.entry_name = ( char * ) ( uintptr_t ) ( "entry_name" );
322
323
  expect_not_value( mock_lookup_match_entry, match, NULL );
323
324
  will_return( mock_lookup_match_entry, &match_entry );
324
325
 
@@ -391,9 +392,9 @@ test_packetin_filter_main_successed() {
391
392
  setup();
392
393
 
393
394
  char *argv[] = {
394
- ( char * )( uintptr_t )"packetin_filter",
395
- ( char * )( uintptr_t )"lldp::topo",
396
- ( char * )( uintptr_t )"packet_in::hub",
395
+ ( char * ) ( uintptr_t ) "packetin_filter",
396
+ ( char * ) ( uintptr_t ) "lldp::topo",
397
+ ( char * ) ( uintptr_t ) "packet_in::hub",
397
398
  NULL,
398
399
  };
399
400
  int argc = ARRAY_SIZE( argv ) - 1;
@@ -429,8 +430,8 @@ test_packetin_filter_main_invalid_match_type() {
429
430
  setup();
430
431
 
431
432
  char *argv[] = {
432
- ( char * )( uintptr_t )"packetin_filter",
433
- ( char * )( uintptr_t )"INVALID_MATCH_TYPE::dummy_service_name",
433
+ ( char * ) ( uintptr_t ) "packetin_filter",
434
+ ( char * ) ( uintptr_t ) "INVALID_MATCH_TYPE::dummy_service_name",
434
435
  NULL,
435
436
  };
436
437
  int argc = ARRAY_SIZE( argv ) - 1;
@@ -20,13 +20,13 @@
20
20
  */
21
21
 
22
22
 
23
+ #include <errno.h>
23
24
  #include <fcntl.h>
25
+ #include <netinet/tcp.h>
24
26
  #include <stdio.h>
25
27
  #include <stdlib.h>
26
28
  #include <string.h>
27
- #include <errno.h>
28
29
  #include <sys/wait.h>
29
- #include <netinet/tcp.h>
30
30
  #include "unittest.h"
31
31
  #include "trema.h"
32
32
  #include "switch_manager.h"
@@ -44,7 +44,7 @@ void wait_child( void );
44
44
 
45
45
 
46
46
  /*************************************************************************
47
- * Setup and teardown function.
47
+ * Setup and teardown function.
48
48
  *************************************************************************/
49
49
 
50
50
  static void
@@ -59,7 +59,7 @@ teardown() {
59
59
 
60
60
 
61
61
  /******************************************************************************
62
- * Mock
62
+ * Mock
63
63
  ******************************************************************************/
64
64
 
65
65
  void
@@ -101,19 +101,22 @@ mock_secure_channel_accept( struct listener_info *listener_info ) {
101
101
  ( void ) mock();
102
102
  }
103
103
 
104
+
104
105
  int
105
- mock_access( const char *pathname, int mode) {
106
+ mock_access( const char *pathname, int mode ) {
106
107
  UNUSED( pathname );
107
108
  UNUSED( mode );
108
109
 
109
110
  return ( int ) mock();
110
111
  }
111
112
 
113
+
112
114
  char *
113
115
  mock_get_current_dir_name( void ) {
114
116
  return ( char * ) mock();
115
117
  }
116
118
 
119
+
117
120
  void
118
121
  mock_init_trema( int *argc, char ***argv ) {
119
122
  UNUSED( argc );
@@ -122,6 +125,7 @@ mock_init_trema( int *argc, char ***argv ) {
122
125
  ( void ) mock();
123
126
  }
124
127
 
128
+
125
129
  void
126
130
  mock_set_fd_set_callback( void ( *callback )( fd_set *read_set, fd_set *write_set ) ) {
127
131
  UNUSED( callback );
@@ -129,6 +133,7 @@ mock_set_fd_set_callback( void ( *callback )( fd_set *read_set, fd_set *write_se
129
133
  ( void ) mock();
130
134
  }
131
135
 
136
+
132
137
  void
133
138
  mock_set_check_fd_isset_callback( void ( *callback )( fd_set *read_set, fd_set *write_set ) ) {
134
139
  UNUSED( callback );
@@ -136,6 +141,7 @@ mock_set_check_fd_isset_callback( void ( *callback )( fd_set *read_set, fd_set *
136
141
  ( void ) mock();
137
142
  }
138
143
 
144
+
139
145
  bool
140
146
  mock_secure_channel_listen_start( struct listener_info *listener_info ) {
141
147
  UNUSED( listener_info );
@@ -143,6 +149,7 @@ mock_secure_channel_listen_start( struct listener_info *listener_info ) {
143
149
  return ( bool ) mock();
144
150
  }
145
151
 
152
+
146
153
  char *
147
154
  mock_get_trema_home( void ) {
148
155
  return ( char * ) mock();
@@ -162,7 +169,7 @@ mock_get_executable_name( void ) {
162
169
 
163
170
 
164
171
  void
165
- mock_set_external_callback( void ( *callback ) ( void ) ) {
172
+ mock_set_external_callback( void ( *callback )( void ) ) {
166
173
  check_expected( callback );
167
174
  }
168
175
 
@@ -375,7 +382,7 @@ test_wait_child_wait3_zero_return() {
375
382
  static void
376
383
  test_wait_child_wait3_exit() {
377
384
  setup();
378
-
385
+
379
386
  expect_not_value( mock_wait3, status, NULL );
380
387
  expect_value( mock_wait3, options, WNOHANG );
381
388
  expect_value( mock_wait3, rusage, NULL );
@@ -587,8 +594,8 @@ test_switch_manager_main_succeeded() {
587
594
  setup();
588
595
 
589
596
  char *argv[] = {
590
- ( char * )( uintptr_t )"switch_manager",
591
- ( char * )( uintptr_t )"--switch_manager=switch_manager",
597
+ ( char * ) ( uintptr_t ) "switch_manager",
598
+ ( char * ) ( uintptr_t ) "--switch_manager=switch_manager",
592
599
  NULL,
593
600
  };
594
601
  int argc = ARRAY_SIZE( argv ) - 1;
@@ -619,8 +626,8 @@ test_switch_manager_main_and_port_option_succeeded() {
619
626
  setup();
620
627
 
621
628
  char *argv[] = {
622
- ( char * )( uintptr_t )"switch_manager",
623
- ( char * )( uintptr_t )"--port=6633",
629
+ ( char * ) ( uintptr_t ) "switch_manager",
630
+ ( char * ) ( uintptr_t ) "--port=6633",
624
631
  NULL,
625
632
  };
626
633
  int argc = ARRAY_SIZE( argv ) - 1;
@@ -651,8 +658,8 @@ test_switch_manager_main_and_port_option_failed() {
651
658
  setup();
652
659
 
653
660
  char *argv[] = {
654
- ( char * )( uintptr_t )"switch_manager",
655
- ( char * )( uintptr_t )"--port=0",
661
+ ( char * ) ( uintptr_t ) "switch_manager",
662
+ ( char * ) ( uintptr_t ) "--port=0",
656
663
  NULL,
657
664
  };
658
665
  int argc = ARRAY_SIZE( argv ) - 1;
@@ -676,8 +683,8 @@ test_switch_manager_main_help_and_exit() {
676
683
  setup();
677
684
 
678
685
  char *argv[] = {
679
- ( char * )( uintptr_t )"switch_manager",
680
- ( char * )( uintptr_t )"-x",
686
+ ( char * ) ( uintptr_t ) "switch_manager",
687
+ ( char * ) ( uintptr_t ) "-x",
681
688
  NULL,
682
689
  };
683
690
  int argc = ARRAY_SIZE( argv ) - 1;
@@ -704,7 +711,7 @@ test_switch_manager_main_get_current_dir_name_failed() {
704
711
  setup();
705
712
 
706
713
  char *argv[] = {
707
- ( char * )( uintptr_t )"switch_manager",
714
+ ( char * ) ( uintptr_t ) "switch_manager",
708
715
  NULL,
709
716
  };
710
717
  int argc = ARRAY_SIZE( argv ) - 1;
@@ -726,7 +733,7 @@ test_switch_manager_main_secure_channel_listen_start_failed() {
726
733
  setup();
727
734
 
728
735
  char *argv[] = {
729
- ( char * )( uintptr_t )"switch_manager",
736
+ ( char * ) ( uintptr_t ) "switch_manager",
730
737
  NULL,
731
738
  };
732
739
  int argc = ARRAY_SIZE( argv ) - 1;
@@ -924,7 +931,7 @@ test_secure_channel_accept_parent_succeeded() {
924
931
 
925
932
  int listen_fd = 0;
926
933
  int accept_fd = 1;
927
- int pid = 1; /* parent */
934
+ int pid = 1; /* parent */
928
935
 
929
936
  listener_info.listen_fd = listen_fd;
930
937
 
@@ -993,7 +1000,7 @@ test_secure_channel_accept_child_succeeded() {
993
1000
 
994
1001
  int listen_fd = 0;
995
1002
  int accept_fd = 3;
996
- int pid = 0; /* child */
1003
+ int pid = 0; /* child */
997
1004
 
998
1005
  listener_info.switch_manager = "switch_manager";
999
1006
  listener_info.switch_manager_argc = 0;
@@ -1058,15 +1065,15 @@ test_secure_channel_accept_child_succeeded() {
1058
1065
  static void
1059
1066
  test_secure_channel_accept_child_and_args_succeeded() {
1060
1067
  setup();
1061
-
1068
+
1062
1069
  int listen_fd = 0;
1063
1070
  int accept_fd = 3;
1064
- int pid = 0; /* child */
1071
+ int pid = 0; /* child */
1065
1072
  static char const *argv[] = { "a", "b" };
1066
1073
 
1067
1074
  listener_info.switch_manager = "switch_manager";
1068
1075
  listener_info.switch_manager_argc = 2;
1069
- listener_info.switch_manager_argv = ( char ** )( uintptr_t )argv;
1076
+ listener_info.switch_manager_argv = ( char ** ) ( uintptr_t ) argv;
1070
1077
  listener_info.listen_fd = listen_fd;
1071
1078
 
1072
1079
  expect_value( mock_accept, sockfd, listen_fd );