trema 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.mono.rant +4107 -0
- data/.rspec +1 -0
- data/.yardopts +4 -0
- data/Doxyfile +1679 -0
- data/GPL2 +339 -0
- data/Gemfile +22 -0
- data/Gemfile.lock +71 -0
- data/README.md +135 -0
- data/Rakefile +140 -0
- data/Rantfile +834 -0
- data/VERSION +1 -0
- data/build.rb +32 -0
- data/cruise.rb +389 -0
- data/features/example.dumper.feature +87 -0
- data/features/example.learning_switch.feature +39 -0
- data/features/example.list_switches.feature +38 -0
- data/features/example.message.echo_reply.feature +26 -0
- data/features/example.message.echo_request.feature +25 -0
- data/features/example.message.features_request.feature +84 -0
- data/features/example.message.hello.feature +25 -0
- data/features/example.message.set_config.feature +27 -0
- data/features/example.multi_learning_switch.feature +135 -0
- data/features/example.packetin_filter_config.feature +91 -0
- data/features/example.repeater_hub.feature +49 -0
- data/features/example.switch_monitor.feature +39 -0
- data/features/packetin_filter.feature +49 -0
- data/features/step_definitions/kill_steps.rb +30 -0
- data/features/step_definitions/log_steps.rb +90 -0
- data/features/step_definitions/misc_steps.rb +64 -0
- data/features/step_definitions/off_steps.rb +30 -0
- data/features/step_definitions/run_steps.rb +91 -0
- data/features/step_definitions/send_packets_steps.rb +42 -0
- data/features/step_definitions/show_stats_steps.rb +43 -0
- data/features/step_definitions/stats_steps.rb +39 -0
- data/features/support/env.rb +75 -0
- data/features/support/hooks.rb +8 -0
- data/features/switch_manager.feature +35 -0
- data/features/trema-config.feature +68 -0
- data/features/trema.dump_flows.feature +25 -0
- data/features/trema.feature +25 -0
- data/features/trema.kill.feature +53 -0
- data/features/trema.killall.feature +30 -0
- data/features/trema.reset_stats.feature +14 -0
- data/features/trema.run.feature +46 -0
- data/features/trema.send_packets.feature +56 -0
- data/features/trema.show_stats.feature +67 -0
- data/features/tutorial.hello_trema.feature +27 -0
- data/features/tutorial.packet_in.feature +47 -0
- data/features/tutorial.switch_info.feature +55 -0
- data/ruby/.gitignore +4 -0
- data/ruby/blocker.rb +78 -0
- data/ruby/extconf.rb +71 -0
- data/ruby/sub-process.rb +291 -0
- data/ruby/trema/action-common.c +60 -0
- data/ruby/trema/action-common.h +42 -0
- data/ruby/trema/action-enqueue.c +161 -0
- data/ruby/trema/action-enqueue.h +40 -0
- data/ruby/trema/action-output.c +169 -0
- data/ruby/trema/action-output.h +42 -0
- data/ruby/trema/action-set-dl-dst.c +131 -0
- data/ruby/trema/action-set-dl-dst.h +44 -0
- data/ruby/trema/action-set-dl-src.c +131 -0
- data/ruby/trema/action-set-dl-src.h +44 -0
- data/ruby/trema/action-set-nw-dst.c +135 -0
- data/ruby/trema/action-set-nw-dst.h +42 -0
- data/ruby/trema/action-set-nw-src.c +140 -0
- data/ruby/trema/action-set-nw-src.h +42 -0
- data/ruby/trema/action-set-nw-tos.c +124 -0
- data/ruby/trema/action-set-nw-tos.h +42 -0
- data/ruby/trema/action-set-tp-dst.c +122 -0
- data/ruby/trema/action-set-tp-dst.h +42 -0
- data/ruby/trema/action-set-tp-src.c +124 -0
- data/ruby/trema/action-set-tp-src.h +42 -0
- data/ruby/trema/action-set-vlan-pcp.c +128 -0
- data/ruby/trema/action-set-vlan-pcp.h +42 -0
- data/ruby/trema/action-set-vlan-vid.c +125 -0
- data/ruby/trema/action-set-vlan-vid.h +42 -0
- data/ruby/trema/action-strip-vlan.c +81 -0
- data/ruby/trema/action-strip-vlan.h +42 -0
- data/ruby/trema/action-vendor.c +121 -0
- data/ruby/trema/action-vendor.h +42 -0
- data/ruby/trema/aggregate-stats-reply.rb +70 -0
- data/ruby/trema/app.rb +112 -0
- data/ruby/trema/barrier-reply.c +99 -0
- data/ruby/trema/barrier-reply.h +46 -0
- data/ruby/trema/barrier-request.c +108 -0
- data/ruby/trema/barrier-request.h +44 -0
- data/ruby/trema/cli.rb +269 -0
- data/ruby/trema/command.rb +40 -0
- data/ruby/trema/command/dump_flows.rb +62 -0
- data/ruby/trema/command/kill.rb +71 -0
- data/ruby/trema/command/killall.rb +56 -0
- data/ruby/trema/command/reset_stats.rb +61 -0
- data/ruby/trema/command/ruby.rb +55 -0
- data/ruby/trema/command/run.rb +120 -0
- data/ruby/trema/command/send_packets.rb +130 -0
- data/ruby/trema/command/shell.rb +61 -0
- data/ruby/trema/command/show_stats.rb +84 -0
- data/ruby/trema/command/usage.rb +61 -0
- data/ruby/trema/command/version.rb +39 -0
- data/ruby/trema/controller.c +595 -0
- data/ruby/trema/controller.h +44 -0
- data/ruby/trema/controller.rb +81 -0
- data/ruby/trema/daemon.rb +167 -0
- data/ruby/trema/dsl.rb +34 -0
- data/ruby/trema/dsl/configuration.rb +153 -0
- data/ruby/trema/dsl/context.rb +71 -0
- data/ruby/trema/dsl/link.rb +41 -0
- data/ruby/trema/dsl/parser.rb +70 -0
- data/ruby/trema/dsl/run.rb +49 -0
- data/ruby/trema/dsl/runner.rb +165 -0
- data/ruby/trema/dsl/stanza.rb +53 -0
- data/ruby/trema/dsl/switch.rb +78 -0
- data/ruby/trema/dsl/syntax-error.rb +33 -0
- data/ruby/trema/dsl/syntax.rb +109 -0
- data/ruby/trema/dsl/vhost.rb +108 -0
- data/ruby/trema/dsl/vswitch.rb +47 -0
- data/ruby/trema/echo-reply.c +107 -0
- data/ruby/trema/echo-reply.h +42 -0
- data/ruby/trema/echo-request.c +140 -0
- data/ruby/trema/echo-request.h +42 -0
- data/ruby/trema/error.c +253 -0
- data/ruby/trema/error.h +44 -0
- data/ruby/trema/exact-match.rb +36 -0
- data/ruby/trema/executables.rb +95 -0
- data/ruby/trema/features-reply.c +238 -0
- data/ruby/trema/features-reply.h +60 -0
- data/ruby/trema/features-request.c +109 -0
- data/ruby/trema/features-request.h +44 -0
- data/ruby/trema/flow-removed.c +275 -0
- data/ruby/trema/flow-removed.h +46 -0
- data/ruby/trema/flow-stats-reply.rb +109 -0
- data/ruby/trema/flow.rb +56 -0
- data/ruby/trema/get-config-reply.c +159 -0
- data/ruby/trema/get-config-reply.h +52 -0
- data/ruby/trema/get-config-request.c +107 -0
- data/ruby/trema/get-config-request.h +44 -0
- data/ruby/trema/hello.c +110 -0
- data/ruby/trema/hello.h +44 -0
- data/ruby/trema/host.rb +257 -0
- data/ruby/trema/ip.rb +101 -0
- data/ruby/trema/link.rb +176 -0
- data/ruby/trema/list-switches-reply.c +46 -0
- data/ruby/trema/list-switches-reply.h +40 -0
- data/ruby/trema/logger.c +162 -0
- data/ruby/trema/logger.h +44 -0
- data/ruby/trema/mac.rb +151 -0
- data/ruby/trema/match.c +594 -0
- data/ruby/trema/match.h +36 -0
- data/ruby/trema/monkey-patch/integer.rb +35 -0
- data/ruby/trema/monkey-patch/integer/base-conversions.rb +36 -0
- data/ruby/trema/monkey-patch/integer/ranges.rb +51 -0
- data/ruby/trema/monkey-patch/module.rb +33 -0
- data/ruby/trema/monkey-patch/module/deprecation.rb +41 -0
- data/ruby/trema/monkey-patch/string.rb +33 -0
- data/ruby/trema/monkey-patch/string/inflectors.rb +54 -0
- data/ruby/trema/network-component.rb +153 -0
- data/ruby/trema/ofctl.rb +62 -0
- data/ruby/trema/open-vswitch.rb +154 -0
- data/ruby/trema/openflow-error.c +191 -0
- data/ruby/trema/openflow-error.h +53 -0
- data/ruby/trema/openflow-switch.rb +88 -0
- data/ruby/trema/ordered-hash.rb +74 -0
- data/ruby/trema/packet-queue.rb +178 -0
- data/ruby/trema/packet_in.c +736 -0
- data/ruby/trema/packet_in.h +46 -0
- data/ruby/trema/packetin-filter.rb +126 -0
- data/ruby/trema/path.rb +135 -0
- data/ruby/trema/phost.rb +69 -0
- data/ruby/trema/port-mod.c +226 -0
- data/ruby/trema/port-mod.h +36 -0
- data/ruby/trema/port-stats-reply.rb +111 -0
- data/ruby/trema/port-status.c +156 -0
- data/ruby/trema/port-status.h +45 -0
- data/ruby/trema/port.c +295 -0
- data/ruby/trema/port.h +47 -0
- data/ruby/trema/process.rb +76 -0
- data/ruby/trema/queue-get-config-reply.c +200 -0
- data/ruby/trema/queue-get-config-reply.h +47 -0
- data/ruby/trema/queue-get-config-request.c +141 -0
- data/ruby/trema/queue-get-config-request.h +44 -0
- data/ruby/trema/queue-stats-reply.rb +78 -0
- data/ruby/trema/set-config.c +171 -0
- data/ruby/trema/set-config.h +44 -0
- data/ruby/trema/shell.rb +39 -0
- data/ruby/trema/shell/down.rb +39 -0
- data/ruby/trema/shell/killall.rb +40 -0
- data/ruby/trema/shell/link.rb +61 -0
- data/ruby/trema/shell/reset_stats.rb +50 -0
- data/ruby/trema/shell/run.rb +67 -0
- data/ruby/trema/shell/send_packets.rb +42 -0
- data/ruby/trema/shell/show_stats.rb +49 -0
- data/ruby/trema/shell/up.rb +43 -0
- data/ruby/trema/shell/vhost.rb +44 -0
- data/ruby/trema/shell/vswitch.rb +49 -0
- data/ruby/trema/stats-helper.rb +65 -0
- data/ruby/trema/stats-reply.c +483 -0
- data/ruby/trema/stats-reply.h +53 -0
- data/ruby/trema/stats-request.c +634 -0
- data/ruby/trema/stats-request.h +42 -0
- data/ruby/trema/switch-daemon.rb +74 -0
- data/ruby/trema/switch-disconnected.c +40 -0
- data/ruby/trema/switch-disconnected.h +38 -0
- data/ruby/trema/switch-manager.rb +121 -0
- data/ruby/trema/switch.rb +37 -0
- data/ruby/trema/table-stats-reply.rb +87 -0
- data/ruby/trema/timers.rb +97 -0
- data/ruby/trema/trema.c +122 -0
- data/ruby/trema/tremashark.rb +39 -0
- data/ruby/trema/util.rb +84 -0
- data/ruby/trema/vendor-request.c +193 -0
- data/ruby/trema/vendor-request.h +44 -0
- data/ruby/trema/vendor-stats-reply.rb +62 -0
- data/ruby/trema/vendor.c +152 -0
- data/ruby/trema/vendor.h +52 -0
- data/ruby/trema/version.rb +30 -0
- data/spec/spec_helper.rb +153 -0
- data/spec/support/openflow-message.rb +94 -0
- data/spec/trema/action-enqueue_spec.rb +100 -0
- data/spec/trema/action-output_spec.rb +116 -0
- data/spec/trema/action-set-dl-dst_spec.rb +95 -0
- data/spec/trema/action-set-dl-src_spec.rb +92 -0
- data/spec/trema/action-set-nw-dst_spec.rb +96 -0
- data/spec/trema/action-set-nw-src_spec.rb +97 -0
- data/spec/trema/action-set-nw-tos_spec.rb +88 -0
- data/spec/trema/action-set-tp-dst_spec.rb +88 -0
- data/spec/trema/action-set-tp-src_spec.rb +88 -0
- data/spec/trema/action-set-vlan-pcp_spec.rb +91 -0
- data/spec/trema/action-set-vlan-vid_spec.rb +91 -0
- data/spec/trema/action-strip-vlan_spec.rb +57 -0
- data/spec/trema/action-vendor_spec.rb +90 -0
- data/spec/trema/app_spec.rb +90 -0
- data/spec/trema/barrier-reply_spec.rb +45 -0
- data/spec/trema/barrier-request_spec.rb +83 -0
- data/spec/trema/cli_spec.rb +160 -0
- data/spec/trema/controller_spec.rb +100 -0
- data/spec/trema/dsl/configuration_spec.rb +122 -0
- data/spec/trema/dsl/link_spec.rb +54 -0
- data/spec/trema/dsl/run_spec.rb +78 -0
- data/spec/trema/dsl/runner_spec.rb +239 -0
- data/spec/trema/dsl/switch_spec.rb +77 -0
- data/spec/trema/dsl/syntax_spec.rb +121 -0
- data/spec/trema/dsl/vhost_spec.rb +148 -0
- data/spec/trema/dsl/vswitch_spec.rb +90 -0
- data/spec/trema/echo-reply_spec.rb +49 -0
- data/spec/trema/echo-request_spec.rb +75 -0
- data/spec/trema/error_spec.rb +142 -0
- data/spec/trema/executables_spec.rb +75 -0
- data/spec/trema/features-reply_spec.rb +57 -0
- data/spec/trema/features-request_spec.rb +66 -0
- data/spec/trema/flow-removed_spec.rb +146 -0
- data/spec/trema/get-config-reply_spec.rb +43 -0
- data/spec/trema/get-config-request_spec.rb +82 -0
- data/spec/trema/hello_spec.rb +49 -0
- data/spec/trema/host_spec.rb +193 -0
- data/spec/trema/link_spec.rb +64 -0
- data/spec/trema/list-switches-reply_spec.rb +48 -0
- data/spec/trema/logger_spec.rb +48 -0
- data/spec/trema/mac_spec.rb +115 -0
- data/spec/trema/match_spec.rb +113 -0
- data/spec/trema/open-vswitch_spec.rb +123 -0
- data/spec/trema/openflow-error_spec.rb +141 -0
- data/spec/trema/openflow-switch_spec.rb +56 -0
- data/spec/trema/packet-in_spec.rb +168 -0
- data/spec/trema/packet-out_spec.rb +128 -0
- data/spec/trema/packetin-filter_spec.rb +41 -0
- data/spec/trema/port-mod_spec.rb +101 -0
- data/spec/trema/port-status_spec.rb +108 -0
- data/spec/trema/port_spec.rb +61 -0
- data/spec/trema/process_spec.rb +71 -0
- data/spec/trema/queue-get-config-reply_spec.rb +66 -0
- data/spec/trema/queue-get-config-request_spec.rb +69 -0
- data/spec/trema/set-config_spec.rb +80 -0
- data/spec/trema/shell/vhost_spec.rb +57 -0
- data/spec/trema/shell/vswitch_spec.rb +89 -0
- data/spec/trema/stats-reply_spec.rb +306 -0
- data/spec/trema/stats-request_spec.rb +151 -0
- data/spec/trema/switch-disconnected_spec.rb +58 -0
- data/spec/trema/switch-manager_spec.rb +43 -0
- data/spec/trema/tremashark_spec.rb +41 -0
- data/spec/trema/util_spec.rb +93 -0
- data/spec/trema/vendor-request_spec.rb +79 -0
- data/src/examples/cbench_switch/README +21 -0
- data/src/examples/cbench_switch/cbench-switch.rb +39 -0
- data/src/examples/cbench_switch/cbench_switch.c +68 -0
- data/src/examples/dumper/dumper.c +370 -0
- data/src/examples/dumper/dumper.conf +7 -0
- data/src/examples/dumper/dumper.rb +196 -0
- data/src/examples/hello_trema/README +13 -0
- data/src/examples/hello_trema/hello_trema.c +51 -0
- data/src/examples/hello_trema/hello_trema.conf +3 -0
- data/src/examples/hello_trema/hello_trema.rb +35 -0
- data/src/examples/learning_switch/README +15 -0
- data/src/examples/learning_switch/fdb.rb +112 -0
- data/src/examples/learning_switch/learning-switch.rb +88 -0
- data/src/examples/learning_switch/learning_switch.c +236 -0
- data/src/examples/learning_switch/learning_switch.conf +18 -0
- data/src/examples/list_switches/README +19 -0
- data/src/examples/list_switches/list-switches.rb +45 -0
- data/src/examples/list_switches/list_switches.c +81 -0
- data/src/examples/list_switches/list_switches.conf +15 -0
- data/src/examples/match_compare/match-compare.conf +30 -0
- data/src/examples/match_compare/match-compare.rb +99 -0
- data/src/examples/multi_learning_switch/README +14 -0
- data/src/examples/multi_learning_switch/multi-learning-switch.rb +96 -0
- data/src/examples/multi_learning_switch/multi_learning_switch.c +296 -0
- data/src/examples/multi_learning_switch/multi_learning_switch.conf +17 -0
- data/src/examples/openflow_message/README +11 -0
- data/src/examples/openflow_message/echo-reply.rb +59 -0
- data/src/examples/openflow_message/echo-request.rb +58 -0
- data/src/examples/openflow_message/echo_reply.c +70 -0
- data/src/examples/openflow_message/echo_request.c +70 -0
- data/src/examples/openflow_message/example.rb +63 -0
- data/src/examples/openflow_message/features-request.rb +97 -0
- data/src/examples/openflow_message/features_request.c +168 -0
- data/src/examples/openflow_message/hello.c +70 -0
- data/src/examples/openflow_message/hello.rb +58 -0
- data/src/examples/openflow_message/set-config.rb +59 -0
- data/src/examples/openflow_message/set_config.c +70 -0
- data/src/examples/packet_in/README +15 -0
- data/src/examples/packet_in/packet_in.c +55 -0
- data/src/examples/packet_in/packet_in.conf +15 -0
- data/src/examples/packet_in/packet_in.rb +34 -0
- data/src/examples/packetin_filter_config/README +12 -0
- data/src/examples/packetin_filter_config/add_filter.c +73 -0
- data/src/examples/packetin_filter_config/delete_filter.c +65 -0
- data/src/examples/packetin_filter_config/delete_filter_strict.c +75 -0
- data/src/examples/packetin_filter_config/dump_filter.c +65 -0
- data/src/examples/packetin_filter_config/dump_filter_strict.c +75 -0
- data/src/examples/packetin_filter_config/packetin_filter_config.c +134 -0
- data/src/examples/packetin_filter_config/packetin_filter_config.conf +7 -0
- data/src/examples/packetin_filter_config/utils.c +102 -0
- data/src/examples/packetin_filter_config/utils.h +42 -0
- data/src/examples/repeater_hub/README +8 -0
- data/src/examples/repeater_hub/repeater-hub.rb +43 -0
- data/src/examples/repeater_hub/repeater-hub_spec.rb +156 -0
- data/src/examples/repeater_hub/repeater_hub.c +83 -0
- data/src/examples/repeater_hub/repeater_hub.conf +28 -0
- data/src/examples/switch_info/README +13 -0
- data/src/examples/switch_info/switch_info.c +80 -0
- data/src/examples/switch_info/switch_info.conf +3 -0
- data/src/examples/switch_info/switch_info.rb +46 -0
- data/src/examples/switch_monitor/switch-monitor.conf +3 -0
- data/src/examples/switch_monitor/switch-monitor.rb +58 -0
- data/src/examples/switch_monitor/switch_monitor.c +154 -0
- data/src/examples/traffic_monitor/counter.c +74 -0
- data/src/examples/traffic_monitor/counter.h +48 -0
- data/src/examples/traffic_monitor/counter.rb +46 -0
- data/src/examples/traffic_monitor/fdb.c +76 -0
- data/src/examples/traffic_monitor/fdb.h +50 -0
- data/src/examples/traffic_monitor/fdb.rb +44 -0
- data/src/examples/traffic_monitor/traffic-monitor.rb +100 -0
- data/src/examples/traffic_monitor/traffic_monitor.c +163 -0
- data/src/examples/traffic_monitor/traffic_monitor.conf +16 -0
- data/src/lib/arp.h +61 -0
- data/src/lib/bool.h +49 -0
- data/src/lib/buffer.c +305 -0
- data/src/lib/buffer.h +56 -0
- data/src/lib/byteorder.c +547 -0
- data/src/lib/byteorder.h +110 -0
- data/src/lib/checks.h +42 -0
- data/src/lib/daemon.c +302 -0
- data/src/lib/daemon.h +42 -0
- data/src/lib/doubly_linked_list.c +281 -0
- data/src/lib/doubly_linked_list.h +88 -0
- data/src/lib/ether.c +48 -0
- data/src/lib/ether.h +94 -0
- data/src/lib/etherip.h +46 -0
- data/src/lib/event_handler.c +389 -0
- data/src/lib/event_handler.h +64 -0
- data/src/lib/hash_table.c +417 -0
- data/src/lib/hash_table.h +138 -0
- data/src/lib/icmp.h +74 -0
- data/src/lib/igmp.h +50 -0
- data/src/lib/ipv4.h +50 -0
- data/src/lib/linked_list.c +199 -0
- data/src/lib/linked_list.h +84 -0
- data/src/lib/log.c +402 -0
- data/src/lib/log.h +78 -0
- data/src/lib/match.h +84 -0
- data/src/lib/match_table.c +608 -0
- data/src/lib/match_table.h +51 -0
- data/src/lib/message_queue.c +143 -0
- data/src/lib/message_queue.h +61 -0
- data/src/lib/messenger.c +1714 -0
- data/src/lib/messenger.h +145 -0
- data/src/lib/openflow_application_interface.c +1673 -0
- data/src/lib/openflow_application_interface.h +329 -0
- data/src/lib/openflow_message.c +4051 -0
- data/src/lib/openflow_message.h +288 -0
- data/src/lib/openflow_service_interface.h +59 -0
- data/src/lib/packet_info.c +230 -0
- data/src/lib/packet_info.h +209 -0
- data/src/lib/packet_parser.c +502 -0
- data/src/lib/packetin_filter_interface.c +294 -0
- data/src/lib/packetin_filter_interface.h +127 -0
- data/src/lib/persistent_storage.c +480 -0
- data/src/lib/persistent_storage.h +46 -0
- data/src/lib/stat.c +213 -0
- data/src/lib/stat.h +44 -0
- data/src/lib/tcp.h +67 -0
- data/src/lib/timer.c +350 -0
- data/src/lib/timer.h +53 -0
- data/src/lib/trema.c +710 -0
- data/src/lib/trema.h +79 -0
- data/src/lib/trema_private.c +177 -0
- data/src/lib/trema_private.h +60 -0
- data/src/lib/trema_wrapper.c +56 -0
- data/src/lib/trema_wrapper.h +64 -0
- data/src/lib/udp.h +43 -0
- data/src/lib/utility.c +515 -0
- data/src/lib/utility.h +67 -0
- data/src/lib/wrapper.c +100 -0
- data/src/lib/wrapper.h +76 -0
- data/src/packetin_filter/README +17 -0
- data/src/packetin_filter/packetin_filter.c +575 -0
- data/src/switch_manager/README +20 -0
- data/src/switch_manager/cookie_table.c +292 -0
- data/src/switch_manager/cookie_table.h +72 -0
- data/src/switch_manager/dpid_table.c +110 -0
- data/src/switch_manager/dpid_table.h +46 -0
- data/src/switch_manager/management_interface.h +44 -0
- data/src/switch_manager/ofpmsg_recv.c +482 -0
- data/src/switch_manager/ofpmsg_recv.h +42 -0
- data/src/switch_manager/ofpmsg_send.c +235 -0
- data/src/switch_manager/ofpmsg_send.h +50 -0
- data/src/switch_manager/secure_channel_listener.c +281 -0
- data/src/switch_manager/secure_channel_listener.h +42 -0
- data/src/switch_manager/secure_channel_receiver.c +126 -0
- data/src/switch_manager/secure_channel_receiver.h +43 -0
- data/src/switch_manager/secure_channel_sender.c +126 -0
- data/src/switch_manager/secure_channel_sender.h +43 -0
- data/src/switch_manager/service_interface.c +181 -0
- data/src/switch_manager/service_interface.h +46 -0
- data/src/switch_manager/switch.c +538 -0
- data/src/switch_manager/switch.h +51 -0
- data/src/switch_manager/switch_manager.c +448 -0
- data/src/switch_manager/switch_manager.h +63 -0
- data/src/switch_manager/switchinfo.h +72 -0
- data/src/switch_manager/xid_table.c +184 -0
- data/src/switch_manager/xid_table.h +56 -0
- data/src/tremashark/README +78 -0
- data/src/tremashark/packet_capture.c +357 -0
- data/src/tremashark/pcap_private.h +47 -0
- data/src/tremashark/pcap_queue.c +197 -0
- data/src/tremashark/pcap_queue.h +58 -0
- data/src/tremashark/plugin/.gitignore +6 -0
- data/src/tremashark/plugin/packet-trema/.gitignore +5 -0
- data/src/tremashark/plugin/packet-trema/Makefile +77 -0
- data/src/tremashark/plugin/packet-trema/Makefile.am +110 -0
- data/src/tremashark/plugin/packet-trema/Makefile.common +31 -0
- data/src/tremashark/plugin/packet-trema/moduleinfo.h +41 -0
- data/src/tremashark/plugin/packet-trema/packet-trema.c +1659 -0
- data/src/tremashark/plugin/packet-trema/plugin.c +31 -0
- data/src/tremashark/plugin/user_dlts +2 -0
- data/src/tremashark/queue.c +168 -0
- data/src/tremashark/queue.h +60 -0
- data/src/tremashark/stdin_relay.c +257 -0
- data/src/tremashark/syslog_relay.c +247 -0
- data/src/tremashark/tremashark.c +556 -0
- data/trema +93 -0
- data/trema-config +61 -0
- data/unittests/buffer_stubs.c +74 -0
- data/unittests/cmockery_trema.c +123 -0
- data/unittests/cmockery_trema.h +96 -0
- data/unittests/lib/buffer_test.c +370 -0
- data/unittests/lib/byteorder_test.c +1717 -0
- data/unittests/lib/daemon_test.c +664 -0
- data/unittests/lib/doubly_linked_list_test.c +346 -0
- data/unittests/lib/ether_test.c +127 -0
- data/unittests/lib/hash_table_test.c +278 -0
- data/unittests/lib/linked_list_test.c +343 -0
- data/unittests/lib/log_test.c +459 -0
- data/unittests/lib/match_table_test.c +1509 -0
- data/unittests/lib/message_queue_test.c +379 -0
- data/unittests/lib/messenger_test.c +438 -0
- data/unittests/lib/openflow_application_interface_test.c +3488 -0
- data/unittests/lib/openflow_message_test.c +7337 -0
- data/unittests/lib/packet_info_test.c +544 -0
- data/unittests/lib/packet_parser_test.c +703 -0
- data/unittests/lib/packetin_filter_interface_test.c +723 -0
- data/unittests/lib/persistent_storage_test.c +802 -0
- data/unittests/lib/stat_test.c +291 -0
- data/unittests/lib/test_packets/arp_rep.cap +0 -0
- data/unittests/lib/test_packets/arp_req.cap +0 -0
- data/unittests/lib/test_packets/icmp_echo_rep.cap +0 -0
- data/unittests/lib/test_packets/icmp_echo_req.cap +0 -0
- data/unittests/lib/test_packets/igmp_query_v2.cap +0 -0
- data/unittests/lib/test_packets/ipx.cap +0 -0
- data/unittests/lib/test_packets/lldp.cap +0 -0
- data/unittests/lib/test_packets/lldp_over_ip.cap +0 -0
- data/unittests/lib/test_packets/tcp.cap +0 -0
- data/unittests/lib/test_packets/tcp_syn.cap +0 -0
- data/unittests/lib/test_packets/udp.cap +0 -0
- data/unittests/lib/test_packets/udp_frag_head.cap +0 -0
- data/unittests/lib/test_packets/udp_frag_next.cap +0 -0
- data/unittests/lib/test_packets/vtag_icmp_echo_rep.cap +0 -0
- data/unittests/lib/test_packets/vtag_icmp_echo_req.cap +0 -0
- data/unittests/lib/timer_test.c +248 -0
- data/unittests/lib/trema_private_test.c +323 -0
- data/unittests/lib/trema_test.c +985 -0
- data/unittests/lib/utility_test.c +628 -0
- data/unittests/lib/wrapper_test.c +201 -0
- data/unittests/packetin_filter/packetin_filter_test.c +477 -0
- data/unittests/switch_manager/switch_manager_test.c +1178 -0
- data/unittests/wrapper_stubs.c +39 -0
- data/vendor/.gitignore +6 -0
- data/vendor/README +30 -0
- data/vendor/cmockery-20110428.tar.gz +0 -0
- data/vendor/oflops-0.03.tar.gz +0 -0
- data/vendor/oflops_no_snmp+1.0.0.patch +340 -0
- data/vendor/openflow-1.0.0.tar.gz +0 -0
- data/vendor/openflow.git.tar.gz +0 -0
- data/vendor/openvswitch-1.2.2.tar.gz +0 -0
- data/vendor/ruby-ifconfig-1.2/COPYING +340 -0
- data/vendor/ruby-ifconfig-1.2/Changelog +16 -0
- data/vendor/ruby-ifconfig-1.2/INSTALL +239 -0
- data/vendor/ruby-ifconfig-1.2/README +38 -0
- data/vendor/ruby-ifconfig-1.2/Rakefile +14 -0
- data/vendor/ruby-ifconfig-1.2/TODO +8 -0
- data/vendor/ruby-ifconfig-1.2/ifconfig_examples/darwin.txt +17 -0
- data/vendor/ruby-ifconfig-1.2/ifconfig_examples/dragonflybsd.txt +10 -0
- data/vendor/ruby-ifconfig-1.2/ifconfig_examples/dragonflybsd_netstat.txt +14 -0
- data/vendor/ruby-ifconfig-1.2/ifconfig_examples/freebsd.txt +17 -0
- data/vendor/ruby-ifconfig-1.2/ifconfig_examples/freebsd_netstat.txt +24 -0
- data/vendor/ruby-ifconfig-1.2/ifconfig_examples/linux.txt +60 -0
- data/vendor/ruby-ifconfig-1.2/ifconfig_examples/linux_ethernet.txt +20 -0
- data/vendor/ruby-ifconfig-1.2/ifconfig_examples/netbsd.txt +10 -0
- data/vendor/ruby-ifconfig-1.2/ifconfig_examples/openbsd.txt +36 -0
- data/vendor/ruby-ifconfig-1.2/ifconfig_examples/sunos.txt +10 -0
- data/vendor/ruby-ifconfig-1.2/lib/ifconfig.rb +71 -0
- data/vendor/ruby-ifconfig-1.2/lib/ifconfig/bsd/ifconfig.rb +72 -0
- data/vendor/ruby-ifconfig-1.2/lib/ifconfig/bsd/interface_types.rb +69 -0
- data/vendor/ruby-ifconfig-1.2/lib/ifconfig/bsd/network_types.rb +3 -0
- data/vendor/ruby-ifconfig-1.2/lib/ifconfig/common/ifconfig.rb +84 -0
- data/vendor/ruby-ifconfig-1.2/lib/ifconfig/common/interface_types.rb +130 -0
- data/vendor/ruby-ifconfig-1.2/lib/ifconfig/common/network_types.rb +49 -0
- data/vendor/ruby-ifconfig-1.2/lib/ifconfig/linux/ifconfig.rb +43 -0
- data/vendor/ruby-ifconfig-1.2/lib/ifconfig/linux/interface_types.rb +112 -0
- data/vendor/ruby-ifconfig-1.2/lib/ifconfig/linux/network_types.rb +55 -0
- data/vendor/ruby-ifconfig-1.2/lib/ifconfig/sunos/ifconfig.rb +38 -0
- data/vendor/ruby-ifconfig-1.2/lib/ifconfig/sunos/interface_types.rb +77 -0
- data/vendor/ruby-ifconfig-1.2/lib/ifconfig/sunos/network_types.rb +4 -0
- data/vendor/ruby-ifconfig-1.2/setup.rb +1306 -0
- data/vendor/ruby-ifconfig-1.2/test/test_bsd.rb +35 -0
- data/vendor/ruby-ifconfig-1.2/test/test_darwin.rb +33 -0
- data/vendor/ruby-ifconfig-1.2/test/test_dragonflybsd.rb +35 -0
- data/vendor/ruby-ifconfig-1.2/test/test_helper.rb +4 -0
- data/vendor/ruby-ifconfig-1.2/test/test_linux.rb +31 -0
- data/vendor/ruby-ifconfig-1.2/test/test_netbsd.rb +33 -0
- data/vendor/ruby-ifconfig-1.2/test/test_openbsd.rb +33 -0
- data/vendor/ruby-ifconfig-1.2/test/test_sunos.rb +35 -0
- data/vendor/ruby-ifconfig-1.2/test/unit/tc_darwin.rb +40 -0
- data/vendor/ruby-ifconfig-1.2/test/unit/tc_dragonflybsd.rb +39 -0
- data/vendor/ruby-ifconfig-1.2/test/unit/tc_freebsd.rb +40 -0
- data/vendor/ruby-ifconfig-1.2/test/unit/tc_linux.rb +49 -0
- data/vendor/ruby-ifconfig-1.2/test/unit/tc_netbsd.rb +39 -0
- data/vendor/ruby-ifconfig-1.2/test/unit/tc_openbsd.rb +39 -0
- data/vendor/ruby-ifconfig-1.2/test/unit/tc_sunos.rb +44 -0
- metadata +856 -0
@@ -0,0 +1,370 @@
|
|
1
|
+
/*
|
2
|
+
* Unit tests for buf functions and macros.
|
3
|
+
*
|
4
|
+
* Author: Shin-ya Zenke
|
5
|
+
*
|
6
|
+
* Copyright (C) 2008-2012 NEC Corporation
|
7
|
+
*
|
8
|
+
* This program is free software; you can redistribute it and/or modify
|
9
|
+
* it under the terms of the GNU General Public License, version 2, as
|
10
|
+
* published by the Free Software Foundation.
|
11
|
+
*
|
12
|
+
* This program is distributed in the hope that it will be useful,
|
13
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
* GNU General Public License for more details.
|
16
|
+
*
|
17
|
+
* You should have received a copy of the GNU General Public License along
|
18
|
+
* with this program; if not, write to the Free Software Foundation, Inc.,
|
19
|
+
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
20
|
+
*/
|
21
|
+
|
22
|
+
|
23
|
+
#include <stdio.h>
|
24
|
+
#include <stdlib.h>
|
25
|
+
#include <string.h>
|
26
|
+
#include "buffer.h"
|
27
|
+
#include "checks.h"
|
28
|
+
#include "cmockery_trema.h"
|
29
|
+
#include "openflow.h"
|
30
|
+
#include "packet_info.h"
|
31
|
+
|
32
|
+
|
33
|
+
typedef struct tea {
|
34
|
+
const char *name;
|
35
|
+
const char *origin;
|
36
|
+
} tea;
|
37
|
+
|
38
|
+
static tea CEYLON = { "Ceylon", "Sri Lanka" };
|
39
|
+
static tea DARJEELING = { "Darjeeling", "India" };
|
40
|
+
|
41
|
+
|
42
|
+
typedef struct private_buffer {
|
43
|
+
buffer public;
|
44
|
+
size_t real_length;
|
45
|
+
void *top;
|
46
|
+
pthread_mutex_t *mutex;
|
47
|
+
} private_buffer;
|
48
|
+
|
49
|
+
|
50
|
+
/********************************************************************************
|
51
|
+
* Tests.
|
52
|
+
********************************************************************************/
|
53
|
+
|
54
|
+
static void
|
55
|
+
test_alloc_buffer_succeeds() {
|
56
|
+
buffer *buf = alloc_buffer();
|
57
|
+
|
58
|
+
assert_true( buf != NULL );
|
59
|
+
|
60
|
+
free_buffer( buf );
|
61
|
+
}
|
62
|
+
|
63
|
+
|
64
|
+
static void
|
65
|
+
test_alloc_buffer_with_length_succeeds() {
|
66
|
+
buffer *buf = alloc_buffer_with_length( sizeof( tea ) );
|
67
|
+
assert_true( buf != NULL );
|
68
|
+
free_buffer( buf );
|
69
|
+
}
|
70
|
+
|
71
|
+
|
72
|
+
static void
|
73
|
+
test_free_buffer_succeeds() {
|
74
|
+
buffer *buf = alloc_buffer();
|
75
|
+
assert_true( buf != NULL );
|
76
|
+
free_buffer( buf );
|
77
|
+
}
|
78
|
+
|
79
|
+
|
80
|
+
static void
|
81
|
+
test_append_front_buffer_new_alloc_succeeds() {
|
82
|
+
buffer *buf = alloc_buffer();
|
83
|
+
assert_true( buf != NULL );
|
84
|
+
void *data_pointer = append_front_buffer( buf, sizeof( tea ) );
|
85
|
+
assert_true( data_pointer != NULL );
|
86
|
+
assert_true( buf->length == sizeof( tea ) );
|
87
|
+
free_buffer( buf );
|
88
|
+
}
|
89
|
+
|
90
|
+
|
91
|
+
static void
|
92
|
+
test_append_front_twice_suceeds() {
|
93
|
+
buffer *buf = alloc_buffer_with_length( sizeof( tea ) * 2 );
|
94
|
+
assert_true( buf != NULL );
|
95
|
+
|
96
|
+
void *data_pointer = append_front_buffer( buf, sizeof( tea ) );
|
97
|
+
assert_true( data_pointer != NULL );
|
98
|
+
assert_true( buf->length == sizeof( tea ) );
|
99
|
+
|
100
|
+
memcpy( data_pointer, &CEYLON, sizeof( tea ) );
|
101
|
+
|
102
|
+
data_pointer = append_front_buffer( buf, sizeof( tea ) );
|
103
|
+
assert_true( data_pointer != NULL );
|
104
|
+
assert_true( buf->length == sizeof( tea ) * 2 );
|
105
|
+
|
106
|
+
tea *tea_data = ( tea * ) ( ( char * ) data_pointer + sizeof( tea ) );
|
107
|
+
assert_true( 0 == strcmp( tea_data->name, CEYLON.name ) );
|
108
|
+
|
109
|
+
free_buffer( buf );
|
110
|
+
}
|
111
|
+
|
112
|
+
|
113
|
+
static void
|
114
|
+
test_append_front_buffer_succeeds() {
|
115
|
+
buffer *buf = alloc_buffer_with_length( sizeof( tea ) * 2 );
|
116
|
+
assert_true( buf != NULL );
|
117
|
+
|
118
|
+
void *data_pointer = append_front_buffer( buf, sizeof( tea ) );
|
119
|
+
assert_true( data_pointer != NULL );
|
120
|
+
assert_true( buf->length == sizeof( tea ) );
|
121
|
+
|
122
|
+
data_pointer = append_front_buffer( buf, sizeof( tea ) );
|
123
|
+
assert_true( data_pointer != NULL );
|
124
|
+
assert_true( buf->length == sizeof( tea ) * 2 );
|
125
|
+
|
126
|
+
free_buffer( buf );
|
127
|
+
}
|
128
|
+
|
129
|
+
|
130
|
+
static void
|
131
|
+
test_append_front_buffer_resize_succeeds() {
|
132
|
+
buffer *buf = alloc_buffer_with_length( sizeof( tea ) );
|
133
|
+
assert_true( buf != NULL );
|
134
|
+
|
135
|
+
void *data_pointer = append_front_buffer( buf, sizeof( tea ) * 2 );
|
136
|
+
assert_true( data_pointer != NULL );
|
137
|
+
assert_true( buf->length == sizeof( tea ) * 2 );
|
138
|
+
|
139
|
+
free_buffer( buf );
|
140
|
+
}
|
141
|
+
|
142
|
+
|
143
|
+
static void
|
144
|
+
test_remove_front_buffer_succeeds() {
|
145
|
+
buffer *buf = alloc_buffer_with_length( sizeof( tea ) * 2 );
|
146
|
+
assert_true( buf != NULL );
|
147
|
+
|
148
|
+
void *data_pointer = append_front_buffer( buf, sizeof( tea ) * 2 );
|
149
|
+
assert_true( data_pointer != NULL );
|
150
|
+
assert_true( buf->length == sizeof( tea ) * 2 );
|
151
|
+
|
152
|
+
data_pointer = remove_front_buffer( buf, sizeof( tea ) );
|
153
|
+
assert_true( data_pointer != NULL );
|
154
|
+
assert_true( buf->length == sizeof( tea ) );
|
155
|
+
|
156
|
+
free_buffer( buf );
|
157
|
+
}
|
158
|
+
|
159
|
+
|
160
|
+
static void
|
161
|
+
test_remove_front_buffer_text_insert_succeeds() {
|
162
|
+
buffer *buf = alloc_buffer_with_length( sizeof( tea ) * 2 );
|
163
|
+
assert_true( buf != NULL );
|
164
|
+
|
165
|
+
void *data_pointer = append_front_buffer( buf, sizeof( tea ) * 2 );
|
166
|
+
assert_true( data_pointer != NULL );
|
167
|
+
assert_true( buf->length == sizeof( tea ) * 2 );
|
168
|
+
|
169
|
+
memcpy( ( char * ) data_pointer + sizeof( tea ), &CEYLON, sizeof( tea ) );
|
170
|
+
|
171
|
+
data_pointer = remove_front_buffer( buf, sizeof( tea ) );
|
172
|
+
assert_true( data_pointer != NULL );
|
173
|
+
assert_true( buf->length == sizeof( tea ) );
|
174
|
+
tea *tea_data = ( tea * ) ( ( char * ) buf->data );
|
175
|
+
assert_true( 0 == strcmp( tea_data->name, CEYLON.name ) );
|
176
|
+
|
177
|
+
free_buffer( buf );
|
178
|
+
}
|
179
|
+
|
180
|
+
|
181
|
+
static void
|
182
|
+
test_remove_front_buffer_all_removed() {
|
183
|
+
buffer *buf = alloc_buffer_with_length( sizeof( tea ) );
|
184
|
+
assert_true( buf != NULL );
|
185
|
+
|
186
|
+
void *data_pointer = append_front_buffer( buf, sizeof( tea ) );
|
187
|
+
assert_true( data_pointer != NULL );
|
188
|
+
assert_true( data_pointer == buf->data );
|
189
|
+
|
190
|
+
data_pointer = remove_front_buffer( buf, sizeof( tea ) );
|
191
|
+
assert_true( data_pointer != NULL );
|
192
|
+
assert_true( buf->length == 0 );
|
193
|
+
|
194
|
+
free_buffer( buf );
|
195
|
+
}
|
196
|
+
|
197
|
+
|
198
|
+
static void
|
199
|
+
test_append_back_buffer_succeeds() {
|
200
|
+
buffer *buf = alloc_buffer_with_length( sizeof( tea ) * 2 );
|
201
|
+
assert_true( buf != NULL );
|
202
|
+
|
203
|
+
void *data_pointer = append_back_buffer( buf, sizeof( tea ) );
|
204
|
+
assert_true( data_pointer != NULL );
|
205
|
+
assert_true( buf->length == sizeof( tea ) );
|
206
|
+
|
207
|
+
free_buffer( buf );
|
208
|
+
}
|
209
|
+
|
210
|
+
|
211
|
+
static void
|
212
|
+
test_append_back_twice_succeeds() {
|
213
|
+
buffer *buf = alloc_buffer_with_length( sizeof( tea ) * 3 );
|
214
|
+
assert_true( buf != NULL );
|
215
|
+
|
216
|
+
void *data_pointer = append_back_buffer( buf, sizeof( tea ) );
|
217
|
+
assert_true( data_pointer != NULL );
|
218
|
+
assert_true( buf->length == sizeof( tea ) );
|
219
|
+
|
220
|
+
memcpy( data_pointer, &CEYLON, sizeof( tea ) );
|
221
|
+
|
222
|
+
data_pointer = append_back_buffer( buf, sizeof( tea ) );
|
223
|
+
assert_true( data_pointer != NULL );
|
224
|
+
assert_true( buf->length == sizeof( tea ) * 2 );
|
225
|
+
|
226
|
+
memcpy( data_pointer, &DARJEELING, sizeof( tea ) );
|
227
|
+
|
228
|
+
tea *tea_data = ( tea * ) ( ( char * ) buf->data );
|
229
|
+
assert_true( 0 == strcmp( tea_data->name, CEYLON.name ) );
|
230
|
+
tea_data = ( tea * ) ( ( char * ) buf->data + sizeof( tea ) );
|
231
|
+
assert_true( 0 == strcmp( tea_data->name, DARJEELING.name ) );
|
232
|
+
|
233
|
+
free_buffer( buf );
|
234
|
+
}
|
235
|
+
|
236
|
+
|
237
|
+
static void
|
238
|
+
test_append_back_buffer_resize_succeeds() {
|
239
|
+
buffer *buf = alloc_buffer_with_length( sizeof( tea ) );
|
240
|
+
assert_true( buf != NULL );
|
241
|
+
|
242
|
+
void *data_pointer = append_back_buffer( buf, sizeof( tea ) * 2 );
|
243
|
+
assert_true( data_pointer != NULL );
|
244
|
+
assert_true( buf->length == sizeof( tea ) * 2 );
|
245
|
+
|
246
|
+
free_buffer( buf );
|
247
|
+
}
|
248
|
+
|
249
|
+
|
250
|
+
static void
|
251
|
+
test_append_back_buffer_succeeds_if_initialize_length_is_0() {
|
252
|
+
buffer *buf = alloc_buffer();
|
253
|
+
assert_true( buf != NULL );
|
254
|
+
|
255
|
+
void *data_pointer = append_back_buffer( buf, sizeof( tea ) );
|
256
|
+
assert_true( data_pointer != NULL );
|
257
|
+
assert_true( buf->length == sizeof( tea ) );
|
258
|
+
|
259
|
+
free_buffer( buf );
|
260
|
+
}
|
261
|
+
|
262
|
+
|
263
|
+
static void
|
264
|
+
test_duplicate_buffer_succeeds() {
|
265
|
+
buffer *buf = alloc_buffer_with_length( 1024 );
|
266
|
+
assert_true( buf != NULL );
|
267
|
+
unsigned char *data = append_back_buffer( buf, 1024 );
|
268
|
+
int i;
|
269
|
+
for ( i = 0; i < 1024; i++ ) {
|
270
|
+
data[ i ] = ( unsigned char ) ( i % 0xff ) ;
|
271
|
+
}
|
272
|
+
|
273
|
+
buffer *duplicate = duplicate_buffer( buf );
|
274
|
+
assert_true( duplicate != NULL );
|
275
|
+
assert_true( duplicate->user_data == buf->user_data );
|
276
|
+
assert_true( duplicate->length == buf->length );
|
277
|
+
assert_memory_equal( duplicate->data, buf->data, 1024 );
|
278
|
+
|
279
|
+
free_buffer( buf );
|
280
|
+
free_buffer( duplicate );
|
281
|
+
}
|
282
|
+
|
283
|
+
|
284
|
+
static void
|
285
|
+
test_duplicate_buffer_succeeds_if_initialize_length_is_0() {
|
286
|
+
buffer *buf = alloc_buffer();
|
287
|
+
assert_true( buf != NULL );
|
288
|
+
assert_true( buf->data == NULL );
|
289
|
+
|
290
|
+
buffer *duplicate = duplicate_buffer( buf );
|
291
|
+
assert_true( duplicate != NULL );
|
292
|
+
assert_true( duplicate->data == NULL );
|
293
|
+
assert_true( duplicate->user_data == NULL );
|
294
|
+
assert_true( duplicate->length == 0 );
|
295
|
+
|
296
|
+
free_buffer( buf );
|
297
|
+
free_buffer( duplicate );
|
298
|
+
}
|
299
|
+
|
300
|
+
|
301
|
+
static void
|
302
|
+
dump_function( const char *format, ... ) {
|
303
|
+
char hex[ 1000 ];
|
304
|
+
|
305
|
+
va_list args;
|
306
|
+
va_start( args, format );
|
307
|
+
vsnprintf( hex, sizeof( hex ), format, args );
|
308
|
+
va_end( args );
|
309
|
+
|
310
|
+
check_expected( hex );
|
311
|
+
}
|
312
|
+
|
313
|
+
|
314
|
+
static void
|
315
|
+
test_dump_buffer() {
|
316
|
+
buffer *buf = alloc_buffer();
|
317
|
+
|
318
|
+
void *datap = append_back_buffer( buf, ( size_t ) 1 );
|
319
|
+
int data255 = 255;
|
320
|
+
memcpy( datap, &data255, ( size_t ) 1 );
|
321
|
+
|
322
|
+
expect_string( dump_function, hex, "ff" );
|
323
|
+
dump_buffer( buf, dump_function );
|
324
|
+
|
325
|
+
free_buffer( buf );
|
326
|
+
}
|
327
|
+
|
328
|
+
|
329
|
+
/********************************************************************************
|
330
|
+
* Run tests.
|
331
|
+
********************************************************************************/
|
332
|
+
|
333
|
+
int
|
334
|
+
main() {
|
335
|
+
const UnitTest tests[] = {
|
336
|
+
unit_test( test_alloc_buffer_succeeds ),
|
337
|
+
unit_test( test_alloc_buffer_with_length_succeeds ),
|
338
|
+
|
339
|
+
unit_test( test_free_buffer_succeeds ),
|
340
|
+
|
341
|
+
unit_test( test_append_front_twice_suceeds ),
|
342
|
+
unit_test( test_append_front_buffer_succeeds ),
|
343
|
+
unit_test( test_append_front_buffer_resize_succeeds ),
|
344
|
+
unit_test( test_append_front_buffer_new_alloc_succeeds ),
|
345
|
+
|
346
|
+
unit_test( test_remove_front_buffer_succeeds ),
|
347
|
+
unit_test( test_remove_front_buffer_text_insert_succeeds ),
|
348
|
+
unit_test( test_remove_front_buffer_all_removed ),
|
349
|
+
|
350
|
+
unit_test( test_append_back_buffer_succeeds ),
|
351
|
+
unit_test( test_append_back_buffer_resize_succeeds ),
|
352
|
+
unit_test( test_append_back_buffer_succeeds_if_initialize_length_is_0 ),
|
353
|
+
unit_test( test_append_back_twice_succeeds ),
|
354
|
+
|
355
|
+
unit_test( test_duplicate_buffer_succeeds ),
|
356
|
+
unit_test( test_duplicate_buffer_succeeds_if_initialize_length_is_0 ),
|
357
|
+
|
358
|
+
unit_test( test_dump_buffer ),
|
359
|
+
};
|
360
|
+
setup_leak_detector();
|
361
|
+
return run_tests( tests );
|
362
|
+
}
|
363
|
+
|
364
|
+
|
365
|
+
/*
|
366
|
+
* Local variables:
|
367
|
+
* c-basic-offset: 2
|
368
|
+
* indent-tabs-mode: nil
|
369
|
+
* End:
|
370
|
+
*/
|
@@ -0,0 +1,1717 @@
|
|
1
|
+
/*
|
2
|
+
* Unit tests for byteorder converters.
|
3
|
+
*
|
4
|
+
* Author: Yasunobu Chiba
|
5
|
+
*
|
6
|
+
* Copyright (C) 2008-2012 NEC Corporation
|
7
|
+
*
|
8
|
+
* This program is free software; you can redistribute it and/or modify
|
9
|
+
* it under the terms of the GNU General Public License, version 2, as
|
10
|
+
* published by the Free Software Foundation.
|
11
|
+
*
|
12
|
+
* This program is distributed in the hope that it will be useful,
|
13
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
* GNU General Public License for more details.
|
16
|
+
*
|
17
|
+
* You should have received a copy of the GNU General Public License along
|
18
|
+
* with this program; if not, write to the Free Software Foundation, Inc.,
|
19
|
+
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
20
|
+
*/
|
21
|
+
|
22
|
+
|
23
|
+
#include <arpa/inet.h>
|
24
|
+
#include <openflow.h>
|
25
|
+
#include <stdlib.h>
|
26
|
+
#include <string.h>
|
27
|
+
#include "byteorder.h"
|
28
|
+
#include "checks.h"
|
29
|
+
#include "cmockery_trema.h"
|
30
|
+
#include "log.h"
|
31
|
+
#include "utility.h"
|
32
|
+
#include "wrapper.h"
|
33
|
+
|
34
|
+
|
35
|
+
void
|
36
|
+
mock_die( const char *format, ... ) {
|
37
|
+
UNUSED( format );
|
38
|
+
|
39
|
+
mock_assert( false, "mock_die", __FILE__, __LINE__ );
|
40
|
+
}
|
41
|
+
|
42
|
+
|
43
|
+
/********************************************************************************
|
44
|
+
* Helpers.
|
45
|
+
********************************************************************************/
|
46
|
+
|
47
|
+
static const uint8_t MAC_ADDR_X[ OFP_ETH_ALEN ] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x07 };
|
48
|
+
static const uint8_t MAC_ADDR_Y[ OFP_ETH_ALEN ] = { 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d };
|
49
|
+
static const uint32_t IP_ADDR_X = 0x01020304;
|
50
|
+
static const uint32_t IP_ADDR_Y = 0x0a090807;
|
51
|
+
static const uint16_t TP_PORT_X = 1024;
|
52
|
+
static const uint16_t TP_PORT_Y = 2048;
|
53
|
+
static const char *PORT_NAME = "port 1";
|
54
|
+
static const uint32_t PORT_FEATURES = ( OFPPF_10MB_HD | OFPPF_10MB_FD | OFPPF_100MB_HD |
|
55
|
+
OFPPF_100MB_FD | OFPPF_1GB_HD | OFPPF_1GB_FD |
|
56
|
+
OFPPF_COPPER | OFPPF_AUTONEG | OFPPF_PAUSE );
|
57
|
+
static const struct ofp_match MATCH = { OFPFW_ALL, 1,
|
58
|
+
{ 0x01, 0x02, 0x03, 0x04, 0x05, 0x07 },
|
59
|
+
{ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d },
|
60
|
+
1, 1, { 0 }, 0x800, 1, 0x6, { 0, 0 },
|
61
|
+
0x0a090807, 0x0a090807, 1024, 2048 };
|
62
|
+
static const uint64_t COOKIE = 0x0102030405060708ULL;
|
63
|
+
static const uint64_t PACKET_COUNT = 10000;
|
64
|
+
static const uint64_t BYTE_COUNT = 10000000;
|
65
|
+
static const char *TABLE_NAME = "flow table 1";
|
66
|
+
|
67
|
+
|
68
|
+
static struct ofp_action_output *
|
69
|
+
create_action_output() {
|
70
|
+
struct ofp_action_output *action = xmalloc( sizeof( struct ofp_action_output ) );
|
71
|
+
memset( action, 0, sizeof( struct ofp_action_output ) );
|
72
|
+
|
73
|
+
action->type = htons( OFPAT_OUTPUT );
|
74
|
+
action->len = htons( 8 );
|
75
|
+
action->port = htons( 1 );
|
76
|
+
action->max_len = htons( 2048 );
|
77
|
+
|
78
|
+
return action;
|
79
|
+
}
|
80
|
+
|
81
|
+
|
82
|
+
static struct ofp_action_vlan_vid *
|
83
|
+
create_action_vlan_vid() {
|
84
|
+
struct ofp_action_vlan_vid *action = xmalloc( sizeof( struct ofp_action_vlan_vid ) );
|
85
|
+
memset( action, 0, sizeof( struct ofp_action_vlan_vid ) );
|
86
|
+
|
87
|
+
action->type = htons( OFPAT_SET_VLAN_VID );
|
88
|
+
action->len = htons( 8 );
|
89
|
+
action->vlan_vid = htons( 256 );
|
90
|
+
|
91
|
+
return action;
|
92
|
+
}
|
93
|
+
|
94
|
+
|
95
|
+
static struct ofp_action_vlan_pcp *
|
96
|
+
create_action_vlan_pcp() {
|
97
|
+
struct ofp_action_vlan_pcp *action = xmalloc( sizeof( struct ofp_action_vlan_pcp ) );
|
98
|
+
memset( action, 0, sizeof( struct ofp_action_vlan_pcp ) );
|
99
|
+
|
100
|
+
action->type = htons( OFPAT_SET_VLAN_PCP );
|
101
|
+
action->len = htons( 8 );
|
102
|
+
action->vlan_pcp = 3;
|
103
|
+
|
104
|
+
return action;
|
105
|
+
}
|
106
|
+
|
107
|
+
|
108
|
+
static struct ofp_action_header *
|
109
|
+
create_action_strip_vlan() {
|
110
|
+
struct ofp_action_header *action = xmalloc( sizeof( struct ofp_action_header ) );
|
111
|
+
memset( action, 0, sizeof( struct ofp_action_header ) );
|
112
|
+
|
113
|
+
action->type = htons( OFPAT_STRIP_VLAN );
|
114
|
+
action->len = htons( 8 );
|
115
|
+
|
116
|
+
return action;
|
117
|
+
}
|
118
|
+
|
119
|
+
|
120
|
+
static struct ofp_action_dl_addr *
|
121
|
+
create_action_dl_addr() {
|
122
|
+
struct ofp_action_dl_addr *action = xmalloc( sizeof( struct ofp_action_dl_addr ) );
|
123
|
+
memset( action, 0, sizeof( struct ofp_action_dl_addr ) );
|
124
|
+
|
125
|
+
action->type = htons( OFPAT_SET_DL_SRC );
|
126
|
+
action->len = htons( 16 );
|
127
|
+
memcpy( action->dl_addr, MAC_ADDR_X, sizeof( action->dl_addr ) );
|
128
|
+
|
129
|
+
return action;
|
130
|
+
}
|
131
|
+
|
132
|
+
|
133
|
+
static struct ofp_action_nw_addr *
|
134
|
+
create_action_nw_addr() {
|
135
|
+
struct ofp_action_nw_addr *action = xmalloc( sizeof( struct ofp_action_nw_addr ) );
|
136
|
+
memset( action, 0, sizeof( struct ofp_action_nw_addr ) );
|
137
|
+
|
138
|
+
action->type = htons( OFPAT_SET_NW_SRC );
|
139
|
+
action->len = htons( 8 );
|
140
|
+
action->nw_addr = htonl( IP_ADDR_X );
|
141
|
+
|
142
|
+
return action;
|
143
|
+
}
|
144
|
+
|
145
|
+
|
146
|
+
static struct ofp_action_nw_tos *
|
147
|
+
create_action_nw_tos() {
|
148
|
+
struct ofp_action_nw_tos *action = xmalloc( sizeof( struct ofp_action_nw_tos ) );
|
149
|
+
memset( action, 0, sizeof( struct ofp_action_nw_tos ) );
|
150
|
+
|
151
|
+
action->type = htons( OFPAT_SET_NW_TOS );
|
152
|
+
action->len = htons( 8 );
|
153
|
+
action->nw_tos = 3;
|
154
|
+
|
155
|
+
return action;
|
156
|
+
}
|
157
|
+
|
158
|
+
|
159
|
+
static struct ofp_action_tp_port *
|
160
|
+
create_action_tp_port() {
|
161
|
+
struct ofp_action_tp_port *action = xmalloc( sizeof( struct ofp_action_tp_port ) );
|
162
|
+
memset( action, 0, sizeof( struct ofp_action_tp_port ) );
|
163
|
+
|
164
|
+
action->type = htons( OFPAT_SET_TP_SRC );
|
165
|
+
action->len = htons( 8 );
|
166
|
+
action->tp_port = htons( TP_PORT_X );
|
167
|
+
|
168
|
+
return action;
|
169
|
+
}
|
170
|
+
|
171
|
+
|
172
|
+
static struct ofp_action_enqueue *
|
173
|
+
create_action_enqueue() {
|
174
|
+
struct ofp_action_enqueue *action = xmalloc( sizeof( struct ofp_action_enqueue ) );
|
175
|
+
memset( action, 0, sizeof( struct ofp_action_enqueue ) );
|
176
|
+
|
177
|
+
action->type = htons( OFPAT_ENQUEUE );
|
178
|
+
action->len = htons( 16 );
|
179
|
+
action->port = htons( 1 );
|
180
|
+
action->queue_id = htonl( 8 );
|
181
|
+
|
182
|
+
return action;
|
183
|
+
}
|
184
|
+
|
185
|
+
|
186
|
+
static struct ofp_action_vendor_header *
|
187
|
+
create_action_vendor() {
|
188
|
+
struct ofp_action_vendor_header *action = xmalloc( sizeof( struct ofp_action_vendor_header ) );
|
189
|
+
memset( action, 0, sizeof( struct ofp_action_vendor_header ) );
|
190
|
+
|
191
|
+
action->type = htons( OFPAT_VENDOR );
|
192
|
+
action->len = htons( 8 );
|
193
|
+
action->vendor = htonl( 2048 );
|
194
|
+
|
195
|
+
return action;
|
196
|
+
}
|
197
|
+
|
198
|
+
|
199
|
+
/********************************************************************************
|
200
|
+
* ntoh_match() test.
|
201
|
+
********************************************************************************/
|
202
|
+
|
203
|
+
void
|
204
|
+
test_ntoh_match() {
|
205
|
+
struct ofp_match dst;
|
206
|
+
struct ofp_match src;
|
207
|
+
|
208
|
+
memset( &src, 0, sizeof( struct ofp_match ) );
|
209
|
+
memset( &dst, 0, sizeof( struct ofp_match ) );
|
210
|
+
|
211
|
+
src.wildcards = htonl( OFPFW_ALL );
|
212
|
+
src.in_port = htons( 1 );
|
213
|
+
memcpy( &src.dl_src, MAC_ADDR_X, sizeof( src.dl_src ) );
|
214
|
+
memcpy( &src.dl_dst, MAC_ADDR_Y, sizeof( src.dl_dst ) );
|
215
|
+
src.dl_vlan = htons( 1 );
|
216
|
+
src.dl_vlan_pcp = 1;
|
217
|
+
src.dl_type = htons( 0x800 );
|
218
|
+
src.nw_tos = 1;
|
219
|
+
src.nw_proto = 0x6;
|
220
|
+
src.nw_src = htonl( IP_ADDR_X );
|
221
|
+
src.nw_dst = htonl( IP_ADDR_Y );
|
222
|
+
src.tp_src = htons( TP_PORT_X );
|
223
|
+
src.tp_dst = htons( TP_PORT_Y );
|
224
|
+
|
225
|
+
ntoh_match( &dst, &src );
|
226
|
+
|
227
|
+
assert_int_equal( ( int ) htonl( dst.wildcards ), ( int ) src.wildcards );
|
228
|
+
assert_int_equal( htons( dst.in_port ), src.in_port );
|
229
|
+
assert_memory_equal( dst.dl_src, src.dl_src, sizeof( src.dl_src ) );
|
230
|
+
assert_memory_equal( dst.dl_dst, src.dl_dst, sizeof( src.dl_dst ) );
|
231
|
+
assert_int_equal( htons( dst.dl_vlan ), src.dl_vlan );
|
232
|
+
assert_int_equal( dst.dl_vlan_pcp, src.dl_vlan_pcp );
|
233
|
+
assert_int_equal( htons( dst.dl_type ), src.dl_type );
|
234
|
+
assert_int_equal( dst.nw_tos, src.nw_tos );
|
235
|
+
assert_int_equal( dst.nw_proto, src.nw_proto );
|
236
|
+
assert_int_equal( ( int ) htonl( dst.nw_src ), ( int ) src.nw_src );
|
237
|
+
assert_int_equal( ( int ) htonl( dst.nw_dst ), ( int ) src.nw_dst );
|
238
|
+
assert_int_equal( htons( dst.tp_src ), src.tp_src );
|
239
|
+
assert_int_equal( htons( dst.tp_dst ), src.tp_dst );
|
240
|
+
}
|
241
|
+
|
242
|
+
|
243
|
+
/********************************************************************************
|
244
|
+
* ntoh_phy_port() test.
|
245
|
+
********************************************************************************/
|
246
|
+
|
247
|
+
void
|
248
|
+
test_ntoh_phy_port() {
|
249
|
+
struct ofp_phy_port dst;
|
250
|
+
struct ofp_phy_port src;
|
251
|
+
|
252
|
+
memset( &src, 0, sizeof( struct ofp_phy_port ) );
|
253
|
+
memset( &dst, 0, sizeof( struct ofp_phy_port ) );
|
254
|
+
|
255
|
+
src.port_no = htons( 1 );
|
256
|
+
memcpy( src.hw_addr, MAC_ADDR_X, sizeof( src.hw_addr ) );
|
257
|
+
memset( src.name, '\0', OFP_MAX_PORT_NAME_LEN );
|
258
|
+
memcpy( src.name, PORT_NAME, strlen( PORT_NAME ) );
|
259
|
+
src.config = htonl( OFPPC_PORT_DOWN );
|
260
|
+
src.state = htonl( OFPPS_LINK_DOWN );
|
261
|
+
src.curr = htonl( OFPPF_1GB_FD | OFPPF_COPPER | OFPPF_PAUSE );
|
262
|
+
src.advertised = htonl( PORT_FEATURES );
|
263
|
+
src.supported = htonl( PORT_FEATURES );
|
264
|
+
src.peer = htonl( PORT_FEATURES );
|
265
|
+
|
266
|
+
ntoh_phy_port( &dst, &src );
|
267
|
+
|
268
|
+
assert_int_equal( htons( dst.port_no ), src.port_no );
|
269
|
+
assert_memory_equal( dst.hw_addr, src.hw_addr, sizeof( src.hw_addr ) );
|
270
|
+
assert_memory_equal( dst.name, src.name, OFP_MAX_PORT_NAME_LEN );
|
271
|
+
assert_int_equal( ( int ) htonl( dst.config ), ( int ) src.config );
|
272
|
+
assert_int_equal( ( int ) htonl( dst.state ), ( int ) src.state );
|
273
|
+
assert_int_equal( ( int ) htonl( dst.curr ), ( int ) src.curr );
|
274
|
+
assert_int_equal( ( int ) htonl( dst.advertised ), ( int ) src.advertised );
|
275
|
+
assert_int_equal( ( int ) htonl( dst.supported ), ( int ) src.supported );
|
276
|
+
assert_int_equal( ( int ) htonl( dst.peer ), ( int ) src.peer );
|
277
|
+
}
|
278
|
+
|
279
|
+
|
280
|
+
/********************************************************************************
|
281
|
+
* ntoh_action_output() test.
|
282
|
+
********************************************************************************/
|
283
|
+
|
284
|
+
void
|
285
|
+
test_ntoh_action_output() {
|
286
|
+
struct ofp_action_output dst;
|
287
|
+
|
288
|
+
memset( &dst, 0, sizeof( struct ofp_action_output ) );
|
289
|
+
|
290
|
+
struct ofp_action_output *src = create_action_output();
|
291
|
+
|
292
|
+
ntoh_action_output( &dst, src );
|
293
|
+
|
294
|
+
assert_int_equal( htons( dst.type ), src->type );
|
295
|
+
assert_int_equal( htons( dst.len ), src->len );
|
296
|
+
assert_int_equal( htons( dst.port ), src->port );
|
297
|
+
assert_int_equal( htons( dst.max_len ), src->max_len );
|
298
|
+
|
299
|
+
xfree( src );
|
300
|
+
}
|
301
|
+
|
302
|
+
|
303
|
+
/********************************************************************************
|
304
|
+
* ntoh_action_vlan_vid() test.
|
305
|
+
********************************************************************************/
|
306
|
+
|
307
|
+
void
|
308
|
+
test_ntoh_action_vlan_vid() {
|
309
|
+
struct ofp_action_vlan_vid dst;
|
310
|
+
|
311
|
+
memset( &dst, 0, sizeof( struct ofp_action_vlan_vid ) );
|
312
|
+
|
313
|
+
struct ofp_action_vlan_vid *src = create_action_vlan_vid();
|
314
|
+
|
315
|
+
ntoh_action_vlan_vid( &dst, src );
|
316
|
+
|
317
|
+
assert_int_equal( htons( dst.type ), src->type );
|
318
|
+
assert_int_equal( htons( dst.len ), src->len );
|
319
|
+
assert_int_equal( htons( dst.vlan_vid ), src->vlan_vid );
|
320
|
+
|
321
|
+
xfree( src );
|
322
|
+
}
|
323
|
+
|
324
|
+
|
325
|
+
/********************************************************************************
|
326
|
+
* ntoh_action_vlan_pcp() test.
|
327
|
+
********************************************************************************/
|
328
|
+
|
329
|
+
void
|
330
|
+
test_ntoh_action_vlan_pcp() {
|
331
|
+
struct ofp_action_vlan_pcp dst;
|
332
|
+
|
333
|
+
memset( &dst, 0, sizeof( struct ofp_action_vlan_pcp ) );
|
334
|
+
|
335
|
+
struct ofp_action_vlan_pcp *src = create_action_vlan_pcp();
|
336
|
+
|
337
|
+
ntoh_action_vlan_pcp( &dst, src );
|
338
|
+
|
339
|
+
assert_int_equal( htons( dst.type ), src->type );
|
340
|
+
assert_int_equal( htons( dst.len ), src->len );
|
341
|
+
assert_int_equal( dst.vlan_pcp, src->vlan_pcp );
|
342
|
+
|
343
|
+
xfree( src );
|
344
|
+
}
|
345
|
+
|
346
|
+
|
347
|
+
/********************************************************************************
|
348
|
+
* ntoh_action_strip_vlan() test.
|
349
|
+
********************************************************************************/
|
350
|
+
|
351
|
+
void
|
352
|
+
test_ntoh_action_strip_vlan() {
|
353
|
+
struct ofp_action_header dst;
|
354
|
+
|
355
|
+
memset( &dst, 0, sizeof( struct ofp_action_header ) );
|
356
|
+
|
357
|
+
struct ofp_action_header *src = create_action_strip_vlan();
|
358
|
+
|
359
|
+
ntoh_action_strip_vlan( &dst, src );
|
360
|
+
|
361
|
+
assert_int_equal( htons( dst.type ), src->type );
|
362
|
+
assert_int_equal( htons( dst.len ), src->len );
|
363
|
+
|
364
|
+
xfree( src );
|
365
|
+
}
|
366
|
+
|
367
|
+
|
368
|
+
/********************************************************************************
|
369
|
+
* ntoh_action_dl_addr() test.
|
370
|
+
********************************************************************************/
|
371
|
+
|
372
|
+
void
|
373
|
+
test_ntoh_action_dl_addr() {
|
374
|
+
struct ofp_action_dl_addr dst;
|
375
|
+
|
376
|
+
memset( &dst, 0, sizeof( struct ofp_action_dl_addr ) );
|
377
|
+
|
378
|
+
struct ofp_action_dl_addr *src = create_action_dl_addr();
|
379
|
+
|
380
|
+
ntoh_action_dl_addr( &dst, src );
|
381
|
+
|
382
|
+
assert_int_equal( htons( dst.type ), src->type );
|
383
|
+
assert_int_equal( htons( dst.len ), src->len );
|
384
|
+
assert_memory_equal( dst.dl_addr, src->dl_addr, sizeof( src->dl_addr ) );
|
385
|
+
|
386
|
+
xfree( src );
|
387
|
+
}
|
388
|
+
|
389
|
+
|
390
|
+
/********************************************************************************
|
391
|
+
* ntoh_action_nw_addr() test.
|
392
|
+
********************************************************************************/
|
393
|
+
|
394
|
+
void
|
395
|
+
test_ntoh_action_nw_addr() {
|
396
|
+
struct ofp_action_nw_addr dst;
|
397
|
+
|
398
|
+
memset( &dst, 0, sizeof( struct ofp_action_nw_addr ) );
|
399
|
+
|
400
|
+
struct ofp_action_nw_addr *src = create_action_nw_addr();
|
401
|
+
|
402
|
+
ntoh_action_nw_addr( &dst, src );
|
403
|
+
|
404
|
+
assert_int_equal( htons( dst.type ), src->type );
|
405
|
+
assert_int_equal( htons( dst.len ), src->len );
|
406
|
+
assert_int_equal( ( int ) htonl( dst.nw_addr ), ( int ) src->nw_addr );
|
407
|
+
|
408
|
+
xfree( src );
|
409
|
+
}
|
410
|
+
|
411
|
+
|
412
|
+
/********************************************************************************
|
413
|
+
* ntoh_action_nw_tos() test.
|
414
|
+
********************************************************************************/
|
415
|
+
|
416
|
+
void
|
417
|
+
test_ntoh_action_nw_tos() {
|
418
|
+
struct ofp_action_nw_tos dst;
|
419
|
+
|
420
|
+
memset( &dst, 0, sizeof( struct ofp_action_nw_tos ) );
|
421
|
+
|
422
|
+
struct ofp_action_nw_tos *src = create_action_nw_tos();
|
423
|
+
|
424
|
+
ntoh_action_nw_tos( &dst, src );
|
425
|
+
|
426
|
+
assert_int_equal( htons( dst.type ), src->type );
|
427
|
+
assert_int_equal( htons( dst.len ), src->len );
|
428
|
+
assert_int_equal( dst.nw_tos, src->nw_tos );
|
429
|
+
|
430
|
+
xfree( src );
|
431
|
+
}
|
432
|
+
|
433
|
+
|
434
|
+
/********************************************************************************
|
435
|
+
* ntoh_action_tp_port() test.
|
436
|
+
********************************************************************************/
|
437
|
+
|
438
|
+
void
|
439
|
+
test_ntoh_action_tp_port() {
|
440
|
+
struct ofp_action_tp_port dst;
|
441
|
+
|
442
|
+
memset( &dst, 0, sizeof( struct ofp_action_tp_port ) );
|
443
|
+
|
444
|
+
struct ofp_action_tp_port *src = create_action_tp_port();
|
445
|
+
|
446
|
+
ntoh_action_tp_port( &dst, src );
|
447
|
+
|
448
|
+
assert_int_equal( htons( dst.type ), src->type );
|
449
|
+
assert_int_equal( htons( dst.len ), src->len );
|
450
|
+
assert_int_equal( htons( dst.tp_port ), src->tp_port );
|
451
|
+
|
452
|
+
xfree( src );
|
453
|
+
}
|
454
|
+
|
455
|
+
|
456
|
+
/********************************************************************************
|
457
|
+
* ntoh_action_enqueue() test.
|
458
|
+
********************************************************************************/
|
459
|
+
|
460
|
+
void
|
461
|
+
test_ntoh_action_enqueue() {
|
462
|
+
struct ofp_action_enqueue dst;
|
463
|
+
|
464
|
+
memset( &dst, 0, sizeof( struct ofp_action_enqueue ) );
|
465
|
+
|
466
|
+
struct ofp_action_enqueue *src = create_action_enqueue();
|
467
|
+
|
468
|
+
ntoh_action_enqueue( &dst, src );
|
469
|
+
|
470
|
+
assert_int_equal( htons( dst.type ), src->type );
|
471
|
+
assert_int_equal( htons( dst.len ), src->len );
|
472
|
+
assert_int_equal( htons( dst.port) , src->port );
|
473
|
+
assert_int_equal( ( int ) htonl( dst.queue_id ), ( int ) src->queue_id );
|
474
|
+
|
475
|
+
xfree( src );
|
476
|
+
}
|
477
|
+
|
478
|
+
|
479
|
+
/********************************************************************************
|
480
|
+
* ntoh_action_vendor() test.
|
481
|
+
********************************************************************************/
|
482
|
+
|
483
|
+
void
|
484
|
+
test_ntoh_action_vendor() {
|
485
|
+
struct ofp_action_vendor_header dst;
|
486
|
+
|
487
|
+
memset( &dst, 0, sizeof( struct ofp_action_vendor_header ) );
|
488
|
+
|
489
|
+
struct ofp_action_vendor_header *src = create_action_vendor();
|
490
|
+
|
491
|
+
ntoh_action_vendor( &dst, src );
|
492
|
+
|
493
|
+
assert_int_equal( htons( dst.type ), src->type );
|
494
|
+
assert_int_equal( htons( dst.len ), src->len );
|
495
|
+
assert_int_equal( ( int ) htonl( dst.vendor ), ( int ) src->vendor );
|
496
|
+
|
497
|
+
xfree( src );
|
498
|
+
}
|
499
|
+
|
500
|
+
|
501
|
+
/********************************************************************************
|
502
|
+
* ntoh_action() tests.
|
503
|
+
********************************************************************************/
|
504
|
+
|
505
|
+
void
|
506
|
+
test_ntoh_action() {
|
507
|
+
{
|
508
|
+
struct ofp_action_output dst;
|
509
|
+
|
510
|
+
memset( &dst, 0, sizeof( struct ofp_action_output ) );
|
511
|
+
|
512
|
+
struct ofp_action_output *src = create_action_output();
|
513
|
+
|
514
|
+
ntoh_action( ( struct ofp_action_header * ) &dst, ( struct ofp_action_header * ) src );
|
515
|
+
|
516
|
+
assert_int_equal( htons( dst.type ), src->type );
|
517
|
+
assert_int_equal( htons( dst.len ), src->len );
|
518
|
+
assert_int_equal( htons( dst.port ), src->port );
|
519
|
+
assert_int_equal( htons( dst.max_len ), src->max_len );
|
520
|
+
|
521
|
+
xfree( src );
|
522
|
+
}
|
523
|
+
|
524
|
+
{
|
525
|
+
struct ofp_action_vlan_vid dst;
|
526
|
+
|
527
|
+
memset( &dst, 0, sizeof( struct ofp_action_vlan_vid ) );
|
528
|
+
|
529
|
+
struct ofp_action_vlan_vid *src = create_action_vlan_vid();
|
530
|
+
|
531
|
+
ntoh_action( ( struct ofp_action_header * ) &dst, ( struct ofp_action_header * ) src );
|
532
|
+
|
533
|
+
assert_int_equal( htons( dst.type ), src->type );
|
534
|
+
assert_int_equal( htons( dst.len ), src->len );
|
535
|
+
assert_int_equal( htons( dst.vlan_vid ), src->vlan_vid );
|
536
|
+
|
537
|
+
xfree( src );
|
538
|
+
}
|
539
|
+
|
540
|
+
{
|
541
|
+
struct ofp_action_vlan_pcp dst;
|
542
|
+
|
543
|
+
memset( &dst, 0, sizeof( struct ofp_action_vlan_pcp ) );
|
544
|
+
|
545
|
+
struct ofp_action_vlan_pcp *src = create_action_vlan_pcp();
|
546
|
+
|
547
|
+
ntoh_action( ( struct ofp_action_header * ) &dst, ( struct ofp_action_header * ) src );
|
548
|
+
|
549
|
+
assert_int_equal( htons( dst.type ), src->type );
|
550
|
+
assert_int_equal( htons( dst.len ), src->len );
|
551
|
+
assert_int_equal( dst.vlan_pcp, src->vlan_pcp );
|
552
|
+
|
553
|
+
xfree( src );
|
554
|
+
}
|
555
|
+
|
556
|
+
{
|
557
|
+
struct ofp_action_header dst;
|
558
|
+
|
559
|
+
memset( &dst, 0, sizeof( struct ofp_action_header ) );
|
560
|
+
|
561
|
+
struct ofp_action_header *src = create_action_strip_vlan();
|
562
|
+
|
563
|
+
ntoh_action( &dst, src );
|
564
|
+
|
565
|
+
assert_int_equal( htons( dst.type ), src->type );
|
566
|
+
assert_int_equal( htons( dst.len ), src->len );
|
567
|
+
|
568
|
+
xfree( src );
|
569
|
+
}
|
570
|
+
|
571
|
+
{
|
572
|
+
struct ofp_action_dl_addr dst;
|
573
|
+
|
574
|
+
memset( &dst, 0, sizeof( struct ofp_action_dl_addr ) );
|
575
|
+
|
576
|
+
struct ofp_action_dl_addr *src = create_action_dl_addr();
|
577
|
+
|
578
|
+
ntoh_action( ( struct ofp_action_header * ) &dst, ( struct ofp_action_header * ) src );
|
579
|
+
|
580
|
+
assert_int_equal( htons( dst.type ), src->type );
|
581
|
+
assert_int_equal( htons( dst.len ), src->len );
|
582
|
+
assert_memory_equal( dst.dl_addr, src->dl_addr, sizeof( src->dl_addr ) );
|
583
|
+
|
584
|
+
xfree( src );
|
585
|
+
}
|
586
|
+
|
587
|
+
{
|
588
|
+
struct ofp_action_nw_addr dst;
|
589
|
+
|
590
|
+
memset( &dst, 0, sizeof( struct ofp_action_nw_addr ) );
|
591
|
+
|
592
|
+
struct ofp_action_nw_addr *src = create_action_nw_addr();
|
593
|
+
|
594
|
+
ntoh_action( ( struct ofp_action_header * ) &dst, ( struct ofp_action_header * ) src );
|
595
|
+
|
596
|
+
assert_int_equal( htons( dst.type ), src->type );
|
597
|
+
assert_int_equal( htons( dst.len ), src->len );
|
598
|
+
assert_int_equal( ( int ) htonl( dst.nw_addr ), ( int ) src->nw_addr );
|
599
|
+
|
600
|
+
xfree( src );
|
601
|
+
}
|
602
|
+
|
603
|
+
{
|
604
|
+
struct ofp_action_nw_tos dst;
|
605
|
+
|
606
|
+
memset( &dst, 0, sizeof( struct ofp_action_nw_tos ) );
|
607
|
+
|
608
|
+
struct ofp_action_nw_tos *src = create_action_nw_tos();
|
609
|
+
|
610
|
+
ntoh_action( ( struct ofp_action_header * ) &dst, ( struct ofp_action_header * ) src );
|
611
|
+
|
612
|
+
assert_int_equal( htons( dst.type ), src->type );
|
613
|
+
assert_int_equal( htons( dst.len ), src->len );
|
614
|
+
assert_int_equal( dst.nw_tos, src->nw_tos );
|
615
|
+
|
616
|
+
xfree( src );
|
617
|
+
}
|
618
|
+
|
619
|
+
{
|
620
|
+
struct ofp_action_tp_port dst;
|
621
|
+
|
622
|
+
memset( &dst, 0, sizeof( struct ofp_action_tp_port ) );
|
623
|
+
|
624
|
+
struct ofp_action_tp_port *src = create_action_tp_port();
|
625
|
+
|
626
|
+
ntoh_action( ( struct ofp_action_header * ) &dst, ( struct ofp_action_header * ) src );
|
627
|
+
|
628
|
+
assert_int_equal( htons( dst.type ), src->type );
|
629
|
+
assert_int_equal( htons( dst.len ), src->len );
|
630
|
+
assert_int_equal( htons( dst.tp_port ), src->tp_port );
|
631
|
+
|
632
|
+
xfree( src );
|
633
|
+
}
|
634
|
+
|
635
|
+
{
|
636
|
+
struct ofp_action_enqueue dst;
|
637
|
+
|
638
|
+
memset( &dst, 0, sizeof( struct ofp_action_enqueue ) );
|
639
|
+
|
640
|
+
struct ofp_action_enqueue *src = create_action_enqueue();
|
641
|
+
|
642
|
+
ntoh_action( ( struct ofp_action_header * ) &dst, ( struct ofp_action_header * ) src );
|
643
|
+
|
644
|
+
assert_int_equal( htons( dst.type ), src->type );
|
645
|
+
assert_int_equal( htons( dst.len ), src->len );
|
646
|
+
assert_int_equal( htons( dst.port) , src->port );
|
647
|
+
assert_int_equal( ( int ) htonl( dst.queue_id ), ( int ) src->queue_id );
|
648
|
+
|
649
|
+
xfree( src );
|
650
|
+
}
|
651
|
+
|
652
|
+
{
|
653
|
+
struct ofp_action_vendor_header dst;
|
654
|
+
|
655
|
+
memset( &dst, 0, sizeof( struct ofp_action_vendor_header ) );
|
656
|
+
|
657
|
+
struct ofp_action_vendor_header *src = create_action_vendor();
|
658
|
+
|
659
|
+
ntoh_action( ( struct ofp_action_header * ) &dst, ( struct ofp_action_header * ) src );
|
660
|
+
|
661
|
+
assert_int_equal( htons( dst.type ), src->type );
|
662
|
+
assert_int_equal( htons( dst.len ), src->len );
|
663
|
+
assert_int_equal( ( int ) htonl( dst.vendor ), ( int ) src->vendor );
|
664
|
+
|
665
|
+
xfree( src );
|
666
|
+
}
|
667
|
+
}
|
668
|
+
|
669
|
+
|
670
|
+
void
|
671
|
+
test_ntoh_action_with_undefined_action_type() {
|
672
|
+
struct ofp_action_output dst;
|
673
|
+
|
674
|
+
memset( &dst, 0, sizeof( struct ofp_action_output ) );
|
675
|
+
|
676
|
+
struct ofp_action_output *src = create_action_output();
|
677
|
+
|
678
|
+
src->type = htons( OFPAT_ENQUEUE + 1 );
|
679
|
+
|
680
|
+
expect_assert_failure( ntoh_action( ( struct ofp_action_header * ) &dst, ( struct ofp_action_header * ) src ) );
|
681
|
+
|
682
|
+
xfree( src );
|
683
|
+
}
|
684
|
+
|
685
|
+
|
686
|
+
/********************************************************************************
|
687
|
+
* hton_action() tests.
|
688
|
+
********************************************************************************/
|
689
|
+
|
690
|
+
void
|
691
|
+
test_hton_action() {
|
692
|
+
{
|
693
|
+
struct ofp_action_output dst;
|
694
|
+
|
695
|
+
memset( &dst, 0, sizeof( struct ofp_action_output ) );
|
696
|
+
|
697
|
+
struct ofp_action_output *src = create_action_output();
|
698
|
+
ntoh_action_output( src, src );
|
699
|
+
|
700
|
+
hton_action( ( struct ofp_action_header * ) &dst, ( struct ofp_action_header * ) src );
|
701
|
+
|
702
|
+
assert_int_equal( htons( dst.type ), src->type );
|
703
|
+
assert_int_equal( htons( dst.len ), src->len );
|
704
|
+
assert_int_equal( htons( dst.port ), src->port );
|
705
|
+
assert_int_equal( htons( dst.max_len ), src->max_len );
|
706
|
+
|
707
|
+
xfree( src );
|
708
|
+
}
|
709
|
+
|
710
|
+
{
|
711
|
+
struct ofp_action_vlan_vid dst;
|
712
|
+
|
713
|
+
memset( &dst, 0, sizeof( struct ofp_action_vlan_vid ) );
|
714
|
+
|
715
|
+
struct ofp_action_vlan_vid *src = create_action_vlan_vid();
|
716
|
+
ntoh_action_vlan_vid( src, src );
|
717
|
+
|
718
|
+
hton_action( ( struct ofp_action_header * ) &dst, ( struct ofp_action_header * ) src );
|
719
|
+
|
720
|
+
assert_int_equal( htons( dst.type ), src->type );
|
721
|
+
assert_int_equal( htons( dst.len ), src->len );
|
722
|
+
assert_int_equal( htons( dst.vlan_vid ), src->vlan_vid );
|
723
|
+
|
724
|
+
xfree( src );
|
725
|
+
}
|
726
|
+
|
727
|
+
{
|
728
|
+
struct ofp_action_vlan_pcp dst;
|
729
|
+
|
730
|
+
memset( &dst, 0, sizeof( struct ofp_action_vlan_pcp ) );
|
731
|
+
|
732
|
+
struct ofp_action_vlan_pcp *src = create_action_vlan_pcp();
|
733
|
+
ntoh_action_vlan_pcp( src, src );
|
734
|
+
|
735
|
+
hton_action( ( struct ofp_action_header * ) &dst, ( struct ofp_action_header * ) src );
|
736
|
+
|
737
|
+
assert_int_equal( htons( dst.type ), src->type );
|
738
|
+
assert_int_equal( htons( dst.len ), src->len );
|
739
|
+
assert_int_equal( dst.vlan_pcp, src->vlan_pcp );
|
740
|
+
|
741
|
+
xfree( src );
|
742
|
+
}
|
743
|
+
|
744
|
+
{
|
745
|
+
struct ofp_action_header dst;
|
746
|
+
|
747
|
+
memset( &dst, 0, sizeof( struct ofp_action_header ) );
|
748
|
+
|
749
|
+
struct ofp_action_header *src = create_action_strip_vlan();
|
750
|
+
ntoh_action_strip_vlan( src, src );
|
751
|
+
|
752
|
+
hton_action( &dst, src );
|
753
|
+
|
754
|
+
assert_int_equal( htons( dst.type ), src->type );
|
755
|
+
assert_int_equal( htons( dst.len ), src->len );
|
756
|
+
|
757
|
+
xfree( src );
|
758
|
+
}
|
759
|
+
|
760
|
+
{
|
761
|
+
struct ofp_action_dl_addr dst;
|
762
|
+
|
763
|
+
memset( &dst, 0, sizeof( struct ofp_action_dl_addr ) );
|
764
|
+
|
765
|
+
struct ofp_action_dl_addr *src = create_action_dl_addr();
|
766
|
+
ntoh_action_dl_addr( src, src );
|
767
|
+
|
768
|
+
hton_action( ( struct ofp_action_header * ) &dst, ( struct ofp_action_header * ) src );
|
769
|
+
|
770
|
+
assert_int_equal( htons( dst.type ), src->type );
|
771
|
+
assert_int_equal( htons( dst.len ), src->len );
|
772
|
+
assert_memory_equal( dst.dl_addr, src->dl_addr, sizeof( src->dl_addr ) );
|
773
|
+
|
774
|
+
xfree( src );
|
775
|
+
}
|
776
|
+
|
777
|
+
{
|
778
|
+
struct ofp_action_nw_addr dst;
|
779
|
+
|
780
|
+
memset( &dst, 0, sizeof( struct ofp_action_nw_addr ) );
|
781
|
+
|
782
|
+
struct ofp_action_nw_addr *src = create_action_nw_addr();
|
783
|
+
ntoh_action_nw_addr( src, src );
|
784
|
+
|
785
|
+
hton_action( ( struct ofp_action_header * ) &dst, ( struct ofp_action_header * ) src );
|
786
|
+
|
787
|
+
assert_int_equal( htons( dst.type ), src->type );
|
788
|
+
assert_int_equal( htons( dst.len ), src->len );
|
789
|
+
assert_int_equal( ( int ) htonl( dst.nw_addr ), ( int ) src->nw_addr );
|
790
|
+
|
791
|
+
xfree( src );
|
792
|
+
}
|
793
|
+
|
794
|
+
{
|
795
|
+
struct ofp_action_nw_tos dst;
|
796
|
+
|
797
|
+
memset( &dst, 0, sizeof( struct ofp_action_nw_tos ) );
|
798
|
+
|
799
|
+
struct ofp_action_nw_tos *src = create_action_nw_tos();
|
800
|
+
ntoh_action_nw_tos( src, src );
|
801
|
+
|
802
|
+
hton_action( ( struct ofp_action_header * ) &dst, ( struct ofp_action_header * ) src );
|
803
|
+
|
804
|
+
assert_int_equal( htons( dst.type ), src->type );
|
805
|
+
assert_int_equal( htons( dst.len ), src->len );
|
806
|
+
assert_int_equal( dst.nw_tos, src->nw_tos );
|
807
|
+
|
808
|
+
xfree( src );
|
809
|
+
}
|
810
|
+
|
811
|
+
{
|
812
|
+
struct ofp_action_tp_port dst;
|
813
|
+
|
814
|
+
memset( &dst, 0, sizeof( struct ofp_action_tp_port ) );
|
815
|
+
|
816
|
+
struct ofp_action_tp_port *src = create_action_tp_port();
|
817
|
+
ntoh_action_tp_port( src, src );
|
818
|
+
|
819
|
+
hton_action( ( struct ofp_action_header * ) &dst, ( struct ofp_action_header * ) src );
|
820
|
+
|
821
|
+
assert_int_equal( htons( dst.type ), src->type );
|
822
|
+
assert_int_equal( htons( dst.len ), src->len );
|
823
|
+
assert_int_equal( htons( dst.tp_port ), src->tp_port );
|
824
|
+
|
825
|
+
xfree( src );
|
826
|
+
}
|
827
|
+
|
828
|
+
{
|
829
|
+
struct ofp_action_enqueue dst;
|
830
|
+
|
831
|
+
memset( &dst, 0, sizeof( struct ofp_action_enqueue ) );
|
832
|
+
|
833
|
+
struct ofp_action_enqueue *src = create_action_enqueue();
|
834
|
+
ntoh_action_enqueue( src, src );
|
835
|
+
|
836
|
+
hton_action( ( struct ofp_action_header * ) &dst, ( struct ofp_action_header * ) src );
|
837
|
+
|
838
|
+
assert_int_equal( htons( dst.type ), src->type );
|
839
|
+
assert_int_equal( htons( dst.len ), src->len );
|
840
|
+
assert_int_equal( htons( dst.port) , src->port );
|
841
|
+
assert_int_equal( ( int ) htonl( dst.queue_id ), ( int ) src->queue_id );
|
842
|
+
|
843
|
+
xfree( src );
|
844
|
+
}
|
845
|
+
|
846
|
+
{
|
847
|
+
struct ofp_action_vendor_header dst;
|
848
|
+
|
849
|
+
memset( &dst, 0, sizeof( struct ofp_action_vendor_header ) );
|
850
|
+
|
851
|
+
struct ofp_action_vendor_header *src = create_action_vendor();
|
852
|
+
ntoh_action_vendor( src, src );
|
853
|
+
|
854
|
+
hton_action( ( struct ofp_action_header * ) &dst, ( struct ofp_action_header * ) src );
|
855
|
+
|
856
|
+
assert_int_equal( htons( dst.type ), src->type );
|
857
|
+
assert_int_equal( htons( dst.len ), src->len );
|
858
|
+
assert_int_equal( ( int ) htonl( dst.vendor ), ( int ) src->vendor );
|
859
|
+
|
860
|
+
xfree( src );
|
861
|
+
}
|
862
|
+
}
|
863
|
+
|
864
|
+
|
865
|
+
void
|
866
|
+
test_hton_action_with_undefined_action_type() {
|
867
|
+
struct ofp_action_output dst;
|
868
|
+
|
869
|
+
memset( &dst, 0, sizeof( struct ofp_action_output ) );
|
870
|
+
|
871
|
+
struct ofp_action_output *src = create_action_output();
|
872
|
+
ntoh_action_output( src, src );
|
873
|
+
|
874
|
+
src->type = OFPAT_ENQUEUE + 1;
|
875
|
+
|
876
|
+
expect_assert_failure( hton_action( ( struct ofp_action_header * ) &dst, ( struct ofp_action_header * ) src ) );
|
877
|
+
|
878
|
+
xfree( src );
|
879
|
+
}
|
880
|
+
|
881
|
+
|
882
|
+
/********************************************************************************
|
883
|
+
* ntoh_flow_stats() tests.
|
884
|
+
********************************************************************************/
|
885
|
+
|
886
|
+
void
|
887
|
+
test_ntoh_flow_stats_without_action() {
|
888
|
+
uint16_t length = ( uint16_t ) ( offsetof( struct ofp_flow_stats, actions ) );
|
889
|
+
|
890
|
+
struct ofp_flow_stats *src = xmalloc( length );
|
891
|
+
struct ofp_flow_stats *dst = xmalloc( length );
|
892
|
+
|
893
|
+
memset( src, 0, length );
|
894
|
+
memset( dst, 0, length );
|
895
|
+
|
896
|
+
src->length = htons( length );
|
897
|
+
src->table_id = 1;
|
898
|
+
hton_match( &src->match, &MATCH );
|
899
|
+
src->duration_sec = htonl( 60 );
|
900
|
+
src->duration_nsec = htonl( 5000 );
|
901
|
+
src->priority = htons( UINT16_MAX );
|
902
|
+
src->idle_timeout = htons( 60 );
|
903
|
+
src->hard_timeout = htons( 300 );
|
904
|
+
src->cookie = htonll( COOKIE );
|
905
|
+
src->packet_count = htonll( PACKET_COUNT );
|
906
|
+
src->byte_count= htonll( BYTE_COUNT );
|
907
|
+
|
908
|
+
ntoh_flow_stats( dst, src );
|
909
|
+
|
910
|
+
assert_int_equal( htons( dst->length ), src->length );
|
911
|
+
assert_int_equal( dst->table_id, src->table_id );
|
912
|
+
assert_memory_equal( &dst->match, &MATCH, sizeof( struct ofp_match ) );
|
913
|
+
assert_int_equal( ( int ) htonl( dst->duration_sec ), ( int ) src->duration_sec );
|
914
|
+
assert_int_equal( ( int ) htonl( dst->duration_nsec ), ( int ) src->duration_nsec );
|
915
|
+
assert_int_equal( htons( dst->priority ), src->priority );
|
916
|
+
assert_int_equal( htons( dst->idle_timeout ), src->idle_timeout );
|
917
|
+
assert_int_equal( htons( dst->hard_timeout ), src->hard_timeout );
|
918
|
+
assert_memory_equal( &dst->cookie, &COOKIE, sizeof( uint64_t ) );
|
919
|
+
assert_memory_equal( &dst->packet_count, &PACKET_COUNT, sizeof( uint64_t ) );
|
920
|
+
assert_memory_equal( &dst->byte_count, &BYTE_COUNT, sizeof( uint64_t ) );
|
921
|
+
|
922
|
+
xfree( src );
|
923
|
+
xfree( dst );
|
924
|
+
}
|
925
|
+
|
926
|
+
|
927
|
+
void
|
928
|
+
test_ntoh_flow_stats_with_single_output_action() {
|
929
|
+
uint16_t length = ( uint16_t ) ( offsetof( struct ofp_flow_stats, actions ) + sizeof( struct ofp_action_output ) );
|
930
|
+
|
931
|
+
struct ofp_flow_stats *src = xmalloc( length );
|
932
|
+
struct ofp_flow_stats *dst = xmalloc( length );
|
933
|
+
|
934
|
+
memset( src, 0, length );
|
935
|
+
memset( dst, 0, length );
|
936
|
+
|
937
|
+
src->length = htons( length );
|
938
|
+
src->table_id = 1;
|
939
|
+
hton_match( &src->match, &MATCH );
|
940
|
+
src->duration_sec = htonl( 60 );
|
941
|
+
src->duration_nsec = htonl( 5000 );
|
942
|
+
src->priority = htons( UINT16_MAX );
|
943
|
+
src->idle_timeout = htons( 60 );
|
944
|
+
src->hard_timeout = htons( 300 );
|
945
|
+
src->cookie = htonll( COOKIE );
|
946
|
+
src->packet_count = htonll( PACKET_COUNT );
|
947
|
+
src->byte_count= htonll( BYTE_COUNT );
|
948
|
+
struct ofp_action_output *act_src = ( struct ofp_action_output * ) src->actions;
|
949
|
+
act_src->type = htons( OFPAT_OUTPUT );
|
950
|
+
act_src->len = htons( 8 );
|
951
|
+
act_src->port = htons( 1 );
|
952
|
+
act_src->max_len = htons( 2048 );
|
953
|
+
|
954
|
+
ntoh_flow_stats( dst, src );
|
955
|
+
|
956
|
+
struct ofp_action_output *act_dst = ( struct ofp_action_output * ) dst->actions;
|
957
|
+
|
958
|
+
assert_int_equal( htons( dst->length ), src->length );
|
959
|
+
assert_int_equal( dst->table_id, src->table_id );
|
960
|
+
assert_memory_equal( &dst->match, &MATCH, sizeof( struct ofp_match ) );
|
961
|
+
assert_int_equal( ( int ) htonl( dst->duration_sec ), ( int ) src->duration_sec );
|
962
|
+
assert_int_equal( ( int ) htonl( dst->duration_nsec ), ( int ) src->duration_nsec );
|
963
|
+
assert_int_equal( htons( dst->priority ), src->priority );
|
964
|
+
assert_int_equal( htons( dst->idle_timeout ), src->idle_timeout );
|
965
|
+
assert_int_equal( htons( dst->hard_timeout ), src->hard_timeout );
|
966
|
+
assert_memory_equal( &dst->cookie, &COOKIE, sizeof( uint64_t ) );
|
967
|
+
assert_memory_equal( &dst->packet_count, &PACKET_COUNT, sizeof( uint64_t ) );
|
968
|
+
assert_memory_equal( &dst->byte_count, &BYTE_COUNT, sizeof( uint64_t ) );
|
969
|
+
assert_int_equal( htons( act_dst->type ), act_src->type );
|
970
|
+
assert_int_equal( htons( act_dst->len ), act_src->len );
|
971
|
+
assert_int_equal( htons( act_dst->port ), act_src->port );
|
972
|
+
assert_int_equal( htons( act_dst->max_len ), act_src->max_len );
|
973
|
+
|
974
|
+
xfree( src );
|
975
|
+
xfree( dst );
|
976
|
+
}
|
977
|
+
|
978
|
+
|
979
|
+
void
|
980
|
+
test_ntoh_flow_stats_with_two_output_actions() {
|
981
|
+
uint16_t length = ( uint16_t ) ( offsetof( struct ofp_flow_stats, actions ) + sizeof( struct ofp_action_output ) * 2 );
|
982
|
+
|
983
|
+
struct ofp_flow_stats *src = xmalloc( length );
|
984
|
+
struct ofp_flow_stats *dst = xmalloc( length );
|
985
|
+
|
986
|
+
memset( src, 0, length );
|
987
|
+
memset( dst, 0, length );
|
988
|
+
|
989
|
+
src->length = htons( length );
|
990
|
+
src->table_id = 1;
|
991
|
+
hton_match( &src->match, &MATCH );
|
992
|
+
src->duration_sec = htonl( 60 );
|
993
|
+
src->duration_nsec = htonl( 5000 );
|
994
|
+
src->priority = htons( UINT16_MAX );
|
995
|
+
src->idle_timeout = htons( 60 );
|
996
|
+
src->hard_timeout = htons( 300 );
|
997
|
+
src->cookie = htonll( COOKIE );
|
998
|
+
src->packet_count = htonll( PACKET_COUNT );
|
999
|
+
src->byte_count= htonll( BYTE_COUNT );
|
1000
|
+
struct ofp_action_output *act_src[ 2 ];
|
1001
|
+
act_src[ 0 ] = ( struct ofp_action_output * ) src->actions;
|
1002
|
+
act_src[ 0 ]->type = htons( OFPAT_OUTPUT );
|
1003
|
+
act_src[ 0 ]->len = htons( 8 );
|
1004
|
+
act_src[ 0 ]->port = htons( 1 );
|
1005
|
+
act_src[ 0 ]->max_len = htons( 2048 );
|
1006
|
+
act_src[ 1 ] = ( struct ofp_action_output * ) ( ( char * ) src->actions + sizeof( struct ofp_action_output ) );
|
1007
|
+
act_src[ 1 ]->type = htons( OFPAT_OUTPUT );
|
1008
|
+
act_src[ 1 ]->len = htons( 8 );
|
1009
|
+
act_src[ 1 ]->port = htons( 2 );
|
1010
|
+
act_src[ 1 ]->max_len = htons( 2048 );
|
1011
|
+
|
1012
|
+
ntoh_flow_stats( dst, src );
|
1013
|
+
|
1014
|
+
struct ofp_action_output *act_dst[ 2 ];
|
1015
|
+
act_dst[ 0 ] = ( struct ofp_action_output * ) dst->actions;
|
1016
|
+
act_dst[ 1 ] = ( struct ofp_action_output * ) ( ( char * ) dst->actions + sizeof( struct ofp_action_output ) );
|
1017
|
+
|
1018
|
+
assert_int_equal( htons( dst->length ), src->length );
|
1019
|
+
assert_int_equal( dst->table_id, src->table_id );
|
1020
|
+
assert_memory_equal( &dst->match, &MATCH, sizeof( struct ofp_match ) );
|
1021
|
+
assert_int_equal( ( int ) htonl( dst->duration_sec ), ( int ) src->duration_sec );
|
1022
|
+
assert_int_equal( ( int ) htonl( dst->duration_nsec ), ( int ) src->duration_nsec );
|
1023
|
+
assert_int_equal( htons( dst->priority ), src->priority );
|
1024
|
+
assert_int_equal( htons( dst->idle_timeout ), src->idle_timeout );
|
1025
|
+
assert_int_equal( htons( dst->hard_timeout ), src->hard_timeout );
|
1026
|
+
assert_memory_equal( &dst->cookie, &COOKIE, sizeof( uint64_t ) );
|
1027
|
+
assert_memory_equal( &dst->packet_count, &PACKET_COUNT, sizeof( uint64_t ) );
|
1028
|
+
assert_memory_equal( &dst->byte_count, &BYTE_COUNT, sizeof( uint64_t ) );
|
1029
|
+
assert_int_equal( htons( act_dst[ 0 ]->type ), act_src[ 0 ]->type );
|
1030
|
+
assert_int_equal( htons( act_dst[ 0 ]->len ), act_src[ 0 ]->len );
|
1031
|
+
assert_int_equal( htons( act_dst[ 0 ]->port ), act_src[ 0 ]->port );
|
1032
|
+
assert_int_equal( htons( act_dst[ 0 ]->max_len ), act_src[ 0 ]->max_len );
|
1033
|
+
assert_int_equal( htons( act_dst[ 1 ]->type ), act_src[ 1 ]->type );
|
1034
|
+
assert_int_equal( htons( act_dst[ 1 ]->len ), act_src[ 1 ]->len );
|
1035
|
+
assert_int_equal( htons( act_dst[ 1 ]->port ), act_src[ 1 ]->port );
|
1036
|
+
assert_int_equal( htons( act_dst[ 1 ]->max_len ), act_src[ 1 ]->max_len );
|
1037
|
+
|
1038
|
+
xfree( src );
|
1039
|
+
xfree( dst );
|
1040
|
+
}
|
1041
|
+
|
1042
|
+
|
1043
|
+
/********************************************************************************
|
1044
|
+
* hton_flow_stats() tests.
|
1045
|
+
********************************************************************************/
|
1046
|
+
|
1047
|
+
void
|
1048
|
+
test_hton_flow_stats_without_action() {
|
1049
|
+
uint16_t length = ( uint16_t ) ( offsetof( struct ofp_flow_stats, actions ) );
|
1050
|
+
|
1051
|
+
struct ofp_flow_stats *src = xmalloc( length );
|
1052
|
+
struct ofp_flow_stats *dst = xmalloc( length );
|
1053
|
+
|
1054
|
+
memset( src, 0, length );
|
1055
|
+
memset( dst, 0, length );
|
1056
|
+
|
1057
|
+
src->length = length;
|
1058
|
+
src->table_id = 1;
|
1059
|
+
src->match = MATCH;
|
1060
|
+
src->duration_sec = 60;
|
1061
|
+
src->duration_nsec = 5000;
|
1062
|
+
src->priority = UINT16_MAX;
|
1063
|
+
src->idle_timeout = 60;
|
1064
|
+
src->hard_timeout = 300;
|
1065
|
+
src->cookie = COOKIE;
|
1066
|
+
src->packet_count = PACKET_COUNT;
|
1067
|
+
src->byte_count= BYTE_COUNT;
|
1068
|
+
|
1069
|
+
hton_flow_stats( dst, src );
|
1070
|
+
|
1071
|
+
assert_int_equal( dst->length, htons( src->length ) );
|
1072
|
+
assert_int_equal( dst->table_id, src->table_id );
|
1073
|
+
hton_match( &src->match, &MATCH );
|
1074
|
+
assert_memory_equal( &dst->match, &src->match, sizeof( struct ofp_match ) );
|
1075
|
+
assert_int_equal( ( int ) dst->duration_sec, ( int ) htonl( src->duration_sec ) );
|
1076
|
+
assert_int_equal( ( int ) dst->duration_nsec, ( int ) htonl( src->duration_nsec ) );
|
1077
|
+
assert_int_equal( dst->priority, htons( src->priority ) );
|
1078
|
+
assert_int_equal( dst->idle_timeout, htons( src->idle_timeout ) );
|
1079
|
+
assert_int_equal( dst->hard_timeout, htons( src->hard_timeout ) );
|
1080
|
+
src->cookie = htonll( COOKIE );
|
1081
|
+
assert_memory_equal( &dst->cookie, &src->cookie, sizeof( uint64_t ) );
|
1082
|
+
src->packet_count = htonll( PACKET_COUNT );
|
1083
|
+
assert_memory_equal( &dst->packet_count, &src->packet_count, sizeof( uint64_t ) );
|
1084
|
+
src->byte_count = htonll( BYTE_COUNT );
|
1085
|
+
assert_memory_equal( &dst->byte_count, &src->byte_count, sizeof( uint64_t ) );
|
1086
|
+
|
1087
|
+
xfree( src );
|
1088
|
+
xfree( dst );
|
1089
|
+
}
|
1090
|
+
|
1091
|
+
|
1092
|
+
void
|
1093
|
+
test_hton_flow_stats_with_single_output_action() {
|
1094
|
+
uint16_t length = ( uint16_t ) ( offsetof( struct ofp_flow_stats, actions ) + sizeof( struct ofp_action_output ) );
|
1095
|
+
|
1096
|
+
struct ofp_flow_stats *src = xmalloc( length );
|
1097
|
+
struct ofp_flow_stats *dst = xmalloc( length );
|
1098
|
+
|
1099
|
+
memset( src, 0, length );
|
1100
|
+
memset( dst, 0, length );
|
1101
|
+
|
1102
|
+
src->length = length;
|
1103
|
+
src->table_id = 1;
|
1104
|
+
src->match = MATCH;
|
1105
|
+
src->duration_sec = 60;
|
1106
|
+
src->duration_nsec = 5000 ;
|
1107
|
+
src->priority = UINT16_MAX;
|
1108
|
+
src->idle_timeout = 60;
|
1109
|
+
src->hard_timeout = 300;
|
1110
|
+
src->cookie = COOKIE;
|
1111
|
+
src->packet_count = PACKET_COUNT;
|
1112
|
+
src->byte_count= BYTE_COUNT;
|
1113
|
+
struct ofp_action_output *act_src = ( struct ofp_action_output * ) src->actions;
|
1114
|
+
act_src->type = OFPAT_OUTPUT;
|
1115
|
+
act_src->len = 8;
|
1116
|
+
act_src->port = 1;
|
1117
|
+
act_src->max_len = 2048;
|
1118
|
+
|
1119
|
+
hton_flow_stats( dst, src );
|
1120
|
+
|
1121
|
+
struct ofp_action_output *act_dst = ( struct ofp_action_output * ) dst->actions;
|
1122
|
+
|
1123
|
+
assert_int_equal( dst->length, htons( src->length ) );
|
1124
|
+
assert_int_equal( dst->table_id, src->table_id );
|
1125
|
+
hton_match( &src->match, &MATCH );
|
1126
|
+
assert_memory_equal( &dst->match, &src->match, sizeof( struct ofp_match ) );
|
1127
|
+
assert_int_equal( ( int ) dst->duration_sec, ( int ) htonl( src->duration_sec ) );
|
1128
|
+
assert_int_equal( ( int ) dst->duration_nsec, ( int ) htonl( src->duration_nsec ) );
|
1129
|
+
assert_int_equal( dst->priority, htons( src->priority ) );
|
1130
|
+
assert_int_equal( dst->idle_timeout, htons( src->idle_timeout ) );
|
1131
|
+
assert_int_equal( dst->hard_timeout, htons( src->hard_timeout ) );
|
1132
|
+
src->cookie = htonll( COOKIE );
|
1133
|
+
assert_memory_equal( &dst->cookie, &src->cookie, sizeof( uint64_t ) );
|
1134
|
+
src->packet_count = htonll( PACKET_COUNT );
|
1135
|
+
assert_memory_equal( &dst->packet_count, &src->packet_count, sizeof( uint64_t ) );
|
1136
|
+
src->byte_count = htonll( BYTE_COUNT );
|
1137
|
+
assert_memory_equal( &dst->byte_count, &src->byte_count, sizeof( uint64_t ) );
|
1138
|
+
assert_int_equal( act_dst->type, htons( act_src->type ) );
|
1139
|
+
assert_int_equal( act_dst->len, htons( act_src->len ) );
|
1140
|
+
assert_int_equal( act_dst->port, htons( act_src->port ) );
|
1141
|
+
assert_int_equal( act_dst->max_len, htons( act_src->max_len ) );
|
1142
|
+
|
1143
|
+
xfree( src );
|
1144
|
+
xfree( dst );
|
1145
|
+
}
|
1146
|
+
|
1147
|
+
|
1148
|
+
void
|
1149
|
+
test_hton_flow_stats_with_two_output_actions() {
|
1150
|
+
uint16_t length = ( uint16_t ) ( offsetof( struct ofp_flow_stats, actions ) + sizeof( struct ofp_action_output ) * 2 );
|
1151
|
+
|
1152
|
+
struct ofp_flow_stats *src = xmalloc( length );
|
1153
|
+
struct ofp_flow_stats *dst = xmalloc( length );
|
1154
|
+
|
1155
|
+
memset( src, 0, length );
|
1156
|
+
memset( dst, 0, length );
|
1157
|
+
|
1158
|
+
src->length = length;
|
1159
|
+
src->table_id = 1;
|
1160
|
+
src->match = MATCH;
|
1161
|
+
src->duration_sec = 60;
|
1162
|
+
src->duration_nsec = 5000;
|
1163
|
+
src->priority = UINT16_MAX;
|
1164
|
+
src->idle_timeout = 60;
|
1165
|
+
src->hard_timeout = 300;
|
1166
|
+
src->cookie = COOKIE;
|
1167
|
+
src->packet_count = PACKET_COUNT;
|
1168
|
+
src->byte_count= BYTE_COUNT;
|
1169
|
+
struct ofp_action_output *act_src[ 2 ];
|
1170
|
+
act_src[ 0 ] = ( struct ofp_action_output * ) src->actions;
|
1171
|
+
act_src[ 0 ]->type = OFPAT_OUTPUT;
|
1172
|
+
act_src[ 0 ]->len = 8;
|
1173
|
+
act_src[ 0 ]->port = 1;
|
1174
|
+
act_src[ 0 ]->max_len = 2048;
|
1175
|
+
act_src[ 1 ] = ( struct ofp_action_output * ) ( ( char * ) src->actions + sizeof( struct ofp_action_output ) );
|
1176
|
+
act_src[ 1 ]->type = OFPAT_OUTPUT;
|
1177
|
+
act_src[ 1 ]->len = 8;
|
1178
|
+
act_src[ 1 ]->port = 2;
|
1179
|
+
act_src[ 1 ]->max_len = 2048;
|
1180
|
+
|
1181
|
+
hton_flow_stats( dst, src );
|
1182
|
+
|
1183
|
+
struct ofp_action_output *act_dst[ 2 ];
|
1184
|
+
act_dst[ 0 ] = ( struct ofp_action_output * ) dst->actions;
|
1185
|
+
act_dst[ 1 ] = ( struct ofp_action_output * ) ( ( char * ) dst->actions + sizeof( struct ofp_action_output ) );
|
1186
|
+
|
1187
|
+
assert_int_equal( htons( dst->length ), src->length );
|
1188
|
+
assert_int_equal( dst->table_id, src->table_id );
|
1189
|
+
hton_match( &src->match, &MATCH );
|
1190
|
+
assert_memory_equal( &dst->match, &src->match, sizeof( struct ofp_match ) );
|
1191
|
+
assert_int_equal( ( int ) htonl( dst->duration_sec ), ( int ) src->duration_sec );
|
1192
|
+
assert_int_equal( ( int ) htonl( dst->duration_nsec ), ( int ) src->duration_nsec );
|
1193
|
+
assert_int_equal( htons( dst->priority ), src->priority );
|
1194
|
+
assert_int_equal( htons( dst->idle_timeout ), src->idle_timeout );
|
1195
|
+
assert_int_equal( htons( dst->hard_timeout ), src->hard_timeout );
|
1196
|
+
src->cookie = htonll( COOKIE );
|
1197
|
+
assert_memory_equal( &dst->cookie, &src->cookie, sizeof( uint64_t ) );
|
1198
|
+
src->packet_count = htonll( PACKET_COUNT );
|
1199
|
+
assert_memory_equal( &dst->packet_count, &src->packet_count, sizeof( uint64_t ) );
|
1200
|
+
src->byte_count = htonll( BYTE_COUNT );
|
1201
|
+
assert_memory_equal( &dst->byte_count, &src->byte_count, sizeof( uint64_t ) );
|
1202
|
+
assert_int_equal( act_dst[ 0 ]->type, htons( act_src[ 0 ]->type ) );
|
1203
|
+
assert_int_equal( act_dst[ 0 ]->len, htons( act_src[ 0 ]->len ) );
|
1204
|
+
assert_int_equal( act_dst[ 0 ]->port, htons( act_src[ 0 ]->port ) );
|
1205
|
+
assert_int_equal( act_dst[ 0 ]->max_len, htons( act_src[ 0 ]->max_len ) );
|
1206
|
+
assert_int_equal( act_dst[ 1 ]->type, htons( act_src[ 1 ]->type ) );
|
1207
|
+
assert_int_equal( act_dst[ 1 ]->len, htons( act_src[ 1 ]->len ) );
|
1208
|
+
assert_int_equal( act_dst[ 1 ]->port, htons( act_src[ 1 ]->port ) );
|
1209
|
+
assert_int_equal( act_dst[ 1 ]->max_len, htons( act_src[ 1 ]->max_len ) );
|
1210
|
+
|
1211
|
+
xfree( src );
|
1212
|
+
xfree( dst );
|
1213
|
+
}
|
1214
|
+
|
1215
|
+
|
1216
|
+
/********************************************************************************
|
1217
|
+
* ntoh_aggregate_stats() test.
|
1218
|
+
********************************************************************************/
|
1219
|
+
|
1220
|
+
void
|
1221
|
+
test_ntoh_aggregate_stats() {
|
1222
|
+
struct ofp_aggregate_stats_reply dst;
|
1223
|
+
struct ofp_aggregate_stats_reply src;
|
1224
|
+
|
1225
|
+
memset( &src, 0, sizeof( struct ofp_aggregate_stats_reply ) );
|
1226
|
+
memset( &dst, 0, sizeof( struct ofp_aggregate_stats_reply ) );
|
1227
|
+
|
1228
|
+
src.packet_count = htonll( PACKET_COUNT );
|
1229
|
+
src.byte_count = htonll( BYTE_COUNT );
|
1230
|
+
src.flow_count = htonl( 1000 );
|
1231
|
+
|
1232
|
+
ntoh_aggregate_stats( &dst, &src );
|
1233
|
+
|
1234
|
+
assert_memory_equal( &dst.packet_count, &PACKET_COUNT, sizeof( uint64_t ) );
|
1235
|
+
assert_memory_equal( &dst.byte_count, &BYTE_COUNT, sizeof( uint64_t ) );
|
1236
|
+
assert_int_equal( ( int ) htonl( dst.flow_count ), ( int ) src.flow_count );
|
1237
|
+
}
|
1238
|
+
|
1239
|
+
|
1240
|
+
/********************************************************************************
|
1241
|
+
* ntoh_table_stats() test.
|
1242
|
+
********************************************************************************/
|
1243
|
+
|
1244
|
+
void
|
1245
|
+
test_ntoh_table_stats() {
|
1246
|
+
struct ofp_table_stats dst;
|
1247
|
+
struct ofp_table_stats src;
|
1248
|
+
|
1249
|
+
memset( &src, 0, sizeof( struct ofp_table_stats ) );
|
1250
|
+
memset( &dst, 0, sizeof( struct ofp_table_stats ) );
|
1251
|
+
|
1252
|
+
uint64_t lookup_count = 100000000;
|
1253
|
+
uint64_t matched_count = 10000000;
|
1254
|
+
|
1255
|
+
src.table_id = 1;
|
1256
|
+
memset( &src.name, '\0', OFP_MAX_TABLE_NAME_LEN );
|
1257
|
+
memcpy( &src.name, TABLE_NAME, strlen( TABLE_NAME ) );
|
1258
|
+
src.wildcards = htonl( OFPFW_ALL );
|
1259
|
+
src.max_entries = htonl( 1000000 );
|
1260
|
+
src.active_count = htonl( 1234 );
|
1261
|
+
src.lookup_count = htonll( lookup_count );
|
1262
|
+
src.matched_count = htonll( matched_count );
|
1263
|
+
|
1264
|
+
ntoh_table_stats( &dst, &src );
|
1265
|
+
|
1266
|
+
assert_int_equal( dst.table_id, src.table_id );
|
1267
|
+
assert_memory_equal( &dst.name, &src.name, OFP_MAX_TABLE_NAME_LEN );
|
1268
|
+
assert_int_equal( ( int ) htonl( dst.wildcards ), ( int ) src.wildcards );
|
1269
|
+
assert_int_equal( ( int ) htonl( dst.max_entries ), ( int ) src.max_entries );
|
1270
|
+
assert_int_equal( ( int ) htonl( dst.active_count ), ( int ) src.active_count );
|
1271
|
+
assert_memory_equal( &dst.lookup_count, &lookup_count, sizeof( uint64_t ) );
|
1272
|
+
assert_memory_equal( &dst.matched_count, &matched_count, sizeof( uint64_t ) );
|
1273
|
+
}
|
1274
|
+
|
1275
|
+
|
1276
|
+
/********************************************************************************
|
1277
|
+
* ntoh_port_stats() test.
|
1278
|
+
********************************************************************************/
|
1279
|
+
|
1280
|
+
void
|
1281
|
+
test_ntoh_port_stats() {
|
1282
|
+
struct ofp_port_stats dst;
|
1283
|
+
struct ofp_port_stats src;
|
1284
|
+
|
1285
|
+
memset( &src, 0, sizeof( struct ofp_port_stats ) );
|
1286
|
+
memset( &dst, 0, sizeof( struct ofp_port_stats ) );
|
1287
|
+
|
1288
|
+
uint64_t rx_packets = 8000;
|
1289
|
+
uint64_t tx_packets = 7000;
|
1290
|
+
uint64_t rx_bytes = 6000;
|
1291
|
+
uint64_t tx_bytes = 5000;
|
1292
|
+
uint64_t rx_dropped = 4000;
|
1293
|
+
uint64_t tx_dropped = 3000;
|
1294
|
+
uint64_t rx_errors = 2000;
|
1295
|
+
uint64_t tx_errors = 1000;
|
1296
|
+
uint64_t rx_frame_err = 900;
|
1297
|
+
uint64_t rx_over_err = 100;
|
1298
|
+
uint64_t rx_crc_err = 10;
|
1299
|
+
uint64_t collisions = 1;
|
1300
|
+
|
1301
|
+
src.port_no = htons( 1 );
|
1302
|
+
src.rx_packets = htonll( rx_packets );
|
1303
|
+
src.tx_packets = htonll( tx_packets );
|
1304
|
+
src.rx_bytes = htonll( rx_bytes );
|
1305
|
+
src.tx_bytes = htonll( tx_bytes );
|
1306
|
+
src.rx_dropped = htonll( rx_dropped );
|
1307
|
+
src.tx_dropped = htonll( tx_dropped );
|
1308
|
+
src.rx_errors = htonll( rx_errors );
|
1309
|
+
src.tx_errors = htonll( tx_errors );
|
1310
|
+
src.rx_frame_err = htonll( rx_frame_err );
|
1311
|
+
src.rx_over_err = htonll( rx_over_err );
|
1312
|
+
src.rx_crc_err = htonll( rx_crc_err );
|
1313
|
+
src.collisions = htonll( collisions );
|
1314
|
+
|
1315
|
+
ntoh_port_stats( &dst, &src );
|
1316
|
+
|
1317
|
+
assert_int_equal( htons( dst.port_no ), src.port_no );
|
1318
|
+
assert_memory_equal( &dst.rx_packets, &rx_packets, sizeof( uint64_t ) );
|
1319
|
+
assert_memory_equal( &dst.tx_packets, &tx_packets, sizeof( uint64_t ) );
|
1320
|
+
assert_memory_equal( &dst.rx_bytes, &rx_bytes, sizeof( uint64_t ) );
|
1321
|
+
assert_memory_equal( &dst.tx_bytes, &tx_bytes, sizeof( uint64_t ) );
|
1322
|
+
assert_memory_equal( &dst.rx_dropped, &rx_dropped, sizeof( uint64_t ) );
|
1323
|
+
assert_memory_equal( &dst.tx_dropped, &tx_dropped, sizeof( uint64_t ) );
|
1324
|
+
assert_memory_equal( &dst.rx_errors, &rx_errors, sizeof( uint64_t ) );
|
1325
|
+
assert_memory_equal( &dst.tx_errors, &tx_errors, sizeof( uint64_t ) );
|
1326
|
+
assert_memory_equal( &dst.rx_frame_err, &rx_frame_err, sizeof( uint64_t ) );
|
1327
|
+
assert_memory_equal( &dst.rx_over_err, &rx_over_err, sizeof( uint64_t ) );
|
1328
|
+
assert_memory_equal( &dst.rx_crc_err, &rx_crc_err, sizeof( uint64_t ) );
|
1329
|
+
assert_memory_equal( &dst.collisions, &collisions, sizeof( uint64_t ) );
|
1330
|
+
}
|
1331
|
+
|
1332
|
+
|
1333
|
+
/********************************************************************************
|
1334
|
+
* ntoh_queue_stats() test.
|
1335
|
+
********************************************************************************/
|
1336
|
+
|
1337
|
+
void
|
1338
|
+
test_ntoh_queue_stats() {
|
1339
|
+
struct ofp_queue_stats dst;
|
1340
|
+
struct ofp_queue_stats src;
|
1341
|
+
|
1342
|
+
memset( &src, 0, sizeof( struct ofp_queue_stats ) );
|
1343
|
+
memset( &dst, 0, sizeof( struct ofp_queue_stats ) );
|
1344
|
+
|
1345
|
+
uint64_t tx_bytes = 10000000;
|
1346
|
+
uint64_t tx_packets = 10000;
|
1347
|
+
uint64_t tx_errors = 1;
|
1348
|
+
|
1349
|
+
src.port_no = htons( 1 );
|
1350
|
+
src.queue_id = htonl( 3 );
|
1351
|
+
src.tx_bytes = htonll( tx_bytes );
|
1352
|
+
src.tx_packets = htonll( tx_packets );
|
1353
|
+
src.tx_errors = htonll( tx_errors );
|
1354
|
+
|
1355
|
+
ntoh_queue_stats( &dst, &src );
|
1356
|
+
|
1357
|
+
assert_int_equal( htons( dst.port_no ), src.port_no );
|
1358
|
+
assert_int_equal( ( int ) htonl( dst.queue_id ), ( int ) src.queue_id );
|
1359
|
+
assert_memory_equal( &dst.tx_bytes, &tx_bytes, sizeof( uint64_t ) );
|
1360
|
+
assert_memory_equal( &dst.tx_packets, &tx_packets, sizeof( uint64_t ) );
|
1361
|
+
assert_memory_equal( &dst.tx_errors, &tx_errors, sizeof( uint64_t ) );
|
1362
|
+
}
|
1363
|
+
|
1364
|
+
|
1365
|
+
/********************************************************************************
|
1366
|
+
* ntoh_queue_property() tests.
|
1367
|
+
********************************************************************************/
|
1368
|
+
|
1369
|
+
void
|
1370
|
+
test_ntoh_queue_property_with_OFPQT_NONE() {
|
1371
|
+
struct ofp_queue_prop_header dst;
|
1372
|
+
struct ofp_queue_prop_header src;
|
1373
|
+
|
1374
|
+
memset( &src, 0, sizeof( struct ofp_queue_prop_header ) );
|
1375
|
+
memset( &dst, 0, sizeof( struct ofp_queue_prop_header ) );
|
1376
|
+
|
1377
|
+
src.property = htons( OFPQT_NONE );
|
1378
|
+
src.len = htons( 8 );
|
1379
|
+
|
1380
|
+
ntoh_queue_property( &dst, &src );
|
1381
|
+
|
1382
|
+
assert_int_equal( htons( dst.property ), src.property );
|
1383
|
+
assert_int_equal( htons( dst.len ), src.len );
|
1384
|
+
}
|
1385
|
+
|
1386
|
+
|
1387
|
+
void
|
1388
|
+
test_ntoh_queue_property_with_OFPQT_MIN_RATE() {
|
1389
|
+
struct ofp_queue_prop_min_rate dst;
|
1390
|
+
struct ofp_queue_prop_min_rate src;
|
1391
|
+
|
1392
|
+
memset( &src, 0, sizeof( struct ofp_queue_prop_min_rate ) );
|
1393
|
+
memset( &dst, 0, sizeof( struct ofp_queue_prop_min_rate ) );
|
1394
|
+
|
1395
|
+
src.prop_header.property = htons( OFPQT_MIN_RATE );
|
1396
|
+
src.prop_header.len = htons( 16 );
|
1397
|
+
src.rate = htons( 500 );
|
1398
|
+
|
1399
|
+
ntoh_queue_property( ( struct ofp_queue_prop_header * ) &dst, ( struct ofp_queue_prop_header * ) &src );
|
1400
|
+
|
1401
|
+
assert_int_equal( htons( dst.prop_header.property ), src.prop_header.property );
|
1402
|
+
assert_int_equal( htons( dst.prop_header.len ), src.prop_header.len );
|
1403
|
+
assert_int_equal( htons( dst.rate ), src.rate );
|
1404
|
+
}
|
1405
|
+
|
1406
|
+
|
1407
|
+
/********************************************************************************
|
1408
|
+
* hton_queue_property() tests.
|
1409
|
+
********************************************************************************/
|
1410
|
+
|
1411
|
+
void
|
1412
|
+
test_hton_queue_property_with_OFPQT_NONE() {
|
1413
|
+
struct ofp_queue_prop_header dst;
|
1414
|
+
struct ofp_queue_prop_header src;
|
1415
|
+
|
1416
|
+
memset( &src, 0, sizeof( struct ofp_queue_prop_header ) );
|
1417
|
+
memset( &dst, 0, sizeof( struct ofp_queue_prop_header ) );
|
1418
|
+
|
1419
|
+
src.property = OFPQT_NONE;
|
1420
|
+
src.len = 8;
|
1421
|
+
|
1422
|
+
hton_queue_property( &dst, &src );
|
1423
|
+
|
1424
|
+
assert_int_equal( dst.property, htons( src.property ) );
|
1425
|
+
assert_int_equal( dst.len, htons( src.len ) );
|
1426
|
+
}
|
1427
|
+
|
1428
|
+
|
1429
|
+
void
|
1430
|
+
test_hton_queue_property_with_OFPQT_MIN_RATE() {
|
1431
|
+
struct ofp_queue_prop_min_rate dst;
|
1432
|
+
struct ofp_queue_prop_min_rate src;
|
1433
|
+
|
1434
|
+
memset( &src, 0, sizeof( struct ofp_queue_prop_min_rate ) );
|
1435
|
+
memset( &dst, 0, sizeof( struct ofp_queue_prop_min_rate ) );
|
1436
|
+
|
1437
|
+
src.prop_header.property = OFPQT_MIN_RATE;
|
1438
|
+
src.prop_header.len = 16;
|
1439
|
+
src.rate = 500;
|
1440
|
+
|
1441
|
+
hton_queue_property( ( struct ofp_queue_prop_header * ) &dst, ( struct ofp_queue_prop_header * ) &src );
|
1442
|
+
|
1443
|
+
assert_int_equal( dst.prop_header.property, htons( src.prop_header.property ) );
|
1444
|
+
assert_int_equal( dst.prop_header.len, htons( src.prop_header.len ) );
|
1445
|
+
assert_int_equal( dst.rate, htons( src.rate ) );
|
1446
|
+
}
|
1447
|
+
|
1448
|
+
|
1449
|
+
/********************************************************************************
|
1450
|
+
* ntoh_packet_queue() tests.
|
1451
|
+
********************************************************************************/
|
1452
|
+
|
1453
|
+
void
|
1454
|
+
test_ntoh_packet_queue_with_single_OFPQT_NONE() {
|
1455
|
+
uint16_t length = ( uint16_t ) ( offsetof( struct ofp_packet_queue, properties ) + sizeof( struct ofp_queue_prop_header ) );
|
1456
|
+
|
1457
|
+
struct ofp_packet_queue *src = xmalloc( length );
|
1458
|
+
struct ofp_packet_queue *dst = xmalloc( length );
|
1459
|
+
|
1460
|
+
memset( src, 0, length );
|
1461
|
+
memset( dst, 0, length );
|
1462
|
+
|
1463
|
+
src->queue_id = htonl( 3 );
|
1464
|
+
src->len = htons( length );
|
1465
|
+
struct ofp_queue_prop_header *ph_src = src->properties;
|
1466
|
+
ph_src->property = htons( OFPQT_NONE );
|
1467
|
+
ph_src->len = htons( 8 );
|
1468
|
+
|
1469
|
+
ntoh_packet_queue( dst, src );
|
1470
|
+
|
1471
|
+
struct ofp_queue_prop_header *ph_dst = dst->properties;
|
1472
|
+
|
1473
|
+
assert_int_equal( ( int ) htonl( dst->queue_id ), ( int ) src->queue_id );
|
1474
|
+
assert_int_equal( htons( dst->len ), src->len );
|
1475
|
+
assert_int_equal( htons( ph_dst->property ), ph_src->property );
|
1476
|
+
assert_int_equal( htons( ph_dst->len ), ph_src->len );
|
1477
|
+
|
1478
|
+
xfree( src );
|
1479
|
+
xfree( dst );
|
1480
|
+
}
|
1481
|
+
|
1482
|
+
|
1483
|
+
void
|
1484
|
+
test_ntoh_packet_queue_with_single_OFPQT_MIN_RATE() {
|
1485
|
+
uint16_t length = ( uint16_t ) ( offsetof( struct ofp_packet_queue, properties ) + sizeof( struct ofp_queue_prop_min_rate ) );
|
1486
|
+
|
1487
|
+
struct ofp_packet_queue *src = xmalloc( length );
|
1488
|
+
struct ofp_packet_queue *dst = xmalloc( length );
|
1489
|
+
|
1490
|
+
memset( src, 0, length );
|
1491
|
+
memset( dst, 0, length );
|
1492
|
+
|
1493
|
+
src->queue_id = htonl( 3 );
|
1494
|
+
src->len = htons( length );
|
1495
|
+
struct ofp_queue_prop_min_rate *pm_src = ( struct ofp_queue_prop_min_rate * ) src->properties;
|
1496
|
+
pm_src->prop_header.property = htons( OFPQT_MIN_RATE );
|
1497
|
+
pm_src->prop_header.len = htons( 16 );
|
1498
|
+
pm_src->rate = htons( 500 );
|
1499
|
+
|
1500
|
+
ntoh_packet_queue( dst, src );
|
1501
|
+
|
1502
|
+
struct ofp_queue_prop_min_rate *pm_dst = ( struct ofp_queue_prop_min_rate * ) dst->properties;
|
1503
|
+
|
1504
|
+
assert_int_equal( ( int ) htonl( dst->queue_id ), ( int ) src->queue_id );
|
1505
|
+
assert_int_equal( htons( dst->len ), src->len );
|
1506
|
+
assert_int_equal( htons( pm_dst->prop_header.property ), pm_src->prop_header.property );
|
1507
|
+
assert_int_equal( htons( pm_dst->prop_header.len ), pm_src->prop_header.len );
|
1508
|
+
assert_int_equal( htons( pm_dst->rate ), pm_src->rate );
|
1509
|
+
|
1510
|
+
xfree( src );
|
1511
|
+
xfree( dst );
|
1512
|
+
}
|
1513
|
+
|
1514
|
+
|
1515
|
+
void
|
1516
|
+
test_ntoh_packet_queue_with_OFPQT_NONE_and_OFPQT_MIN_RATE() {
|
1517
|
+
uint16_t length = ( uint16_t ) ( offsetof( struct ofp_packet_queue, properties ) + sizeof( struct ofp_queue_prop_header ) + sizeof( struct ofp_queue_prop_min_rate ) );
|
1518
|
+
|
1519
|
+
struct ofp_packet_queue *src = xmalloc( length );
|
1520
|
+
struct ofp_packet_queue *dst = xmalloc( length );
|
1521
|
+
|
1522
|
+
memset( src, 0, length );
|
1523
|
+
memset( dst, 0, length );
|
1524
|
+
|
1525
|
+
src->queue_id = htonl( 3 );
|
1526
|
+
src->len = htons( length );
|
1527
|
+
struct ofp_queue_prop_header *ph_src = src->properties;
|
1528
|
+
ph_src->property = htons( OFPQT_NONE );
|
1529
|
+
ph_src->len = htons( 8 );
|
1530
|
+
struct ofp_queue_prop_min_rate *pm_src = ( struct ofp_queue_prop_min_rate * ) ( ( char * ) src->properties + sizeof( struct ofp_queue_prop_header ) );
|
1531
|
+
pm_src->prop_header.property = htons( OFPQT_MIN_RATE );
|
1532
|
+
pm_src->prop_header.len = htons( 16 );
|
1533
|
+
pm_src->rate = htons( 500 );
|
1534
|
+
|
1535
|
+
ntoh_packet_queue( dst, src );
|
1536
|
+
|
1537
|
+
struct ofp_queue_prop_header *ph_dst = dst->properties;
|
1538
|
+
struct ofp_queue_prop_min_rate *pm_dst = ( struct ofp_queue_prop_min_rate * ) ( ( char * ) dst->properties + sizeof( struct ofp_queue_prop_header ) );
|
1539
|
+
|
1540
|
+
assert_int_equal( ( int ) htonl( dst->queue_id ), ( int ) src->queue_id );
|
1541
|
+
assert_int_equal( htons( dst->len ), src->len );
|
1542
|
+
assert_int_equal( htons( ph_dst->property ), ph_src->property );
|
1543
|
+
assert_int_equal( htons( ph_dst->len ), ph_src->len );
|
1544
|
+
assert_int_equal( htons( pm_dst->prop_header.property ),
|
1545
|
+
pm_src->prop_header.property );
|
1546
|
+
assert_int_equal( htons( pm_dst->prop_header.len ),
|
1547
|
+
pm_src->prop_header.len );
|
1548
|
+
assert_int_equal( htons( pm_dst->rate ), pm_src->rate );
|
1549
|
+
|
1550
|
+
xfree( src );
|
1551
|
+
xfree( dst );
|
1552
|
+
}
|
1553
|
+
|
1554
|
+
|
1555
|
+
/********************************************************************************
|
1556
|
+
* hton_packet_queue() tests.
|
1557
|
+
********************************************************************************/
|
1558
|
+
|
1559
|
+
void
|
1560
|
+
test_hton_packet_queue_with_single_OFPQT_NONE() {
|
1561
|
+
uint16_t length = ( uint16_t ) ( offsetof( struct ofp_packet_queue, properties ) + sizeof( struct ofp_queue_prop_header ) );
|
1562
|
+
|
1563
|
+
struct ofp_packet_queue *src = xmalloc( length );
|
1564
|
+
struct ofp_packet_queue *dst = xmalloc( length );
|
1565
|
+
|
1566
|
+
memset( src, 0, length );
|
1567
|
+
memset( dst, 0, length );
|
1568
|
+
|
1569
|
+
src->queue_id = 3;
|
1570
|
+
src->len = length;
|
1571
|
+
struct ofp_queue_prop_header *ph_src = src->properties;
|
1572
|
+
ph_src->property = OFPQT_NONE;
|
1573
|
+
ph_src->len = 8;
|
1574
|
+
|
1575
|
+
hton_packet_queue( dst, src );
|
1576
|
+
|
1577
|
+
struct ofp_queue_prop_header *ph_dst = dst->properties;
|
1578
|
+
|
1579
|
+
assert_int_equal( ( int ) dst->queue_id, ( int ) htonl( src->queue_id ) );
|
1580
|
+
assert_int_equal( dst->len, htons( src->len ) );
|
1581
|
+
assert_int_equal( ph_dst->property, htons( ph_src->property ) );
|
1582
|
+
assert_int_equal( ph_dst->len, htons( ph_src->len ) );
|
1583
|
+
|
1584
|
+
xfree( src );
|
1585
|
+
xfree( dst );
|
1586
|
+
}
|
1587
|
+
|
1588
|
+
|
1589
|
+
void
|
1590
|
+
test_hton_packet_queue_with_single_OFPQT_MIN_RATE() {
|
1591
|
+
uint16_t length = ( uint16_t ) ( offsetof( struct ofp_packet_queue, properties ) + sizeof( struct ofp_queue_prop_min_rate ) );
|
1592
|
+
|
1593
|
+
struct ofp_packet_queue *src = xmalloc( length );
|
1594
|
+
struct ofp_packet_queue *dst = xmalloc( length );
|
1595
|
+
|
1596
|
+
memset( src, 0, length );
|
1597
|
+
memset( dst, 0, length );
|
1598
|
+
|
1599
|
+
src->queue_id = 3;
|
1600
|
+
src->len = length;
|
1601
|
+
struct ofp_queue_prop_min_rate *pm_src = ( struct ofp_queue_prop_min_rate * ) src->properties;
|
1602
|
+
pm_src->prop_header.property = OFPQT_MIN_RATE;
|
1603
|
+
pm_src->prop_header.len = 16;
|
1604
|
+
pm_src->rate = 500;
|
1605
|
+
|
1606
|
+
hton_packet_queue( dst, src );
|
1607
|
+
|
1608
|
+
struct ofp_queue_prop_min_rate *pm_dst = ( struct ofp_queue_prop_min_rate * ) dst->properties;
|
1609
|
+
|
1610
|
+
assert_int_equal( ( int ) dst->queue_id, ( int ) htonl( src->queue_id ) );
|
1611
|
+
assert_int_equal( dst->len, htons( src->len ) );
|
1612
|
+
assert_int_equal( pm_dst->prop_header.property, htons( pm_src->prop_header.property ) );
|
1613
|
+
assert_int_equal( pm_dst->prop_header.len, htons( pm_src->prop_header.len ) );
|
1614
|
+
assert_int_equal( pm_dst->rate, htons( pm_src->rate ) );
|
1615
|
+
|
1616
|
+
xfree( src );
|
1617
|
+
xfree( dst );
|
1618
|
+
}
|
1619
|
+
|
1620
|
+
|
1621
|
+
void
|
1622
|
+
test_hton_packet_queue_with_OFPQT_NONE_and_OFPQT_MIN_RATE() {
|
1623
|
+
uint16_t length = ( uint16_t ) ( offsetof( struct ofp_packet_queue, properties ) + sizeof( struct ofp_queue_prop_header ) + sizeof( struct ofp_queue_prop_min_rate ) );
|
1624
|
+
|
1625
|
+
struct ofp_packet_queue *src = xmalloc( length );
|
1626
|
+
struct ofp_packet_queue *dst = xmalloc( length );
|
1627
|
+
|
1628
|
+
memset( src, 0, length );
|
1629
|
+
memset( dst, 0, length );
|
1630
|
+
|
1631
|
+
src->queue_id = 3;
|
1632
|
+
src->len = length;
|
1633
|
+
struct ofp_queue_prop_header *ph_src = src->properties;
|
1634
|
+
ph_src->property = OFPQT_NONE;
|
1635
|
+
ph_src->len = 8;
|
1636
|
+
struct ofp_queue_prop_min_rate *pm_src = ( struct ofp_queue_prop_min_rate * ) ( ( char * ) src->properties + sizeof( struct ofp_queue_prop_header ) );
|
1637
|
+
pm_src->prop_header.property = OFPQT_MIN_RATE;
|
1638
|
+
pm_src->prop_header.len = 16;
|
1639
|
+
pm_src->rate = 500;
|
1640
|
+
|
1641
|
+
hton_packet_queue( dst, src );
|
1642
|
+
|
1643
|
+
struct ofp_queue_prop_header *ph_dst = dst->properties;
|
1644
|
+
struct ofp_queue_prop_min_rate *pm_dst = ( struct ofp_queue_prop_min_rate * ) ( ( char * ) dst->properties + sizeof( struct ofp_queue_prop_header ) );
|
1645
|
+
|
1646
|
+
assert_int_equal( ( int ) dst->queue_id, ( int ) htonl( src->queue_id ) );
|
1647
|
+
assert_int_equal( dst->len, htons( src->len ) );
|
1648
|
+
assert_int_equal( ph_dst->property, htons( ph_src->property ) );
|
1649
|
+
assert_int_equal( ph_dst->len, htons( ph_src->len ) );
|
1650
|
+
assert_int_equal( pm_dst->prop_header.property,
|
1651
|
+
htons( pm_src->prop_header.property ) );
|
1652
|
+
assert_int_equal( pm_dst->prop_header.len,
|
1653
|
+
htons( pm_src->prop_header.len ) );
|
1654
|
+
assert_int_equal( pm_dst->rate, htons( pm_src->rate ) );
|
1655
|
+
|
1656
|
+
xfree( src );
|
1657
|
+
xfree( dst );
|
1658
|
+
}
|
1659
|
+
|
1660
|
+
|
1661
|
+
/********************************************************************************
|
1662
|
+
* Run tests.
|
1663
|
+
********************************************************************************/
|
1664
|
+
|
1665
|
+
int
|
1666
|
+
main() {
|
1667
|
+
// FIXME: mockanize in setup()
|
1668
|
+
die = mock_die;
|
1669
|
+
|
1670
|
+
const UnitTest tests[] = {
|
1671
|
+
unit_test( test_ntoh_match ),
|
1672
|
+
unit_test( test_ntoh_phy_port ),
|
1673
|
+
unit_test( test_ntoh_action_output ),
|
1674
|
+
unit_test( test_ntoh_action_vlan_vid ),
|
1675
|
+
unit_test( test_ntoh_action_vlan_pcp ),
|
1676
|
+
unit_test( test_ntoh_action_strip_vlan ),
|
1677
|
+
unit_test( test_ntoh_action_dl_addr ),
|
1678
|
+
unit_test( test_ntoh_action_nw_addr ),
|
1679
|
+
unit_test( test_ntoh_action_nw_tos ),
|
1680
|
+
unit_test( test_ntoh_action_tp_port ),
|
1681
|
+
unit_test( test_ntoh_action_enqueue ),
|
1682
|
+
unit_test( test_ntoh_action_vendor ),
|
1683
|
+
unit_test( test_ntoh_action ),
|
1684
|
+
unit_test( test_ntoh_action_with_undefined_action_type ),
|
1685
|
+
unit_test( test_hton_action ),
|
1686
|
+
unit_test( test_hton_action_with_undefined_action_type ),
|
1687
|
+
unit_test( test_ntoh_flow_stats_without_action ),
|
1688
|
+
unit_test( test_ntoh_flow_stats_with_single_output_action ),
|
1689
|
+
unit_test( test_ntoh_flow_stats_with_two_output_actions ),
|
1690
|
+
unit_test( test_hton_flow_stats_without_action ),
|
1691
|
+
unit_test( test_hton_flow_stats_with_single_output_action ),
|
1692
|
+
unit_test( test_hton_flow_stats_with_two_output_actions ),
|
1693
|
+
unit_test( test_ntoh_aggregate_stats ),
|
1694
|
+
unit_test( test_ntoh_table_stats ),
|
1695
|
+
unit_test( test_ntoh_port_stats ),
|
1696
|
+
unit_test( test_ntoh_queue_stats ),
|
1697
|
+
unit_test( test_ntoh_queue_property_with_OFPQT_NONE ),
|
1698
|
+
unit_test( test_ntoh_queue_property_with_OFPQT_MIN_RATE ),
|
1699
|
+
unit_test( test_hton_queue_property_with_OFPQT_NONE ),
|
1700
|
+
unit_test( test_hton_queue_property_with_OFPQT_MIN_RATE ),
|
1701
|
+
unit_test( test_ntoh_packet_queue_with_single_OFPQT_NONE ),
|
1702
|
+
unit_test( test_ntoh_packet_queue_with_single_OFPQT_MIN_RATE ),
|
1703
|
+
unit_test( test_ntoh_packet_queue_with_OFPQT_NONE_and_OFPQT_MIN_RATE ),
|
1704
|
+
unit_test( test_hton_packet_queue_with_single_OFPQT_NONE ),
|
1705
|
+
unit_test( test_hton_packet_queue_with_single_OFPQT_MIN_RATE ),
|
1706
|
+
unit_test( test_hton_packet_queue_with_OFPQT_NONE_and_OFPQT_MIN_RATE ),
|
1707
|
+
};
|
1708
|
+
return run_tests( tests );
|
1709
|
+
}
|
1710
|
+
|
1711
|
+
|
1712
|
+
/*
|
1713
|
+
* Local variables:
|
1714
|
+
* c-basic-offset: 2
|
1715
|
+
* indent-tabs-mode: nil
|
1716
|
+
* End:
|
1717
|
+
*/
|