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
@@ -0,0 +1,184 @@
1
+ #! /usr/bin/env bash
2
+ #
3
+ # Copyright (C) 2012 NEC Corporation
4
+ #
5
+ # This program is free software; you can redistribute it and/or modify
6
+ # it under the terms of the GNU General Public License, version 2, as
7
+ # published by the Free Software Foundation.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License along
15
+ # with this program; if not, write to the Free Software Foundation, Inc.,
16
+ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
+ #
18
+
19
+ EXECUTABLES_DIR="$TREMA_HOME/objects/management"
20
+ ECHO="$EXECUTABLES_DIR/echo"
21
+ SET_LOGGING_LEVEL="$EXECUTABLES_DIR/set_logging_level"
22
+ SHOW_STATS="$EXECUTABLES_DIR/show_stats"
23
+ APPLICATION="$EXECUTABLES_DIR/application"
24
+ SOCK_DIR="$TREMA_HOME/tmp/sock"
25
+ BASENAME="/usr/bin/basename"
26
+ SED="/bin/sed"
27
+ SCRIPT_NAME=`$BASENAME $0`
28
+
29
+
30
+ list_services() {
31
+ shopt -s nullglob
32
+ for file in $SOCK_DIR/*.m.sock
33
+ do echo `$BASENAME $file .m.sock | $SED 's/^trema\.//'`
34
+ done
35
+ }
36
+
37
+
38
+ ping() {
39
+ local service_name="$1"
40
+
41
+ if [ -z "$service_name" ]; then
42
+ echo "Service name must be specified."
43
+ print_ping_usage
44
+ exit 1
45
+ fi
46
+
47
+ $ECHO $service_name
48
+ }
49
+
50
+
51
+ set_logging_level() {
52
+ local service_name="$1"
53
+ local logging_level="$2"
54
+
55
+ if [ -z "$service_name" ]; then
56
+ echo "Service name must be specified."
57
+ print_set_logging_level_usage
58
+ exit 1
59
+ fi
60
+ if [ -z "$logging_level" ]; then
61
+ echo "Logging level must be specified."
62
+ print_set_logging_level_usage
63
+ exit 1
64
+ fi
65
+
66
+ $SET_LOGGING_LEVEL $service_name $logging_level
67
+ }
68
+
69
+
70
+ show_stats() {
71
+ local service_name="$1"
72
+
73
+ if [ -z "$service_name" ]; then
74
+ echo "Service name must be specified."
75
+ print_show_stats_usage
76
+ exit 1
77
+ fi
78
+
79
+ $SHOW_STATS $service_name
80
+ }
81
+
82
+
83
+ application() {
84
+ local service_name="$1"
85
+ local application_id="$2"
86
+ local data="$3"
87
+
88
+ if [ -z "$service_name" ]; then
89
+ echo "Service name must be specified."
90
+ print_application_usage
91
+ exit 1
92
+ fi
93
+ if [ -z "$application_id" ]; then
94
+ echo "Application specific identifier must be specified."
95
+ print_application_usage
96
+ exit 1
97
+ fi
98
+
99
+ $APPLICATION $service_name $application_id $data
100
+ }
101
+
102
+
103
+ check_variables() {
104
+ if [ -z "$TREMA_HOME" ]; then
105
+ echo "TREMA_HOME environment variable must be set."
106
+ exit 1
107
+ fi
108
+
109
+ if [ ! -d "$TREMA_HOME" ]; then
110
+ echo "$TREMA_HOME does not exist."
111
+ exit 1
112
+ fi
113
+
114
+ if [ ! -d "$SOCK_DIR" ]; then
115
+ echo "$SOCK_DIR does not exist."
116
+ exit 1
117
+ fi
118
+
119
+ if [ ! -d "$EXECUTABLES_DIR" ]; then
120
+ echo "$EXECUTABLES_DIR does not exist."
121
+ exit 1
122
+ fi
123
+ }
124
+
125
+
126
+ print_list_services_usage() {
127
+ echo "Usage: $SCRIPT_NAME services"
128
+ }
129
+
130
+
131
+ print_usage() {
132
+ echo "Usage: $SCRIPT_NAME {services|ping|set_logging_level|show_stats|application} [OPTIONS...]"
133
+ }
134
+
135
+
136
+ print_ping_usage() {
137
+ echo "Usage: $SCRIPT_NAME ping SERVICE_NAME"
138
+ }
139
+
140
+
141
+ print_set_logging_level_usage() {
142
+ echo "Usage: $SCRIPT_NAME set_logging_level SERVICE_NAME LOGGING_LEVEL"
143
+ }
144
+
145
+
146
+ print_show_stats_usage() {
147
+ echo "Usage: $SCRIPT_NAME show_stats SERVICE_NAME"
148
+ }
149
+
150
+
151
+ print_application_usage() {
152
+ echo "Usage: $SCRIPT_NAME application SERVICE_NAME APPLICATION_ID DATA_IN_HEX"
153
+ }
154
+
155
+
156
+ check_variables
157
+
158
+ case "$1" in
159
+ services)
160
+ list_services
161
+ ;;
162
+
163
+ ping)
164
+ ping $2
165
+ ;;
166
+
167
+ set_logging_level)
168
+ set_logging_level $2 $3
169
+ ;;
170
+
171
+ show_stats)
172
+ show_stats $2
173
+ ;;
174
+
175
+ application)
176
+ application $2 $3 $4
177
+ ;;
178
+
179
+ *)
180
+ print_usage
181
+ exit 1
182
+ esac
183
+
184
+ exit 0
@@ -39,7 +39,7 @@
39
39
  #undef printf
40
40
  #endif
41
41
  #define printf( fmt, args... ) mock_printf2( fmt, ##args )
42
- int mock_printf2(const char *format, ...);
42
+ int mock_printf2( const char *format, ... );
43
43
 
44
44
  #ifdef error
45
45
  #undef error
@@ -112,24 +112,26 @@ const char *mock_get_executable_name( void );
112
112
  void
113
113
  usage() {
114
114
  printf(
115
- "OpenFlow Packet in Filter.\n"
116
- "Usage: %s [OPTION]... [PACKETIN-FILTER-RULE]...\n"
117
- "\n"
118
- " -n, --name=SERVICE_NAME service name\n"
119
- " -d, --daemonize run in the background\n"
120
- " -l, --logging_level=LEVEL set logging level\n"
121
- " -h, --help display this help and exit\n"
122
- "\n"
123
- "PACKETIN-FILTER-RULE:\n"
124
- " match-type::destination-service-name\n"
125
- "\n"
126
- "match-type:\n"
127
- " lldp LLDP ethernet frame type and priority is 0x8000\n"
128
- " packet_in any packet and priority is zero\n"
129
- "\n"
130
- "destination-service-name destination service name\n"
131
- , get_executable_name()
132
- );
115
+ "OpenFlow Packet in Filter.\n"
116
+ "Usage: %s [OPTION]... [PACKETIN-FILTER-RULE]...\n"
117
+ "\n"
118
+ " -n, --name=SERVICE_NAME service name\n"
119
+ " -d, --daemonize run in the background\n"
120
+ " -l, --logging_level=LEVEL set logging level\n"
121
+ " -g, --syslog output log messages to syslog\n"
122
+ " -f, --logging_facility=FACILITY set syslog facility\n"
123
+ " -h, --help display this help and exit\n"
124
+ "\n"
125
+ "PACKETIN-FILTER-RULE:\n"
126
+ " match-type::destination-service-name\n"
127
+ "\n"
128
+ "match-type:\n"
129
+ " lldp LLDP ethernet frame type and priority is 0x8000\n"
130
+ " packet_in any packet and priority is zero\n"
131
+ "\n"
132
+ "destination-service-name destination service name\n"
133
+ , get_executable_name()
134
+ );
133
135
  }
134
136
 
135
137
 
@@ -210,7 +212,7 @@ handle_packet_in( uint64_t datapath_id, uint32_t transaction_id,
210
212
  free_buffer( buf );
211
213
  return;
212
214
  }
213
-
215
+
214
216
  debug( "Sending a message to %s ( match = %s ).", service_name, match_str );
215
217
  }
216
218
 
@@ -248,7 +250,7 @@ finalize_packetin_match_table( void ) {
248
250
 
249
251
  static bool
250
252
  add_packetin_match_entry( struct ofp_match match, uint16_t priority, const char *service_name ) {
251
- bool ( *insert_or_update_match_entry ) ( struct ofp_match, uint16_t, void * ) = update_match_entry;
253
+ bool ( *insert_or_update_match_entry )( struct ofp_match, uint16_t, void * ) = update_match_entry;
252
254
  list_element *services = lookup_match_strict_entry( match, priority );
253
255
  if ( services == NULL ) {
254
256
  insert_or_update_match_entry = insert_match_entry;
@@ -367,7 +369,7 @@ set_match_type( int argc, char *argv[] ) {
367
369
  static void
368
370
  handle_add_filter_request( const messenger_context_handle *handle, add_packetin_filter_request *request ) {
369
371
  assert( handle != NULL );
370
- assert( request != NULL ) ;
372
+ assert( request != NULL );
371
373
 
372
374
  request->entry.service_name[ MESSENGER_SERVICE_NAME_LENGTH - 1 ] = '\0';
373
375
  if ( strlen( request->entry.service_name ) == 0 ) {
@@ -392,7 +394,7 @@ handle_add_filter_request( const messenger_context_handle *handle, add_packetin_
392
394
  static void
393
395
  delete_filter_walker( struct ofp_match match, uint16_t priority, void *data, void *user_data ) {
394
396
  UNUSED( data );
395
- buffer *reply_buffer = user_data;
397
+ buffer *reply_buffer = user_data;
396
398
  assert( reply_buffer != NULL );
397
399
 
398
400
  delete_packetin_filter_reply *reply = reply_buffer->data;
@@ -410,7 +412,7 @@ delete_filter_walker( struct ofp_match match, uint16_t priority, void *data, voi
410
412
  static void
411
413
  handle_delete_filter_request( const messenger_context_handle *handle, delete_packetin_filter_request *request ) {
412
414
  assert( handle != NULL );
413
- assert( request != NULL ) ;
415
+ assert( request != NULL );
414
416
 
415
417
  buffer *buf = alloc_buffer_with_length( sizeof( delete_packetin_filter_reply ) );
416
418
  delete_packetin_filter_reply *reply = append_back_buffer( buf, sizeof( delete_packetin_filter_reply ) );
@@ -459,7 +461,7 @@ dump_filter_walker( struct ofp_match match, uint16_t priority, void *data, void
459
461
  static void
460
462
  handle_dump_filter_request( const messenger_context_handle *handle, dump_packetin_filter_request *request ) {
461
463
  assert( handle != NULL );
462
- assert( request != NULL ) ;
464
+ assert( request != NULL );
463
465
 
464
466
  buffer *buf = alloc_buffer_with_length( 2048 );
465
467
  dump_packetin_filter_reply *reply = append_back_buffer( buf, offsetof( dump_packetin_filter_reply, entries ) );
@@ -500,14 +502,14 @@ static void
500
502
  handle_request( const messenger_context_handle *handle, uint16_t tag, void *data, size_t length ) {
501
503
  assert( handle != NULL );
502
504
 
503
- debug( "Handling a request ( handle = %p, tag = %#x, data = %p, length = %u ).",
505
+ debug( "Handling a request ( handle = %p, tag = %#x, data = %p, length = %zu ).",
504
506
  handle, tag, data, length );
505
507
 
506
508
  switch ( tag ) {
507
509
  case MESSENGER_ADD_PACKETIN_FILTER_REQUEST:
508
510
  {
509
511
  if ( length != sizeof( add_packetin_filter_request ) ) {
510
- error( "Invalid add packetin filter request ( length = %u ).", length );
512
+ error( "Invalid add packetin filter request ( length = %zu ).", length );
511
513
  return;
512
514
  }
513
515
 
@@ -517,7 +519,7 @@ handle_request( const messenger_context_handle *handle, uint16_t tag, void *data
517
519
  case MESSENGER_DELETE_PACKETIN_FILTER_REQUEST:
518
520
  {
519
521
  if ( length != sizeof( delete_packetin_filter_request ) ) {
520
- error( "Invalid delete packetin filter request ( length = %u ).", length );
522
+ error( "Invalid delete packetin filter request ( length = %zu ).", length );
521
523
  return;
522
524
  }
523
525
 
@@ -527,7 +529,7 @@ handle_request( const messenger_context_handle *handle, uint16_t tag, void *data
527
529
  case MESSENGER_DUMP_PACKETIN_FILTER_REQUEST:
528
530
  {
529
531
  if ( length != sizeof( dump_packetin_filter_request ) ) {
530
- error( "Invalid dump packetin filter request ( length = %u ).", length );
532
+ error( "Invalid dump packetin filter request ( length = %zu ).", length );
531
533
  return;
532
534
  }
533
535
 
@@ -92,7 +92,7 @@ static cookie_entry_t *
92
92
  allocate_cookie_entry( uint64_t *original_cookie, char *service_name, uint16_t flags ) {
93
93
  cookie_entry_t *new_entry;
94
94
 
95
- new_entry = xmalloc( sizeof ( cookie_entry_t ) );
95
+ new_entry = xmalloc( sizeof( cookie_entry_t ) );
96
96
  memset( new_entry, 0, sizeof( cookie_entry_t ) );
97
97
 
98
98
  new_entry->cookie = generate_cookie();
@@ -178,9 +178,9 @@ insert_cookie_entry( uint64_t *original_cookie, char *service_name, uint16_t fla
178
178
  void
179
179
  delete_cookie_entry( cookie_entry_t *entry ) {
180
180
  debug( "Deleting cookie entry ( cookie = %#" PRIx64 ", application = [ cookie = %#" PRIx64 ", service_name = %s, "
181
- "flags = %#x ], reference_count = %d, expire_at = %u ).",
181
+ "flags = %#x ], reference_count = %d, expire_at = %" PRIu64 " ).",
182
182
  entry->cookie, entry->application.cookie, entry->application.service_name,
183
- entry->application.flags, entry->reference_count, entry->expire_at );
183
+ entry->application.flags, entry->reference_count, ( int64_t ) entry->expire_at );
184
184
 
185
185
  if ( entry->reference_count > 1 ) {
186
186
  debug( "Decrementing reference counter ( reference_count = %d ).", entry->reference_count );
@@ -229,9 +229,9 @@ age_cookie_entry( cookie_entry_t *entry ) {
229
229
  if ( entry->expire_at < time( NULL ) ) {
230
230
  // TODO: check if the target flow is still alive or not
231
231
  warn( "Aging out cookie entry ( cookie = %#" PRIx64 ", application = [ cookie = %#" PRIx64 ", service_name = %s, "
232
- "flags = %#x ], reference_count = %d, expire_at = %u ).",
232
+ "flags = %#x ], reference_count = %d, expire_at = %" PRIu64 " ).",
233
233
  entry->cookie, entry->application.cookie, entry->application.service_name,
234
- entry->application.flags, entry->reference_count, entry->expire_at );
234
+ entry->application.flags, entry->reference_count, ( int64_t ) entry->expire_at );
235
235
 
236
236
  delete_hash_entry( cookie_table.global, &entry->cookie );
237
237
  delete_hash_entry( cookie_table.application, &entry->application );
@@ -257,9 +257,9 @@ age_cookie_table( void *user_data ) {
257
257
  static void
258
258
  dump_cookie_entry( cookie_entry_t *entry ) {
259
259
  info( "cookie = %#" PRIx64 ", application = [ cookie = %#" PRIx64 ", service_name = %s, "
260
- "flags = %#x ], reference_count = %d, expire_at = %u",
260
+ "flags = %#x ], reference_count = %d, expire_at = %" PRIu64 "",
261
261
  entry->cookie, entry->application.cookie, entry->application.service_name,
262
- entry->application.flags, entry->reference_count, entry->expire_at );
262
+ entry->application.flags, entry->reference_count, ( int64_t ) entry->expire_at );
263
263
  }
264
264
 
265
265
 
@@ -19,8 +19,8 @@
19
19
 
20
20
 
21
21
  #include <assert.h>
22
- #include <string.h>
23
22
  #include <inttypes.h>
23
+ #include <string.h>
24
24
  #include "trema.h"
25
25
  #include "dpid_table.h"
26
26
 
@@ -63,7 +63,7 @@ insert_dpid_entry( uint64_t *dpid ) {
63
63
  return;
64
64
  }
65
65
 
66
- uint64_t *new_entry = xmalloc( sizeof ( uint64_t ) );
66
+ uint64_t *new_entry = xmalloc( sizeof( uint64_t ) );
67
67
  *new_entry = *dpid;
68
68
  insert_hash_entry( dpid_table, new_entry, new_entry );
69
69
  }
@@ -95,7 +95,7 @@ get_switches( void ) {
95
95
  init_hash_iterator( dpid_table, &iter );
96
96
  while ( ( entry = iterate_hash_next( &iter ) ) != NULL ) {
97
97
  uint64_t *dpid = append_back_buffer( buf, sizeof( uint64_t ) );
98
- *dpid = htonll( *( uint64_t * )( entry->value ) );
98
+ *dpid = htonll( *( uint64_t * ) ( entry->value ) );
99
99
  }
100
100
 
101
101
  return buf;
@@ -43,4 +43,3 @@ buffer *get_switches( void );
43
43
  * indent-tabs-mode: nil
44
44
  * End:
45
45
  */
46
-
@@ -41,4 +41,3 @@ enum {
41
41
  * indent-tabs-mode: nil
42
42
  * End:
43
43
  */
44
-
@@ -295,9 +295,9 @@ ofpmsg_recv_flowremoved( struct switch_info *sw_info, buffer *buf ) {
295
295
  }
296
296
 
297
297
  debug( "Cookie found ( cookie = %#" PRIx64 ", application = [ cookie = %#" PRIx64
298
- ", service name = %s, flags = %#x ], reference_count = %d, expire_at = %u ).",
298
+ ", service name = %s, flags = %#x ], reference_count = %d, expire_at = %" PRIu64 " ).",
299
299
  cookie, entry->application.cookie, entry->application.service_name, entry->application.flags,
300
- entry->reference_count, entry->expire_at );
300
+ entry->reference_count, ( int64_t ) entry->expire_at );
301
301
 
302
302
  if ( entry->application.flags & OFPFF_SEND_FLOW_REM ) {
303
303
  flow_removed->cookie = htonll( entry->application.cookie );
@@ -358,7 +358,7 @@ ofpmsg_recv_statsreply( struct switch_info *sw_info, buffer *buf ) {
358
358
  uint32_t xid = ntohl( stats_reply->header.xid );
359
359
  xid_entry_t *xid_entry = lookup_xid_entry( xid );
360
360
  if ( xid_entry == NULL ) {
361
- error( "No transaction id entry found ( transaction_id = %#lx ).", xid );
361
+ error( "No transaction id entry found ( transaction_id = %#" PRIx32 " ).", xid );
362
362
  free_buffer( buf );
363
363
  return -1;
364
364
  }
@@ -39,4 +39,3 @@ int ofpmsg_recv( struct switch_info *sw_info, buffer *buf );
39
39
  * indent-tabs-mode: nil
40
40
  * End:
41
41
  */
42
-
@@ -18,8 +18,8 @@
18
18
  */
19
19
 
20
20
 
21
- #include <openflow.h>
22
21
  #include <inttypes.h>
22
+ #include <openflow.h>
23
23
  #include <stdio.h>
24
24
  #include <string.h>
25
25
  #include "cookie_table.h"
@@ -118,7 +118,7 @@ ofpmsg_send_error_msg( struct switch_info *sw_info, uint16_t type, uint16_t code
118
118
  int ret;
119
119
  buffer *buf;
120
120
 
121
- if (data->length > OFP_ERROR_MSG_MAX_DATA ) {
121
+ if ( data->length > OFP_ERROR_MSG_MAX_DATA ) {
122
122
  // FIXME
123
123
  data->length = OFP_ERROR_MSG_MAX_DATA;
124
124
  }