trema 0.2.2.1 → 0.2.3

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 (250) hide show
  1. data/.gitmodules +3 -0
  2. data/.travis.yml +13 -0
  3. data/.yardopts +4 -0
  4. data/Gemfile +2 -3
  5. data/README.md +43 -97
  6. data/Rakefile +60 -4
  7. data/Rantfile +11 -10
  8. data/cruise.rb +4 -6
  9. data/features/example.packetin_filter_config.feature +10 -10
  10. data/features/example.switch_monitor.feature +14 -2
  11. data/features/step_definitions/kill_steps.rb +2 -2
  12. data/features/step_definitions/{off_steps.rb → killall_steps.rb} +2 -2
  13. data/features/step_definitions/misc_steps.rb +1 -1
  14. data/features/step_definitions/up_steps.rb +30 -0
  15. data/features/trema.feature +1 -0
  16. data/features/trema.run.feature +1 -0
  17. data/locale/README.ja.md +19 -0
  18. data/locale/ja/yard.po +3762 -0
  19. data/locale/yard.pot +3740 -0
  20. data/ruby/extconf.rb +4 -1
  21. data/ruby/trema/action-common.c +3 -17
  22. data/ruby/trema/action-common.h +3 -7
  23. data/ruby/trema/action.rb +33 -0
  24. data/ruby/trema/app.rb +1 -1
  25. data/ruby/trema/barrier-request.c +1 -0
  26. data/ruby/trema/command/run.rb +13 -9
  27. data/ruby/trema/command/usage.rb +1 -0
  28. data/ruby/trema/command/version.rb +1 -1
  29. data/ruby/trema/controller.c +133 -50
  30. data/ruby/trema/controller.rb +2 -2
  31. data/ruby/trema/desc-stats-reply.rb +77 -0
  32. data/ruby/trema/dsl/configuration.rb +3 -14
  33. data/ruby/trema/dsl/rswitch.rb +47 -0
  34. data/ruby/trema/dsl/runner.rb +4 -1
  35. data/ruby/trema/dsl/syntax.rb +11 -8
  36. data/ruby/trema/echo-reply.c +59 -45
  37. data/ruby/trema/echo-reply.h +1 -3
  38. data/ruby/trema/echo-request.c +49 -71
  39. data/ruby/trema/echo-request.h +0 -2
  40. data/ruby/trema/echo.c +99 -0
  41. data/ruby/trema/{action-enqueue.h → echo.h} +6 -7
  42. data/ruby/trema/enqueue.rb +87 -0
  43. data/ruby/trema/error.c +109 -104
  44. data/ruby/trema/error.h +0 -2
  45. data/ruby/trema/features-reply.c +89 -35
  46. data/ruby/trema/features-reply.h +0 -6
  47. data/ruby/trema/features-request.c +63 -37
  48. data/ruby/trema/features-request.h +0 -2
  49. data/ruby/trema/flow-mod.c +149 -0
  50. data/ruby/trema/{action-output.h → flow-mod.h} +6 -6
  51. data/ruby/trema/get-config-request.c +1 -0
  52. data/ruby/trema/hardware-switch.rb +88 -0
  53. data/ruby/trema/hello.c +55 -31
  54. data/ruby/trema/hello.h +0 -2
  55. data/ruby/trema/ip.rb +12 -2
  56. data/ruby/trema/logger.rb +29 -0
  57. data/ruby/trema/mac.rb +57 -36
  58. data/ruby/trema/match.c +7 -9
  59. data/ruby/trema/monkey-patch/integer/ranges.rb +0 -2
  60. data/ruby/trema/network-component.rb +1 -1
  61. data/ruby/trema/open-vswitch.rb +2 -2
  62. data/ruby/trema/openflow-switch.rb +3 -54
  63. data/ruby/trema/{packet_in.c → packet-in.c} +262 -175
  64. data/ruby/trema/{packet_in.h → packet-in.h} +0 -2
  65. data/ruby/trema/packet-queue.rb +4 -3
  66. data/ruby/trema/port-mod.c +8 -9
  67. data/ruby/trema/port-status-add.rb +60 -0
  68. data/ruby/trema/port-status-delete.rb +60 -0
  69. data/ruby/trema/port-status-modify.rb +60 -0
  70. data/ruby/trema/port-status.c +48 -15
  71. data/ruby/trema/port-status.h +6 -8
  72. data/ruby/trema/port.c +63 -8
  73. data/ruby/trema/queue-get-config-request.c +1 -0
  74. data/ruby/trema/ruby-switch.rb +62 -0
  75. data/ruby/trema/send-out-port.rb +97 -0
  76. data/ruby/trema/set-config.c +1 -0
  77. data/ruby/trema/set-eth-addr.rb +45 -0
  78. data/ruby/trema/set-eth-dst-addr.rb +54 -0
  79. data/ruby/trema/set-eth-src-addr.rb +54 -0
  80. data/ruby/trema/set-ip-addr.rb +47 -0
  81. data/ruby/trema/set-ip-dst-addr.rb +53 -0
  82. data/ruby/trema/set-ip-src-addr.rb +52 -0
  83. data/ruby/trema/set-ip-tos.rb +63 -0
  84. data/ruby/trema/set-transport-dst-port.rb +53 -0
  85. data/ruby/trema/set-transport-port.rb +52 -0
  86. data/ruby/trema/set-transport-src-port.rb +54 -0
  87. data/ruby/trema/set-vlan-priority.rb +65 -0
  88. data/ruby/trema/set-vlan-vid.rb +64 -0
  89. data/ruby/trema/shell/down.rb +1 -1
  90. data/ruby/trema/shell/link.rb +4 -4
  91. data/ruby/trema/shell/run.rb +8 -6
  92. data/ruby/trema/shell/up.rb +3 -3
  93. data/ruby/trema/stats-reply.c +27 -2
  94. data/ruby/trema/stats-request.c +64 -23
  95. data/ruby/trema/strip-vlan-header.rb +41 -0
  96. data/ruby/trema/switch.c +196 -0
  97. data/ruby/trema/{action-vendor.h → switch.h} +5 -7
  98. data/ruby/trema/switch.rb +28 -9
  99. data/ruby/trema/trema-ruby-utils.c +66 -0
  100. data/ruby/trema/{action-set-dl-src.h → trema-ruby-utils.h} +9 -11
  101. data/ruby/trema/trema.c +61 -61
  102. data/ruby/trema/vendor-action.rb +73 -0
  103. data/ruby/trema/vendor.c +121 -52
  104. data/ruby/trema/vendor.h +6 -10
  105. data/ruby/trema/version.rb +1 -1
  106. data/spec/spec_helper.rb +1 -1
  107. data/spec/support/action.rb +52 -0
  108. data/spec/support/mandatory-option.rb +56 -0
  109. data/spec/support/openflow-message.rb +91 -7
  110. data/spec/support/port-status.rb +38 -0
  111. data/spec/trema/controller_spec.rb +0 -26
  112. data/spec/trema/dsl/configuration_spec.rb +3 -3
  113. data/spec/trema/dsl/runner_spec.rb +12 -32
  114. data/spec/trema/dsl/syntax_spec.rb +2 -11
  115. data/spec/trema/echo-reply_spec.rb +49 -14
  116. data/spec/trema/echo-request_spec.rb +86 -34
  117. data/spec/trema/enqueue_spec.rb +76 -0
  118. data/spec/trema/error_spec.rb +43 -58
  119. data/spec/trema/features-reply_spec.rb +58 -24
  120. data/spec/trema/features-request_spec.rb +54 -28
  121. data/spec/trema/flow-mod_spec.rb +99 -0
  122. data/spec/trema/{openflow-switch_spec.rb → hardware-switch_spec.rb} +3 -3
  123. data/spec/trema/hello_spec.rb +28 -14
  124. data/spec/trema/ip_spec.rb +54 -0
  125. data/spec/trema/mac_spec.rb +49 -64
  126. data/spec/trema/match_spec.rb +1 -1
  127. data/spec/trema/open-vswitch_spec.rb +7 -7
  128. data/spec/trema/packet-in_spec.rb +73 -16
  129. data/spec/trema/port-status-add_spec.rb +32 -0
  130. data/spec/trema/port-status-delete_spec.rb +32 -0
  131. data/spec/trema/port-status-modify_spec.rb +71 -0
  132. data/spec/trema/port-status_spec.rb +5 -76
  133. data/spec/trema/{action-output_spec.rb → send-out-port_spec.rb} +20 -47
  134. data/spec/trema/set-eth-dst-addr_spec.rb +75 -0
  135. data/spec/trema/set-eth-src-addr_spec.rb +72 -0
  136. data/spec/trema/set-ip-dst-addr_spec.rb +58 -0
  137. data/spec/trema/set-ip-src-addr_spec.rb +58 -0
  138. data/spec/trema/set-ip-tos_spec.rb +65 -0
  139. data/spec/trema/set-transport-dst-port_spec.rb +65 -0
  140. data/spec/trema/set-transport-src-port_spec.rb +65 -0
  141. data/spec/trema/set-vlan-priority_spec.rb +65 -0
  142. data/spec/trema/set-vlan-vid_spec.rb +65 -0
  143. data/spec/trema/shell/vhost_spec.rb +4 -1
  144. data/spec/trema/shell/vswitch_spec.rb +11 -11
  145. data/spec/trema/stats-reply_spec.rb +59 -13
  146. data/spec/trema/stats-request_spec.rb +6 -0
  147. data/spec/trema/{action-strip-vlan_spec.rb → strip-vlan-header_spec.rb} +3 -17
  148. data/spec/trema/switch-daemon_spec.rb +39 -0
  149. data/spec/trema/vendor-action_spec.rb +81 -0
  150. data/spec/trema/vendor_spec.rb +76 -0
  151. data/spec/trema_spec.rb +56 -0
  152. data/src/examples/dumper/dumper.c +0 -8
  153. data/src/examples/dumper/dumper.rb +52 -52
  154. data/src/examples/hello_trema/hello_trema.c +0 -2
  155. data/src/examples/learning_switch/learning-switch.rb +3 -3
  156. data/src/examples/multi_learning_switch/multi-learning-switch.rb +3 -3
  157. data/src/examples/openflow_message/features-request.rb +3 -3
  158. data/src/examples/packetin_filter_config/utils.c +4 -4
  159. data/src/examples/repeater_hub/repeater-hub.rb +3 -3
  160. data/src/examples/switch_info/switch_info.rb +2 -2
  161. data/src/examples/switch_monitor/switch_monitor.c +1 -1
  162. data/src/examples/traffic_monitor/traffic-monitor.rb +3 -3
  163. data/src/lib/arp.h +4 -1
  164. data/src/lib/chibach.c +391 -0
  165. data/src/lib/chibach.h +71 -0
  166. data/src/lib/chibach_private.c +170 -0
  167. data/src/lib/chibach_private.h +52 -0
  168. data/src/lib/ether.c +2 -1
  169. data/src/lib/ether.h +0 -1
  170. data/src/lib/ipv4.h +13 -14
  171. data/{ruby/trema/action-set-nw-src.h → src/lib/ipv6.h} +13 -9
  172. data/src/lib/log.c +161 -58
  173. data/src/lib/log.h +11 -16
  174. data/src/lib/messenger.c +36 -1
  175. data/src/lib/messenger.h +1 -0
  176. data/src/lib/openflow_application_interface.c +128 -28
  177. data/src/lib/openflow_application_interface.h +31 -6
  178. data/src/lib/openflow_message.c +2 -1
  179. data/src/lib/openflow_service_interface.h +1 -0
  180. data/src/lib/openflow_switch_interface.c +1380 -0
  181. data/src/lib/openflow_switch_interface.h +264 -0
  182. data/src/lib/packet_info.c +94 -11
  183. data/src/lib/packet_info.h +22 -3
  184. data/src/lib/packet_parser.c +38 -2
  185. data/src/lib/secure_channel.c +498 -0
  186. data/{ruby/trema/vendor-request.h → src/lib/secure_channel.h} +11 -10
  187. data/src/lib/tcp.h +0 -3
  188. data/src/lib/trema.c +38 -5
  189. data/{ruby/trema/action-set-nw-dst.h → src/lib/trema.hpp} +17 -8
  190. data/src/lib/trema_wrapper.c +5 -0
  191. data/src/lib/trema_wrapper.h +4 -0
  192. data/src/lib/utility.c +93 -4
  193. data/src/lib/utility.h +1 -0
  194. data/src/lib/wrapper.c +30 -7
  195. data/src/lib/wrapper.h +2 -0
  196. data/src/switch_manager/ofpmsg_recv.c +44 -30
  197. data/src/switch_manager/ofpmsg_send.c +40 -1
  198. data/src/switch_manager/ofpmsg_send.h +2 -0
  199. data/src/switch_manager/switch.c +153 -8
  200. data/src/switch_manager/switch.h +1 -0
  201. data/src/switch_manager/switchinfo.h +5 -0
  202. data/src/tremashark/README +2 -2
  203. data/src/tremashark/plugin/packet-trema/packet-trema.c +1 -0
  204. data/trema +1 -1
  205. data/unittests/lib/log_test.c +158 -34
  206. data/unittests/lib/openflow_application_interface_test.c +252 -69
  207. data/unittests/lib/openflow_message_test.c +3 -1
  208. data/unittests/lib/packet_parser_test.c +60 -15
  209. data/unittests/lib/test_packets/icmp6_echo_rep.cap +0 -0
  210. data/unittests/lib/test_packets/icmp6_echo_req.cap +0 -0
  211. data/unittests/lib/trema_test.c +2 -0
  212. data/unittests/lib/utility_test.c +65 -2
  213. data/unittests/lib/wrapper_test.c +29 -0
  214. data/vendor/{README → README.md} +2 -12
  215. data/vendor/packet-openflow.diff +13 -0
  216. metadata +86 -53
  217. data/GPL2 +0 -339
  218. data/ruby/trema/action-enqueue.c +0 -161
  219. data/ruby/trema/action-output.c +0 -169
  220. data/ruby/trema/action-set-dl-dst.c +0 -131
  221. data/ruby/trema/action-set-dl-dst.h +0 -44
  222. data/ruby/trema/action-set-dl-src.c +0 -131
  223. data/ruby/trema/action-set-nw-dst.c +0 -135
  224. data/ruby/trema/action-set-nw-src.c +0 -140
  225. data/ruby/trema/action-set-nw-tos.c +0 -124
  226. data/ruby/trema/action-set-nw-tos.h +0 -42
  227. data/ruby/trema/action-set-tp-dst.c +0 -122
  228. data/ruby/trema/action-set-tp-dst.h +0 -42
  229. data/ruby/trema/action-set-tp-src.c +0 -124
  230. data/ruby/trema/action-set-tp-src.h +0 -42
  231. data/ruby/trema/action-set-vlan-pcp.c +0 -128
  232. data/ruby/trema/action-set-vlan-pcp.h +0 -42
  233. data/ruby/trema/action-set-vlan-vid.c +0 -125
  234. data/ruby/trema/action-set-vlan-vid.h +0 -42
  235. data/ruby/trema/action-strip-vlan.c +0 -81
  236. data/ruby/trema/action-strip-vlan.h +0 -42
  237. data/ruby/trema/action-vendor.c +0 -121
  238. data/ruby/trema/vendor-request.c +0 -193
  239. data/spec/trema/action-enqueue_spec.rb +0 -100
  240. data/spec/trema/action-set-dl-dst_spec.rb +0 -95
  241. data/spec/trema/action-set-dl-src_spec.rb +0 -92
  242. data/spec/trema/action-set-nw-dst_spec.rb +0 -96
  243. data/spec/trema/action-set-nw-src_spec.rb +0 -97
  244. data/spec/trema/action-set-nw-tos_spec.rb +0 -88
  245. data/spec/trema/action-set-tp-dst_spec.rb +0 -88
  246. data/spec/trema/action-set-tp-src_spec.rb +0 -88
  247. data/spec/trema/action-set-vlan-pcp_spec.rb +0 -91
  248. data/spec/trema/action-set-vlan-vid_spec.rb +0 -91
  249. data/spec/trema/action-vendor_spec.rb +0 -90
  250. data/spec/trema/vendor-request_spec.rb +0 -79
@@ -42,6 +42,7 @@
42
42
  int switch_event_connected( struct switch_info *switch_info );
43
43
  int switch_event_disconnected( struct switch_info *switch_info );
44
44
  int switch_event_recv_hello( struct switch_info *switch_info );
45
+ int switch_event_recv_echoreply( struct switch_info *switch_info, buffer *buf );
45
46
  int switch_event_recv_featuresreply( struct switch_info *switch_info, uint64_t *datapath_id );
46
47
  int switch_event_recv_from_application( uint64_t *datapath_id, char *application_service_name, buffer *buf );
47
48
  int switch_event_disconnect_request( uint64_t *datapath_id );
@@ -42,7 +42,10 @@ struct switch_info {
42
42
  struct notify_info *notify_info;
43
43
 
44
44
  int secure_channel_fd; // socket file descriptor of secure channel
45
+
45
46
  bool flow_cleanup;
47
+ bool cookie_translation;
48
+ bool deny_packet_in_on_startup;
46
49
 
47
50
  int state; // state of switch secure channel
48
51
  uint64_t datapath_id;
@@ -58,6 +61,8 @@ struct switch_info {
58
61
  message_queue *recv_queue;
59
62
 
60
63
  bool running_timer;
64
+
65
+ uint32_t echo_request_xid;
61
66
  };
62
67
 
63
68
 
@@ -68,8 +68,8 @@ How to run?
68
68
 
69
69
  2. Send SIGUSR2 to processes to be monitored by tremashark. e.g.,
70
70
 
71
- $ sudo kill -USR2 `cat tmp/learning_switch.pid`
72
- $ sudo kill -USR2 `cat tmp/switch.1.pid`
71
+ $ sudo kill -USR2 `cat tmp/pid/learning_switch.pid`
72
+ $ sudo kill -USR2 `cat tmp/pid/switch.0x1.pid`
73
73
 
74
74
  Known issue
75
75
  ===========
@@ -225,6 +225,7 @@ static const value_string names_service_tag[] = {
225
225
  { MESSENGER_OPENFLOW_CONNECTED, "Switch Connected" },
226
226
  { MESSENGER_OPENFLOW_READY, "Switch Ready" },
227
227
  { MESSENGER_OPENFLOW_DISCONNECTED, "Switch Disconnected" },
228
+ { MESSENGER_OPENFLOW_FAILD_TO_CONNECT, "Switch Failed to connect" },
228
229
  { 0, NULL },
229
230
  };
230
231
 
data/trema CHANGED
@@ -45,7 +45,7 @@ end
45
45
  def method_for command
46
46
  case command
47
47
  when "version", "-V", "--version"
48
- return :version
48
+ return :show_version
49
49
  when "ruby"
50
50
  return :ruby
51
51
  when "help", "-h", "--help", "/?", "-?"
@@ -20,8 +20,10 @@
20
20
  */
21
21
 
22
22
 
23
+ #include <stdarg.h>
23
24
  #include <stdio.h>
24
25
  #include <stdlib.h>
26
+ #include <syslog.h>
25
27
  #include "checks.h"
26
28
  #include "cmockery_trema.h"
27
29
  #include "log.h"
@@ -81,6 +83,35 @@ mock_fprintf( FILE *stream, const char *format, ... ) {
81
83
  }
82
84
 
83
85
 
86
+ static bool syslog_initialized = false;
87
+
88
+ static void
89
+ mock_openlog( const char *ident, int option, int facility ) {
90
+ check_expected( ident );
91
+ check_expected( option );
92
+ check_expected( facility );
93
+
94
+ syslog_initialized = true;
95
+ }
96
+
97
+
98
+ static void
99
+ mock_closelog( void ) {
100
+ syslog_initialized = false;
101
+ }
102
+
103
+
104
+ static void
105
+ mock_vsyslog( int priority, const char *format, va_list ap ) {
106
+ check_expected( priority );
107
+
108
+ char output[ 256 ];
109
+ vsnprintf( output, sizeof( output ), format, ap );
110
+
111
+ check_expected( output );
112
+ }
113
+
114
+
84
115
  /********************************************************************************
85
116
  * Setup and teardown function.
86
117
  ********************************************************************************/
@@ -104,20 +135,41 @@ setup() {
104
135
  trema_abort = mock_abort;
105
136
  trema_vprintf = mock_vprintf;
106
137
  trema_fprintf = mock_fprintf;
138
+ trema_openlog = mock_openlog;
139
+ trema_closelog = mock_closelog;
140
+ trema_vsyslog = mock_vsyslog;
141
+ }
142
+
143
+
144
+ static void
145
+ setup_logger_stdout() {
146
+ setup();
147
+ init_log( "log_test.c", get_trema_tmp(), LOGGING_TYPE_STDOUT );
148
+ }
149
+
150
+
151
+ static void
152
+ setup_logger_file() {
153
+ setup();
154
+ init_log( "log_test.c", get_trema_tmp(), LOGGING_TYPE_FILE );
107
155
  }
108
156
 
109
157
 
110
158
  static void
111
- setup_logger() {
159
+ setup_logger_file_stdout() {
112
160
  setup();
113
- init_log( "log_test.c", get_trema_tmp(), false );
161
+ init_log( "log_test.c", get_trema_tmp(), LOGGING_TYPE_FILE | LOGGING_TYPE_STDOUT );
114
162
  }
115
163
 
116
164
 
117
165
  static void
118
- setup_daemon_logger() {
166
+ setup_logger_syslog() {
119
167
  setup();
120
- init_log( "log_test.c", get_trema_tmp(), true );
168
+ const char *ident = "log_test.c";
169
+ expect_string( mock_openlog, ident, ident );
170
+ expect_value( mock_openlog, option, LOG_NDELAY );
171
+ expect_value( mock_openlog, facility, LOG_USER );
172
+ init_log( ident, get_trema_tmp(), LOGGING_TYPE_SYSLOG );
121
173
  }
122
174
 
123
175
 
@@ -132,6 +184,9 @@ teardown() {
132
184
  trema_abort = abort;
133
185
  trema_vprintf = vprintf;
134
186
  trema_fprintf = fprintf;
187
+ trema_openlog = openlog;
188
+ trema_closelog = closelog;
189
+ trema_vsyslog = vsyslog;
135
190
  }
136
191
 
137
192
 
@@ -142,8 +197,30 @@ teardown() {
142
197
  void
143
198
  test_init_log_reads_LOGING_LEVEL_environment_variable() {
144
199
  setenv( "LOGGING_LEVEL", "CRITICAL", 1 );
145
- init_log( "tetris", get_trema_tmp(), false );
146
- assert_int_equal( LOG_CRITICAL, get_logging_level() );
200
+ init_log( "tetris", get_trema_tmp(), LOGGING_TYPE_FILE );
201
+ assert_int_equal( LOG_CRIT, get_logging_level() );
202
+ }
203
+
204
+
205
+ void
206
+ test_init_log_opens_syslog() {
207
+ const char *ident = "tetris";
208
+ expect_string( mock_openlog, ident, ident );
209
+ expect_value( mock_openlog, option, LOG_NDELAY );
210
+ expect_value( mock_openlog, facility, LOG_USER );
211
+ init_log( ident, get_trema_tmp(), LOGGING_TYPE_SYSLOG );
212
+ assert_true( syslog_initialized );
213
+ }
214
+
215
+
216
+ /********************************************************************************
217
+ * Finalization test.
218
+ ********************************************************************************/
219
+
220
+ void
221
+ test_finalize_log_closes_syslog() {
222
+ finalize_log();
223
+ assert_false( syslog_initialized );
147
224
  }
148
225
 
149
226
 
@@ -160,7 +237,7 @@ test_default_logging_level_is_INFO() {
160
237
  void
161
238
  test_set_logging_level_succeed() {
162
239
  set_logging_level( "critical" );
163
- assert_int_equal( LOG_CRITICAL, get_logging_level() );
240
+ assert_int_equal( LOG_CRIT, get_logging_level() );
164
241
  }
165
242
 
166
243
 
@@ -170,6 +247,23 @@ test_set_logging_level_fail_with_invalid_value() {
170
247
  }
171
248
 
172
249
 
250
+ void
251
+ test_set_logging_level_is_called_before_init_log() {
252
+ set_logging_level( "critical" );
253
+ init_log( "tetris", get_trema_tmp(), LOGGING_TYPE_FILE );
254
+ assert_int_equal( LOG_CRIT, get_logging_level() );
255
+ }
256
+
257
+
258
+ void
259
+ test_LOGGING_LEVEL_overrides_logging_level() {
260
+ setenv( "LOGGING_LEVEL", "DEBUG", 1 );
261
+ set_logging_level( "critical" );
262
+ init_log( "tetris", get_trema_tmp(), LOGGING_TYPE_FILE );
263
+ assert_int_equal( LOG_DEBUG, get_logging_level() );
264
+ }
265
+
266
+
173
267
  /********************************************************************************
174
268
  * critical() tests.
175
269
  ********************************************************************************/
@@ -365,18 +459,35 @@ test_debug_fail_if_NULL() {
365
459
 
366
460
 
367
461
  /********************************************************************************
368
- * Misc.
462
+ * Output type tests.
369
463
  ********************************************************************************/
370
464
 
371
465
  void
372
466
  test_output_to_stdout() {
373
467
  expect_string( mock_vprintf, output, "Hello World\n" );
468
+
469
+ info( "Hello World" );
470
+ }
471
+
472
+
473
+ void
474
+ test_output_to_file_stdout() {
475
+ expect_string( mock_vprintf, output, "Hello World\n" );
374
476
  expect_string( mock_fprintf, output, "Hello World\n" );
375
477
 
376
478
  info( "Hello World" );
377
479
  }
378
480
 
379
481
 
482
+ void
483
+ test_output_to_syslog() {
484
+ expect_value( mock_vsyslog, priority, LOG_INFO );
485
+ expect_string( mock_vsyslog, output, "Hello World" );
486
+
487
+ info( "Hello World" );
488
+ }
489
+
490
+
380
491
  /********************************************************************************
381
492
  * Run tests.
382
493
  ********************************************************************************/
@@ -386,66 +497,79 @@ main() {
386
497
  const UnitTest tests[] = {
387
498
  unit_test_setup_teardown( test_init_log_reads_LOGING_LEVEL_environment_variable,
388
499
  reset_LOGGING_LEVEL, reset_LOGGING_LEVEL ),
500
+ unit_test_setup_teardown( test_init_log_opens_syslog,
501
+ setup, teardown ),
502
+
503
+ unit_test_setup_teardown( test_finalize_log_closes_syslog,
504
+ setup_logger_syslog, teardown ),
389
505
 
390
506
  unit_test_setup_teardown( test_default_logging_level_is_INFO,
391
- setup_logger, teardown ),
507
+ setup_logger_file, teardown ),
392
508
  unit_test_setup_teardown( test_set_logging_level_succeed,
393
- setup_logger, teardown ),
509
+ setup_logger_file, teardown ),
394
510
  unit_test_setup_teardown( test_set_logging_level_fail_with_invalid_value,
395
- setup_logger, teardown ),
511
+ setup_logger_file, teardown ),
512
+ unit_test_setup_teardown( test_set_logging_level_is_called_before_init_log,
513
+ setup, teardown ),
514
+ unit_test_setup_teardown( test_LOGGING_LEVEL_overrides_logging_level,
515
+ setup, teardown ),
396
516
 
397
517
  unit_test_setup_teardown( test_critical_logs_if_logging_level_is_CRITICAL,
398
- setup_daemon_logger, teardown ),
518
+ setup_logger_file, teardown ),
399
519
  unit_test_setup_teardown( test_critical_logs_if_logging_level_is_ERROR,
400
- setup_daemon_logger, teardown ),
520
+ setup_logger_file, teardown ),
401
521
  unit_test_setup_teardown( test_critical_fail_if_NULL,
402
- setup_daemon_logger, teardown ),
522
+ setup_logger_file, teardown ),
403
523
 
404
524
  unit_test_setup_teardown( test_error_donothing_if_logging_level_is_CRITICAL,
405
- setup_daemon_logger, teardown ),
525
+ setup_logger_file, teardown ),
406
526
  unit_test_setup_teardown( test_error_logs_if_logging_level_is_ERROR,
407
- setup_daemon_logger, teardown ),
527
+ setup_logger_file, teardown ),
408
528
  unit_test_setup_teardown( test_error_logs_if_logging_level_is_WARNING,
409
- setup_daemon_logger, teardown ),
529
+ setup_logger_file, teardown ),
410
530
  unit_test_setup_teardown( test_error_fail_if_NULL,
411
- setup_daemon_logger, teardown ),
531
+ setup_logger_file, teardown ),
412
532
 
413
533
  unit_test_setup_teardown( test_warn_donothing_if_logging_level_is_ERROR,
414
- setup_daemon_logger, teardown ),
534
+ setup_logger_file, teardown ),
415
535
  unit_test_setup_teardown( test_warn_logs_if_logging_level_is_WARNING,
416
- setup_daemon_logger, teardown ),
536
+ setup_logger_file, teardown ),
417
537
  unit_test_setup_teardown( test_warn_logs_if_logging_level_is_NOTICE,
418
- setup_daemon_logger, teardown ),
538
+ setup_logger_file, teardown ),
419
539
  unit_test_setup_teardown( test_warn_fail_if_NULL,
420
- setup_daemon_logger, teardown ),
540
+ setup_logger_file, teardown ),
421
541
 
422
542
  unit_test_setup_teardown( test_notice_donothing_if_logging_level_is_WARNING,
423
- setup_daemon_logger, teardown ),
543
+ setup_logger_file, teardown ),
424
544
  unit_test_setup_teardown( test_notice_logs_if_logging_level_is_NOTICE,
425
- setup_daemon_logger, teardown ),
545
+ setup_logger_file, teardown ),
426
546
  unit_test_setup_teardown( test_notice_logs_if_logging_level_is_INFO,
427
- setup_daemon_logger, teardown ),
547
+ setup_logger_file, teardown ),
428
548
  unit_test_setup_teardown( test_notice_fail_if_NULL,
429
- setup_daemon_logger, teardown ),
549
+ setup_logger_file, teardown ),
430
550
 
431
551
  unit_test_setup_teardown( test_info_logs_if_logging_level_is_DEBUG,
432
- setup_daemon_logger, teardown ),
552
+ setup_logger_file, teardown ),
433
553
  unit_test_setup_teardown( test_info_logs_if_logging_level_is_INFO,
434
- setup_daemon_logger, teardown ),
554
+ setup_logger_file, teardown ),
435
555
  unit_test_setup_teardown( test_info_donothing_if_logging_level_is_NOTICE,
436
- setup_daemon_logger, teardown ),
556
+ setup_logger_file, teardown ),
437
557
  unit_test_setup_teardown( test_info_fail_if_NULL,
438
- setup_daemon_logger, teardown ),
558
+ setup_logger_file, teardown ),
439
559
 
440
560
  unit_test_setup_teardown( test_DEBUG_donothing_if_logging_level_is_INFO,
441
- setup_daemon_logger, teardown ),
561
+ setup_logger_file, teardown ),
442
562
  unit_test_setup_teardown( test_DEBUG_logs_if_logging_level_is_DEBUG,
443
- setup_daemon_logger, teardown ),
563
+ setup_logger_file, teardown ),
444
564
  unit_test_setup_teardown( test_debug_fail_if_NULL,
445
- setup_daemon_logger, teardown ),
565
+ setup_logger_file, teardown ),
446
566
 
447
567
  unit_test_setup_teardown( test_output_to_stdout,
448
- setup_logger, teardown ),
568
+ setup_logger_stdout, teardown ),
569
+ unit_test_setup_teardown( test_output_to_file_stdout,
570
+ setup_logger_file_stdout, teardown ),
571
+ unit_test_setup_teardown( test_output_to_syslog,
572
+ setup_logger_syslog, teardown ),
449
573
  };
450
574
  return run_tests( tests );
451
575
  }
@@ -54,6 +54,7 @@ extern hash_table *stats;
54
54
 
55
55
  extern void assert_if_not_initialized();
56
56
  extern void handle_error( const uint64_t datapath_id, buffer *data );
57
+ extern void handle_echo_reply( const uint64_t datapath_id, buffer *data );
57
58
  extern void handle_vendor( const uint64_t datapath_id, buffer *data );
58
59
  extern void handle_features_reply( const uint64_t datapath_id, buffer *data );
59
60
  extern void handle_get_config_reply( const uint64_t datapath_id, buffer *data );
@@ -77,26 +78,28 @@ extern void handle_list_switches_reply( uint16_t message_type, void *data, size_
77
78
  #define SWITCH_DISCONNECTED_USER_DATA ( ( void * ) 0x00020021 )
78
79
  #define ERROR_HANDLER ( ( void * ) 0x00010001 )
79
80
  #define ERROR_USER_DATA ( ( void * ) 0x00010011 )
80
- #define VENDOR_HANDLER ( ( void * ) 0x00010002 )
81
- #define VENDOR_USER_DATA ( ( void * ) 0x00010021 )
82
- #define FEATURES_REPLY_HANDLER ( ( void * ) 0x00010003 )
83
- #define FEATURES_REPLY_USER_DATA ( ( void * ) 0x00010031 )
84
- #define GET_CONFIG_REPLY_HANDLER ( ( void * ) 0x00010004 )
85
- #define GET_CONFIG_REPLY_USER_DATA ( ( void * ) 0x00010041 )
86
- #define PACKET_IN_HANDLER ( ( void * ) 0x00010005 )
87
- #define PACKET_IN_USER_DATA ( ( void * ) 0x00010051 )
88
- #define FLOW_REMOVED_HANDLER ( ( void * ) 0x00010006 )
89
- #define FLOW_REMOVED_USER_DATA ( ( void * ) 0x00010061 )
90
- #define PORT_STATUS_HANDLER ( ( void * ) 0x00010007 )
91
- #define PORT_STATUS_USER_DATA ( ( void * ) 0x00010071 )
92
- #define STATS_REPLY_HANDLER ( ( void * ) 0x00010008 )
93
- #define STATS_REPLY_USER_DATA ( ( void * ) 0x00010081 )
94
- #define BARRIER_REPLY_HANDLER ( ( void * ) 0x00010009 )
95
- #define BARRIER_REPLY_USER_DATA ( ( void * ) 0x00010091 )
96
- #define QUEUE_GET_CONFIG_REPLY_HANDLER ( ( void * ) 0x0001000a )
97
- #define QUEUE_GET_CONFIG_REPLY_USER_DATA ( ( void * ) 0x000100a1 )
98
- #define LIST_SWITCHES_REPLY_HANDLER ( ( void * ) 0x0001000b )
99
- #define LIST_SWITCHES_REPLY_USER_DATA ( ( void * ) 0x000100b1 )
81
+ #define ECHO_REPLY_HANDLER ( ( void * ) 0x00010002 )
82
+ #define ECHO_REPLY_USER_DATA ( ( void * ) 0x00010021 )
83
+ #define VENDOR_HANDLER ( ( void * ) 0x00010003 )
84
+ #define VENDOR_USER_DATA ( ( void * ) 0x00010031 )
85
+ #define FEATURES_REPLY_HANDLER ( ( void * ) 0x00010004 )
86
+ #define FEATURES_REPLY_USER_DATA ( ( void * ) 0x00010041 )
87
+ #define GET_CONFIG_REPLY_HANDLER ( ( void * ) 0x00010005 )
88
+ #define GET_CONFIG_REPLY_USER_DATA ( ( void * ) 0x00010051 )
89
+ #define PACKET_IN_HANDLER ( ( void * ) 0x00010006 )
90
+ #define PACKET_IN_USER_DATA ( ( void * ) 0x00010061 )
91
+ #define FLOW_REMOVED_HANDLER ( ( void * ) 0x00010007 )
92
+ #define FLOW_REMOVED_USER_DATA ( ( void * ) 0x00010071 )
93
+ #define PORT_STATUS_HANDLER ( ( void * ) 0x00010008 )
94
+ #define PORT_STATUS_USER_DATA ( ( void * ) 0x00010081 )
95
+ #define STATS_REPLY_HANDLER ( ( void * ) 0x00010009 )
96
+ #define STATS_REPLY_USER_DATA ( ( void * ) 0x00010091 )
97
+ #define BARRIER_REPLY_HANDLER ( ( void * ) 0x0001000a )
98
+ #define BARRIER_REPLY_USER_DATA ( ( void * ) 0x000100a1 )
99
+ #define QUEUE_GET_CONFIG_REPLY_HANDLER ( ( void * ) 0x0001000b )
100
+ #define QUEUE_GET_CONFIG_REPLY_USER_DATA ( ( void * ) 0x000100b1 )
101
+ #define LIST_SWITCHES_REPLY_HANDLER ( ( void * ) 0x0001000c )
102
+ #define LIST_SWITCHES_REPLY_USER_DATA ( ( void * ) 0x000100c1 )
100
103
 
101
104
  static const pid_t PID = 12345;
102
105
  static char SERVICE_NAME[] = "learning switch application 0";
@@ -112,11 +115,13 @@ static openflow_event_handlers_t NULL_EVENT_HANDLERS = { false, ( void * ) 0, (
112
115
  ( void * ) 0, ( void * ) 0,
113
116
  ( void * ) 0, ( void * ) 0,
114
117
  ( void * ) 0, ( void * ) 0,
118
+ ( void * ) 0, ( void * ) 0,
115
119
  ( void * ) 0 };
116
120
  static openflow_event_handlers_t EVENT_HANDLERS = {
117
121
  false, SWITCH_READY_HANDLER, SWITCH_READY_USER_DATA,
118
122
  SWITCH_DISCONNECTED_HANDLER, SWITCH_DISCONNECTED_USER_DATA,
119
123
  ERROR_HANDLER, ERROR_USER_DATA,
124
+ ECHO_REPLY_HANDLER, ECHO_REPLY_USER_DATA,
120
125
  VENDOR_HANDLER, VENDOR_USER_DATA,
121
126
  FEATURES_REPLY_HANDLER, FEATURES_REPLY_USER_DATA,
122
127
  GET_CONFIG_REPLY_HANDLER, GET_CONFIG_REPLY_USER_DATA,
@@ -241,6 +246,14 @@ mock_delete_message_replied_callback( char *service_name,
241
246
  }
242
247
 
243
248
 
249
+ bool
250
+ mock_clear_send_queue( const char *service_name ) {
251
+ check_expected( service_name );
252
+
253
+ return ( bool ) mock();
254
+ }
255
+
256
+
244
257
  bool
245
258
  mock_parse_packet( buffer *buf ) {
246
259
  calloc_packet_info( buf );
@@ -271,6 +284,25 @@ mock_error_handler( uint64_t datapath_id, uint32_t transaction_id, uint16_t type
271
284
  }
272
285
 
273
286
 
287
+ static void
288
+ mock_echo_reply_handler( uint64_t datapath_id, uint32_t transaction_id, const buffer *data,
289
+ void *user_data ){
290
+ void *data_uc;
291
+
292
+ check_expected( &datapath_id );
293
+ check_expected( transaction_id );
294
+ if( data != NULL ) {
295
+ check_expected( data->length );
296
+ check_expected( data->data );
297
+ }
298
+ else {
299
+ data_uc = ( void * ) ( unsigned long ) data;
300
+ check_expected( data_uc );
301
+ }
302
+ check_expected( user_data );
303
+ }
304
+
305
+
274
306
  static void
275
307
  mock_vendor_handler( uint64_t datapath_id, uint32_t transaction_id, uint32_t vendor,
276
308
  const buffer *data, void *user_data ){
@@ -468,7 +500,7 @@ mock_critical( char *format, ... ) {
468
500
  }
469
501
 
470
502
 
471
- static logging_level
503
+ static int
472
504
  mock_get_logging_level() {
473
505
  return LOG_DEBUG;
474
506
  }
@@ -774,6 +806,26 @@ test_set_error_handler_if_handler_is_NULL() {
774
806
  }
775
807
 
776
808
 
809
+ /********************************************************************************
810
+ * set_echo_reply_handler() tests.
811
+ ********************************************************************************/
812
+
813
+ static void
814
+ test_set_echo_reply_handler() {
815
+ assert_true( set_echo_reply_handler( ECHO_REPLY_HANDLER, ECHO_REPLY_USER_DATA ) );
816
+ assert_int_equal( event_handlers.echo_reply_callback, ECHO_REPLY_HANDLER );
817
+ assert_int_equal( event_handlers.echo_reply_user_data, ECHO_REPLY_USER_DATA );
818
+ }
819
+
820
+
821
+ static void
822
+ test_set_echo_reply_handler_if_handler_is_NULL() {
823
+ expect_string( mock_die, format, "Callback function ( echo_reply_handler ) must not be NULL." );
824
+ expect_assert_failure( set_echo_reply_handler( NULL, NULL ) );
825
+ assert_memory_equal( &event_handlers, &NULL_EVENT_HANDLERS, sizeof( event_handlers ) );
826
+ }
827
+
828
+
777
829
  /********************************************************************************
778
830
  * set_vendor_handler() tests.
779
831
  ********************************************************************************/
@@ -1367,6 +1419,91 @@ test_handle_error_if_message_length_is_zero() {
1367
1419
  }
1368
1420
 
1369
1421
 
1422
+ /********************************************************************************
1423
+ * handle_echo_request() tests.
1424
+ ********************************************************************************/
1425
+
1426
+ static void
1427
+ test_handle_echo_reply() {
1428
+ buffer *buffer, *data;
1429
+
1430
+ data = alloc_buffer_with_length( 16 );
1431
+ append_back_buffer( data, 16 );
1432
+ memset( data->data, 'a', 16 );
1433
+
1434
+ buffer = create_echo_reply( TRANSACTION_ID, data );
1435
+
1436
+ expect_memory( mock_echo_reply_handler, &datapath_id, &DATAPATH_ID, sizeof( uint64_t ) );
1437
+ expect_value( mock_echo_reply_handler, transaction_id, TRANSACTION_ID );
1438
+ expect_value( mock_echo_reply_handler, data->length, data->length );
1439
+ expect_memory( mock_echo_reply_handler, data->data, data->data, data->length );
1440
+ expect_memory( mock_echo_reply_handler, user_data, USER_DATA, USER_DATA_LEN );
1441
+
1442
+ set_echo_reply_handler( mock_echo_reply_handler, USER_DATA );
1443
+ handle_echo_reply( DATAPATH_ID, buffer );
1444
+
1445
+ free_buffer( data );
1446
+ free_buffer( buffer );
1447
+ }
1448
+
1449
+
1450
+ static void
1451
+ test_handle_echo_reply_without_data() {
1452
+ buffer *buffer;
1453
+
1454
+ buffer = create_echo_reply( TRANSACTION_ID, NULL );
1455
+
1456
+ expect_memory( mock_echo_reply_handler, &datapath_id, &DATAPATH_ID, sizeof( uint64_t ) );
1457
+ expect_value( mock_echo_reply_handler, transaction_id, TRANSACTION_ID );
1458
+ expect_value( mock_echo_reply_handler, data_uc, NULL );
1459
+ expect_memory( mock_echo_reply_handler, user_data, USER_DATA, USER_DATA_LEN );
1460
+
1461
+ set_echo_reply_handler( mock_echo_reply_handler, USER_DATA );
1462
+ handle_echo_reply( DATAPATH_ID, buffer );
1463
+
1464
+ free_buffer( buffer );
1465
+ }
1466
+
1467
+
1468
+ static void
1469
+ test_handle_echo_reply_if_handler_is_not_registered() {
1470
+ buffer *buffer, *data;
1471
+
1472
+ data = alloc_buffer_with_length( 16 );
1473
+ append_back_buffer( data, 16 );
1474
+ memset( data->data, 'a', 16 );
1475
+
1476
+ buffer = create_echo_reply( TRANSACTION_ID, data );
1477
+
1478
+ // FIXME
1479
+
1480
+ handle_echo_reply( DATAPATH_ID, buffer );
1481
+
1482
+ free_buffer( data );
1483
+ free_buffer( buffer );
1484
+ }
1485
+
1486
+
1487
+ static void
1488
+ test_handle_echo_reply_if_message_is_NULL() {
1489
+ set_echo_reply_handler( mock_echo_reply_handler, USER_DATA );
1490
+ expect_assert_failure( handle_echo_reply( DATAPATH_ID, NULL ) );
1491
+ }
1492
+
1493
+
1494
+ static void
1495
+ test_handle_echo_reply_if_message_length_is_zero() {
1496
+ buffer *buffer;
1497
+
1498
+ buffer = alloc_buffer_with_length( 32 );
1499
+
1500
+ set_echo_reply_handler( mock_echo_reply_handler, USER_DATA );
1501
+ expect_assert_failure( handle_echo_reply( DATAPATH_ID, buffer ) );
1502
+
1503
+ free_buffer( buffer );
1504
+ }
1505
+
1506
+
1370
1507
  /********************************************************************************
1371
1508
  * handle_vendor() tests.
1372
1509
  ********************************************************************************/
@@ -2665,6 +2802,9 @@ test_handle_switch_events_if_type_is_MESSENGER_OPENFLOW_DISCONNECTED() {
2665
2802
  expect_memory( mock_switch_disconnected_handler, &datapath_id, &DATAPATH_ID, sizeof( uint64_t ) );
2666
2803
  expect_value( mock_switch_disconnected_handler, user_data, SWITCH_DISCONNECTED_USER_DATA );
2667
2804
 
2805
+ expect_string( mock_clear_send_queue, service_name, REMOTE_SERVICE_NAME );
2806
+ will_return( mock_clear_send_queue, true );
2807
+
2668
2808
  set_switch_disconnected_handler( mock_switch_disconnected_handler, SWITCH_DISCONNECTED_USER_DATA );
2669
2809
  handle_switch_events( MESSENGER_OPENFLOW_DISCONNECTED, data->data, data->length );
2670
2810
 
@@ -3272,6 +3412,9 @@ test_handle_message_if_type_is_MESSENGER_OPENFLOW_DISCONNECTED() {
3272
3412
  expect_memory( mock_switch_disconnected_handler, &datapath_id, &DATAPATH_ID, sizeof( uint64_t ) );
3273
3413
  expect_value( mock_switch_disconnected_handler, user_data, SWITCH_DISCONNECTED_USER_DATA );
3274
3414
 
3415
+ expect_string( mock_clear_send_queue, service_name, REMOTE_SERVICE_NAME );
3416
+ will_return( mock_clear_send_queue, true );
3417
+
3275
3418
  set_switch_disconnected_handler( mock_switch_disconnected_handler, SWITCH_DISCONNECTED_USER_DATA );
3276
3419
  handle_message( MESSENGER_OPENFLOW_DISCONNECTED, data->data, data->length );
3277
3420
 
@@ -3319,6 +3462,28 @@ test_handle_message_if_unhandled_message_type() {
3319
3462
  }
3320
3463
 
3321
3464
 
3465
+ /********************************************************************************
3466
+ * delete_openflow_messages() tests.
3467
+ ********************************************************************************/
3468
+
3469
+ static void
3470
+ test_delete_openflow_messages() {
3471
+ expect_string( mock_clear_send_queue, service_name, REMOTE_SERVICE_NAME );
3472
+ will_return( mock_clear_send_queue, true );
3473
+
3474
+ assert_true( delete_openflow_messages( DATAPATH_ID ) );
3475
+ }
3476
+
3477
+
3478
+ static void
3479
+ test_delete_openflow_messages_if_clear_send_queue_fails() {
3480
+ expect_string( mock_clear_send_queue, service_name, REMOTE_SERVICE_NAME );
3481
+ will_return( mock_clear_send_queue, false );
3482
+
3483
+ assert_false( delete_openflow_messages( DATAPATH_ID ) );
3484
+ }
3485
+
3486
+
3322
3487
  /********************************************************************************
3323
3488
  * Run tests.
3324
3489
  ********************************************************************************/
@@ -3326,6 +3491,7 @@ test_handle_message_if_unhandled_message_type() {
3326
3491
  int
3327
3492
  main() {
3328
3493
  const UnitTest tests[] = {
3494
+ // initialization and finalization tests.
3329
3495
  unit_test_setup_teardown( test_init_openflow_application_interface_with_valid_custom_service_name, cleanup, cleanup ),
3330
3496
  unit_test_setup_teardown( test_init_openflow_application_interface_with_too_long_custom_service_name, cleanup, cleanup ),
3331
3497
  unit_test_setup_teardown( test_init_openflow_application_interface_if_already_initialized, init, cleanup ),
@@ -3342,78 +3508,57 @@ main() {
3342
3508
  unit_test_setup_teardown( test_handle_switch_ready, init, cleanup ),
3343
3509
  unit_test_setup_teardown( test_handle_switch_ready_with_simple_handler, init, cleanup ),
3344
3510
 
3511
+ // switch disconnected handler tests.
3345
3512
  unit_test_setup_teardown( test_set_switch_disconnected_handler, init, cleanup ),
3346
3513
  unit_test_setup_teardown( test_set_switch_disconnected_handler_if_handler_is_NULL, init, cleanup ),
3347
3514
 
3515
+ // error handler tests.
3348
3516
  unit_test_setup_teardown( test_set_error_handler, init, cleanup ),
3349
3517
  unit_test_setup_teardown( test_set_error_handler_if_handler_is_NULL, init, cleanup ),
3350
-
3351
- unit_test_setup_teardown( test_set_vendor_handler, init, cleanup ),
3352
- unit_test_setup_teardown( test_set_vendor_handler_if_handler_is_NULL, init, cleanup ),
3353
-
3354
- unit_test_setup_teardown( test_set_features_reply_handler, init, cleanup ),
3355
- unit_test_setup_teardown( test_set_features_reply_handler_if_handler_is_NULL, init, cleanup ),
3356
-
3357
- unit_test_setup_teardown( test_set_get_config_reply_handler, init, cleanup ),
3358
- unit_test_setup_teardown( test_set_get_config_reply_handler_if_handler_is_NULL, init, cleanup ),
3359
-
3360
- unit_test_setup_teardown( test_set_flow_removed_handler, init, cleanup ),
3361
- unit_test_setup_teardown( test_set_flow_removed_handler_if_handler_is_NULL, init, cleanup ),
3362
-
3363
- unit_test_setup_teardown( test_set_port_status_handler, init, cleanup ),
3364
- unit_test_setup_teardown( test_set_port_status_handler_if_handler_is_NULL, init, cleanup ),
3365
-
3366
- unit_test_setup_teardown( test_set_stats_reply_handler, init, cleanup ),
3367
- unit_test_setup_teardown( test_set_stats_reply_handler_if_handler_is_NULL, init, cleanup ),
3368
-
3369
- unit_test_setup_teardown( test_set_barrier_reply_handler, init, cleanup ),
3370
- unit_test_setup_teardown( test_set_barrier_reply_handler_if_handler_is_NULL, init, cleanup ),
3371
-
3372
- unit_test_setup_teardown( test_set_queue_get_config_reply_handler, init, cleanup ),
3373
- unit_test_setup_teardown( test_set_queue_get_config_reply_handler_if_handler_is_NULL, init, cleanup ),
3374
-
3375
- unit_test_setup_teardown( test_set_list_switches_reply_handler, init, cleanup ),
3376
- unit_test_setup_teardown( test_set_list_switches_reply_handler_if_handler_is_NULL, init, cleanup ),
3377
-
3378
- unit_test_setup_teardown( test_send_openflow_message, init, cleanup ),
3379
- unit_test_setup_teardown( test_send_openflow_message_if_message_is_NULL, init, cleanup ),
3380
- unit_test_setup_teardown( test_send_openflow_message_if_message_length_is_zero, init, cleanup ),
3381
-
3382
3518
  unit_test_setup_teardown( test_handle_error, init, cleanup ),
3383
3519
  unit_test_setup_teardown( test_handle_error_if_handler_is_not_registered, init, cleanup ),
3384
3520
  unit_test_setup_teardown( test_handle_error_if_message_is_NULL, init, cleanup ),
3385
3521
  unit_test_setup_teardown( test_handle_error_if_message_length_is_zero, init, cleanup ),
3386
3522
 
3523
+ // echo_reply handler tests.
3524
+ unit_test_setup_teardown( test_set_echo_reply_handler, init, cleanup ),
3525
+ unit_test_setup_teardown( test_set_echo_reply_handler_if_handler_is_NULL, init, cleanup ),
3526
+ unit_test_setup_teardown( test_handle_echo_reply, init, cleanup ),
3527
+ unit_test_setup_teardown( test_handle_echo_reply_without_data, init, cleanup ),
3528
+ unit_test_setup_teardown( test_handle_echo_reply_if_handler_is_not_registered, init, cleanup ),
3529
+ unit_test_setup_teardown( test_handle_echo_reply_if_message_is_NULL, init, cleanup ),
3530
+ unit_test_setup_teardown( test_handle_echo_reply_if_message_length_is_zero, init, cleanup ),
3531
+
3532
+ // vendor handler tests.
3533
+ unit_test_setup_teardown( test_set_vendor_handler, init, cleanup ),
3534
+ unit_test_setup_teardown( test_set_vendor_handler_if_handler_is_NULL, init, cleanup ),
3535
+
3387
3536
  unit_test_setup_teardown( test_handle_vendor, init, cleanup ),
3388
3537
  unit_test_setup_teardown( test_handle_vendor_without_data, init, cleanup ),
3389
3538
  unit_test_setup_teardown( test_handle_vendor_if_handler_is_not_registered, init, cleanup ),
3390
3539
  unit_test_setup_teardown( test_handle_vendor_if_message_is_NULL, init, cleanup ),
3391
3540
  unit_test_setup_teardown( test_handle_vendor_if_message_length_is_zero, init, cleanup ),
3392
3541
 
3542
+ // features reply handler tests.
3543
+ unit_test_setup_teardown( test_set_features_reply_handler, init, cleanup ),
3544
+ unit_test_setup_teardown( test_set_features_reply_handler_if_handler_is_NULL, init, cleanup ),
3393
3545
  unit_test_setup_teardown( test_handle_features_reply, init, cleanup ),
3394
3546
  unit_test_setup_teardown( test_handle_features_reply_without_phy_port, init, cleanup ),
3395
3547
  unit_test_setup_teardown( test_handle_features_reply_if_handler_is_not_registered, init, cleanup ),
3396
3548
  unit_test_setup_teardown( test_handle_features_reply_if_message_is_NULL, init, cleanup ),
3397
3549
  unit_test_setup_teardown( test_handle_features_reply_if_message_length_is_zero, init, cleanup ),
3398
3550
 
3551
+ // get config reply handler tests.
3552
+ unit_test_setup_teardown( test_set_get_config_reply_handler, init, cleanup ),
3553
+ unit_test_setup_teardown( test_set_get_config_reply_handler_if_handler_is_NULL, init, cleanup ),
3399
3554
  unit_test_setup_teardown( test_handle_get_config_reply, init, cleanup ),
3400
3555
  unit_test_setup_teardown( test_handle_get_config_reply_if_handler_is_not_registered, init, cleanup ),
3401
3556
  unit_test_setup_teardown( test_handle_get_config_reply_if_message_is_NULL, init, cleanup ),
3402
3557
  unit_test_setup_teardown( test_handle_get_config_reply_if_message_length_is_zero, init, cleanup ),
3403
3558
 
3404
- // Packet in handler tests.
3405
- unit_test_setup_teardown( test_set_packet_in_handler, init, cleanup ),
3406
- unit_test_setup_teardown( test_set_simple_packet_in_handler, init, cleanup ),
3407
- unit_test_setup_teardown( test_set_packet_in_handler_should_die_if_handler_is_NULL, init, cleanup ),
3408
- unit_test_setup_teardown( test_handle_packet_in, init, cleanup ),
3409
- unit_test_setup_teardown( test_handle_packet_in_with_simple_handler, init, cleanup ),
3410
- unit_test_setup_teardown( test_handle_packet_in_with_malformed_packet, init, cleanup ),
3411
- unit_test_setup_teardown( test_handle_packet_in_without_data, init, cleanup ),
3412
- unit_test_setup_teardown( test_handle_packet_in_without_handler, init, cleanup ),
3413
- unit_test_setup_teardown( test_handle_packet_in_should_die_if_message_is_NULL, init, cleanup ),
3414
- unit_test_setup_teardown( test_handle_packet_in_should_die_if_message_length_is_zero, init, cleanup ),
3415
-
3416
- // Flow removed handler tests.
3559
+ // flow removed handler tests.
3560
+ unit_test_setup_teardown( test_set_flow_removed_handler, init, cleanup ),
3561
+ unit_test_setup_teardown( test_set_flow_removed_handler_if_handler_is_NULL, init, cleanup ),
3417
3562
  unit_test_setup_teardown( test_handle_flow_removed, init, cleanup ),
3418
3563
  unit_test_setup_teardown( test_handle_flow_removed_with_simple_handler, init, cleanup ),
3419
3564
  unit_test_setup_teardown( test_set_simple_flow_removed_handler, init, cleanup ),
@@ -3421,11 +3566,17 @@ main() {
3421
3566
  unit_test_setup_teardown( test_handle_flow_removed_if_message_is_NULL, init, cleanup ),
3422
3567
  unit_test_setup_teardown( test_handle_flow_removed_if_message_length_is_zero, init, cleanup ),
3423
3568
 
3569
+ // port status handler tests.
3570
+ unit_test_setup_teardown( test_set_port_status_handler, init, cleanup ),
3571
+ unit_test_setup_teardown( test_set_port_status_handler_if_handler_is_NULL, init, cleanup ),
3424
3572
  unit_test_setup_teardown( test_handle_port_status, init, cleanup ),
3425
3573
  unit_test_setup_teardown( test_handle_port_status_if_handler_is_not_registered, init, cleanup ),
3426
3574
  unit_test_setup_teardown( test_handle_port_status_if_message_is_NULL, init, cleanup ),
3427
3575
  unit_test_setup_teardown( test_handle_port_status_if_message_length_is_zero, init, cleanup ),
3428
3576
 
3577
+ // stats reply handler tests.
3578
+ unit_test_setup_teardown( test_set_stats_reply_handler, init, cleanup ),
3579
+ unit_test_setup_teardown( test_set_stats_reply_handler_if_handler_is_NULL, init, cleanup ),
3429
3580
  unit_test_setup_teardown( test_handle_stats_reply_if_type_is_OFPST_DESC, init, cleanup ),
3430
3581
  unit_test_setup_teardown( test_handle_stats_reply_if_type_is_OFPST_FLOW, init, cleanup ),
3431
3582
  unit_test_setup_teardown( test_handle_stats_reply_if_type_is_OFPST_AGGREGATE, init, cleanup ),
@@ -3438,24 +3589,47 @@ main() {
3438
3589
  unit_test_setup_teardown( test_handle_stats_reply_if_message_is_NULL, init, cleanup ),
3439
3590
  unit_test_setup_teardown( test_handle_stats_reply_if_message_length_is_zero, init, cleanup ),
3440
3591
 
3592
+ // barrier reply handler tests.
3593
+ unit_test_setup_teardown( test_set_barrier_reply_handler, init, cleanup ),
3594
+ unit_test_setup_teardown( test_set_barrier_reply_handler_if_handler_is_NULL, init, cleanup ),
3441
3595
  unit_test_setup_teardown( test_handle_barrier_reply, init, cleanup ),
3442
3596
  unit_test_setup_teardown( test_handle_barrier_reply_if_handler_is_not_registered, init, cleanup ),
3443
3597
  unit_test_setup_teardown( test_handle_barrier_reply_if_message_is_NULL, init, cleanup ),
3444
3598
  unit_test_setup_teardown( test_handle_barrier_reply_if_message_length_is_zero, init, cleanup ),
3445
3599
 
3600
+ // queue get config reply handler tests.
3601
+ unit_test_setup_teardown( test_set_queue_get_config_reply_handler, init, cleanup ),
3602
+ unit_test_setup_teardown( test_set_queue_get_config_reply_handler_if_handler_is_NULL, init, cleanup ),
3446
3603
  unit_test_setup_teardown( test_handle_queue_get_config_reply, init, cleanup ),
3447
3604
  unit_test_setup_teardown( test_handle_queue_get_config_reply_without_queues, init, cleanup ),
3448
3605
  unit_test_setup_teardown( test_handle_queue_get_config_reply_if_handler_is_not_registered, init, cleanup ),
3449
3606
  unit_test_setup_teardown( test_handle_queue_get_config_reply_if_message_is_NULL, init, cleanup ),
3450
3607
  unit_test_setup_teardown( test_handle_queue_get_config_reply_if_message_length_is_zero, init, cleanup ),
3451
3608
 
3452
- unit_test_setup_teardown( test_insert_dpid, init, cleanup ),
3453
- unit_test_setup_teardown( test_insert_dpid_if_head_is_NULL, init, cleanup ),
3454
- unit_test_setup_teardown( test_insert_dpid_if_dpid_is_NULL, init, cleanup ),
3609
+ // list switches reply handler tests.
3610
+ unit_test_setup_teardown( test_set_list_switches_reply_handler, init, cleanup ),
3611
+ unit_test_setup_teardown( test_set_list_switches_reply_handler_if_handler_is_NULL, init, cleanup ),
3455
3612
  unit_test_setup_teardown( test_handle_list_switches_reply, init, cleanup ),
3456
3613
  unit_test_setup_teardown( test_handle_list_switches_reply_if_data_is_NULL, init, cleanup ),
3457
3614
  unit_test_setup_teardown( test_handle_list_switches_reply_if_length_is_zero, init, cleanup ),
3458
3615
 
3616
+ // packet-in handler tests.
3617
+ unit_test_setup_teardown( test_set_packet_in_handler, init, cleanup ),
3618
+ unit_test_setup_teardown( test_set_simple_packet_in_handler, init, cleanup ),
3619
+ unit_test_setup_teardown( test_set_packet_in_handler_should_die_if_handler_is_NULL, init, cleanup ),
3620
+ unit_test_setup_teardown( test_handle_packet_in, init, cleanup ),
3621
+ unit_test_setup_teardown( test_handle_packet_in_with_simple_handler, init, cleanup ),
3622
+ unit_test_setup_teardown( test_handle_packet_in_with_malformed_packet, init, cleanup ),
3623
+ unit_test_setup_teardown( test_handle_packet_in_without_data, init, cleanup ),
3624
+ unit_test_setup_teardown( test_handle_packet_in_without_handler, init, cleanup ),
3625
+ unit_test_setup_teardown( test_handle_packet_in_should_die_if_message_is_NULL, init, cleanup ),
3626
+ unit_test_setup_teardown( test_handle_packet_in_should_die_if_message_length_is_zero, init, cleanup ),
3627
+
3628
+ // miscellaneous tests.
3629
+ unit_test_setup_teardown( test_insert_dpid, init, cleanup ),
3630
+ unit_test_setup_teardown( test_insert_dpid_if_head_is_NULL, init, cleanup ),
3631
+ unit_test_setup_teardown( test_insert_dpid_if_dpid_is_NULL, init, cleanup ),
3632
+
3459
3633
  unit_test_setup_teardown( test_handle_switch_events_if_type_is_MESSENGER_OPENFLOW_CONNECTED, init, cleanup ),
3460
3634
  unit_test_setup_teardown( test_handle_switch_events_if_type_is_MESSENGER_OPENFLOW_DISCONNECTED, init, cleanup ),
3461
3635
  unit_test_setup_teardown( test_handle_switch_events_if_message_is_NULL, init, cleanup ),
@@ -3475,6 +3649,15 @@ main() {
3475
3649
  unit_test_setup_teardown( test_handle_message_if_message_is_NULL, init, cleanup ),
3476
3650
  unit_test_setup_teardown( test_handle_message_if_message_length_is_zero, init, cleanup ),
3477
3651
  unit_test_setup_teardown( test_handle_message_if_unhandled_message_type, init, cleanup ),
3652
+
3653
+ // send_openflow_message() tests.
3654
+ unit_test_setup_teardown( test_send_openflow_message, init, cleanup ),
3655
+ unit_test_setup_teardown( test_send_openflow_message_if_message_is_NULL, init, cleanup ),
3656
+ unit_test_setup_teardown( test_send_openflow_message_if_message_length_is_zero, init, cleanup ),
3657
+
3658
+ // delete_openflow_messages() tests.
3659
+ unit_test_setup_teardown( test_delete_openflow_messages, init, cleanup ),
3660
+ unit_test_setup_teardown( test_delete_openflow_messages_if_clear_send_queue_fails, init, cleanup ),
3478
3661
  };
3479
3662
  return run_tests( tests );
3480
3663
  }