trema 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,88 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Author: Yasuhito Takamiya <yasuhito@gmail.com>
|
|
3
|
+
#
|
|
4
|
+
# Copyright (C) 2008-2012 NEC Corporation
|
|
5
|
+
#
|
|
6
|
+
# This program is free software; you can redistribute it and/or modify
|
|
7
|
+
# it under the terms of the GNU General Public License, version 2, as
|
|
8
|
+
# published by the Free Software Foundation.
|
|
9
|
+
#
|
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
# GNU General Public License for more details.
|
|
14
|
+
#
|
|
15
|
+
# You should have received a copy of the GNU General Public License along
|
|
16
|
+
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
17
|
+
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
18
|
+
#
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
require "trema/switch"
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
module Trema
|
|
25
|
+
#
|
|
26
|
+
# Hardware switch that supports OpenFlow protocol.
|
|
27
|
+
#
|
|
28
|
+
class OpenflowSwitch
|
|
29
|
+
#
|
|
30
|
+
# The name of this switch
|
|
31
|
+
#
|
|
32
|
+
# @example
|
|
33
|
+
# switch.name #=> "My expensive OpenFlow switch"
|
|
34
|
+
#
|
|
35
|
+
# @return [String]
|
|
36
|
+
#
|
|
37
|
+
attr_reader :name
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
#
|
|
41
|
+
# Creates a new OpenflowSwitch from {DSL::Switch}
|
|
42
|
+
#
|
|
43
|
+
# @example
|
|
44
|
+
# switch = Trema::OpenflowSwitch.new( stanza )
|
|
45
|
+
#
|
|
46
|
+
# @return [OpenflowSwitch]
|
|
47
|
+
#
|
|
48
|
+
def initialize stanza
|
|
49
|
+
stanza.validate
|
|
50
|
+
@name = stanza.name
|
|
51
|
+
@stanza = stanza
|
|
52
|
+
Switch.add self
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
#
|
|
57
|
+
# Returns datapath id in long format
|
|
58
|
+
#
|
|
59
|
+
# @example
|
|
60
|
+
# switch.dpid_long #=> "0000000000000abc"
|
|
61
|
+
#
|
|
62
|
+
# @return [String]
|
|
63
|
+
#
|
|
64
|
+
def dpid_long
|
|
65
|
+
@stanza.fetch :dpid_long
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
#
|
|
70
|
+
# Returns datapath id prefixed with "0x"
|
|
71
|
+
#
|
|
72
|
+
# @example
|
|
73
|
+
# switch.dpid_short #=> "0xabc"
|
|
74
|
+
#
|
|
75
|
+
# @return [String]
|
|
76
|
+
#
|
|
77
|
+
def dpid_short
|
|
78
|
+
@stanza.fetch :dpid_short
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
### Local variables:
|
|
85
|
+
### mode: Ruby
|
|
86
|
+
### coding: utf-8-unix
|
|
87
|
+
### indent-tabs-mode: nil
|
|
88
|
+
### End:
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Author: Yasuhito Takamiya <yasuhito@gmail.com>
|
|
3
|
+
#
|
|
4
|
+
# Copyright (C) 2008-2012 NEC Corporation
|
|
5
|
+
#
|
|
6
|
+
# This program is free software; you can redistribute it and/or modify
|
|
7
|
+
# it under the terms of the GNU General Public License, version 2, as
|
|
8
|
+
# published by the Free Software Foundation.
|
|
9
|
+
#
|
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
# GNU General Public License for more details.
|
|
14
|
+
#
|
|
15
|
+
# You should have received a copy of the GNU General Public License along
|
|
16
|
+
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
17
|
+
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
18
|
+
#
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
module Trema
|
|
22
|
+
class OrderedHash
|
|
23
|
+
def initialize
|
|
24
|
+
@keys = Array.new
|
|
25
|
+
@content = Hash.new
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def size
|
|
30
|
+
@content.size
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def [] key
|
|
35
|
+
@content[ key ]
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def []= key, value
|
|
40
|
+
@content[ key ] = value
|
|
41
|
+
if not @keys.include?( key )
|
|
42
|
+
@keys << key
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def values
|
|
48
|
+
@keys.map do | each |
|
|
49
|
+
@content[ each ]
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def clear
|
|
55
|
+
@keys.clear
|
|
56
|
+
@content.clear
|
|
57
|
+
self
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def each &block
|
|
62
|
+
@keys.each do | each |
|
|
63
|
+
block.call each, @content[ each ]
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
### Local variables:
|
|
71
|
+
### mode: Ruby
|
|
72
|
+
### coding: utf-8
|
|
73
|
+
### indent-tabs-mode: nil
|
|
74
|
+
### End:
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Author: Nick Karanatsios <nickkaranatsios@gmail.com>
|
|
3
|
+
#
|
|
4
|
+
# Copyright (C) 2008-2012 NEC Corporation
|
|
5
|
+
#
|
|
6
|
+
# This program is free software; you can redistribute it and/or modify
|
|
7
|
+
# it under the terms of the GNU General Public License, version 2, as
|
|
8
|
+
# published by the Free Software Foundation.
|
|
9
|
+
#
|
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
# GNU General Public License for more details.
|
|
14
|
+
#
|
|
15
|
+
# You should have received a copy of the GNU General Public License along
|
|
16
|
+
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
17
|
+
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
18
|
+
#
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class Queue
|
|
22
|
+
class << self
|
|
23
|
+
# @param [PacketQueue] queue
|
|
24
|
+
# the {PacketQueue} to append to the list.
|
|
25
|
+
attr_accessor :queues
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
# Add queue to list.
|
|
30
|
+
# @param [PacketQueue] queue a {PacketQueue} instance.
|
|
31
|
+
def self.append queue
|
|
32
|
+
@queues ||= []
|
|
33
|
+
@queues << queue unless @queues.include?(queue)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
# @return [Array]
|
|
38
|
+
# an array of {PacketQueue} objects.
|
|
39
|
+
def self.queues
|
|
40
|
+
@queues
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
# Iterate over each {PacketQueue} item.
|
|
45
|
+
# @return [Array] a list of {PacketQueue} items.
|
|
46
|
+
def self.each &block
|
|
47
|
+
@queues.each do | each |
|
|
48
|
+
block.call each
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
class PacketQueue
|
|
55
|
+
# No property for queue.
|
|
56
|
+
OFPQT_NONE = 0
|
|
57
|
+
# Minimum datarate guaranteed.
|
|
58
|
+
OFPQT_MIN_RATE = 1
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
# Id for the specific queue.
|
|
62
|
+
# @return [Number] queue_id
|
|
63
|
+
# the value of attribute queue_id.
|
|
64
|
+
attr_accessor :queue_id
|
|
65
|
+
# Queue description's length in bytes.
|
|
66
|
+
# @return [Number] len
|
|
67
|
+
# the value of attribute len.
|
|
68
|
+
attr_accessor :len
|
|
69
|
+
# List of queue properties.
|
|
70
|
+
# @return [Array] properties
|
|
71
|
+
# the value of attribute properties.
|
|
72
|
+
attr_accessor :properties
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
# @overload initialize(options={})
|
|
76
|
+
# @param [Hash] options ths options hash.
|
|
77
|
+
# @option options [Symbol] :queue_id
|
|
78
|
+
# id for the specific queue.
|
|
79
|
+
# @option options [Symbol] :len
|
|
80
|
+
# queue description's length in bytes.
|
|
81
|
+
#
|
|
82
|
+
def initialize options
|
|
83
|
+
@queue_id = options[ :queue_id ]
|
|
84
|
+
@len = options[ :len ]
|
|
85
|
+
@properties = []
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
# @param [MinRateQueue] queue
|
|
90
|
+
# a property queue {MinRateQueue} object to append to the properties list.
|
|
91
|
+
def append queue
|
|
92
|
+
@properties << queue
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
# @return [String]
|
|
97
|
+
# text representation of {PacketQueue}'s attributes and all its properties
|
|
98
|
+
# queue object's attributes.
|
|
99
|
+
def to_s
|
|
100
|
+
str = "queue_id: #{@queue_id} len: #{@len} "
|
|
101
|
+
@properties.each do | each |
|
|
102
|
+
str += each.to_s
|
|
103
|
+
end
|
|
104
|
+
str
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
class QueueProperty
|
|
110
|
+
# Property queue id.
|
|
111
|
+
# For minimum-rate type queue the property value is set to 1, otherwise defaults
|
|
112
|
+
# to zero.
|
|
113
|
+
# @return [Number]
|
|
114
|
+
# the value of attribute property.
|
|
115
|
+
attr_accessor :property
|
|
116
|
+
# length of property. If >= 8 minimum-rate type queue is defined.
|
|
117
|
+
# @return [Number]
|
|
118
|
+
# the value of attribute len.
|
|
119
|
+
attr_accessor :len
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
# Each queue is described by a set of properties, each of a specific type and
|
|
123
|
+
# configuration.
|
|
124
|
+
# @param [Number] property
|
|
125
|
+
# property queue id.
|
|
126
|
+
# @param [Number] len
|
|
127
|
+
# length in bytes of the property queue.
|
|
128
|
+
def initialize property, len
|
|
129
|
+
@property = property
|
|
130
|
+
@len = len
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
# @return [String]
|
|
135
|
+
# text representation of its attributes (property,len).
|
|
136
|
+
def to_s
|
|
137
|
+
"property: #{@property} len: #{@len} "
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
class MinRateQueue < QueueProperty
|
|
143
|
+
# the rate value of the minimum rate queue.
|
|
144
|
+
# @return [Number]
|
|
145
|
+
# the value of attribute rate.
|
|
146
|
+
attr_accessor :rate
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
# An object that encapsulates the minimum rate queue property description.
|
|
150
|
+
# @param [Number] property
|
|
151
|
+
# property queue id.
|
|
152
|
+
# @param [Number] len
|
|
153
|
+
# length in bytes of the property queue.
|
|
154
|
+
# @param [Number] rate
|
|
155
|
+
# the rate value of the mimimum rate queue.
|
|
156
|
+
# @param [PacketQueue] packet_queue
|
|
157
|
+
# A {PacketQueue} instance to use to save the minimum rate queue.
|
|
158
|
+
def initialize property, len, rate, packet_queue
|
|
159
|
+
super property, len
|
|
160
|
+
@rate = rate
|
|
161
|
+
packet_queue.append self
|
|
162
|
+
Queue.append packet_queue
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
# @return [String]
|
|
167
|
+
# text representation of rate prefixed by property and length attributes.
|
|
168
|
+
def to_s
|
|
169
|
+
super.to_s + " rate: #{rate} "
|
|
170
|
+
end
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
### Local variables:
|
|
175
|
+
### mode: Ruby
|
|
176
|
+
### coding: utf-8-unix
|
|
177
|
+
### indent-tabs-mode: nil
|
|
178
|
+
### End:
|
|
@@ -0,0 +1,736 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Author: Yasuhito Takamiya <yasuhito@gmail.com>
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2008-2012 NEC Corporation
|
|
5
|
+
*
|
|
6
|
+
* This program is free software; you can redistribute it and/or modify
|
|
7
|
+
* it under the terms of the GNU General Public License, version 2, as
|
|
8
|
+
* published by the Free Software Foundation.
|
|
9
|
+
*
|
|
10
|
+
* This program is distributed in the hope that it will be useful,
|
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
* GNU General Public License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the GNU General Public License along
|
|
16
|
+
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
17
|
+
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
#include <string.h>
|
|
22
|
+
#include "buffer.h"
|
|
23
|
+
#include "ruby.h"
|
|
24
|
+
#include "trema.h"
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
extern VALUE mTrema;
|
|
28
|
+
VALUE cPacketIn;
|
|
29
|
+
VALUE mPacketInARP;
|
|
30
|
+
VALUE mPacketInIPv4;
|
|
31
|
+
VALUE mPacketInICMPv4;
|
|
32
|
+
VALUE mPacketInIGMP;
|
|
33
|
+
VALUE mPacketInTCP;
|
|
34
|
+
VALUE mPacketInUDP;
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
#define PACKET_IN_RETURN_MAC( packet_member ) { \
|
|
38
|
+
VALUE ret = ULL2NUM( mac_to_uint64( get_packet_in_info( self )->packet_member ) ); \
|
|
39
|
+
return rb_funcall( rb_eval_string( "Trema::Mac" ), rb_intern( "new" ), 1, ret ); }
|
|
40
|
+
|
|
41
|
+
#define PACKET_IN_RETURN_IP( packet_member ) { \
|
|
42
|
+
VALUE ret = ULONG2NUM( get_packet_in_info( self )->packet_member ); \
|
|
43
|
+
return rb_funcall( rb_eval_string( "Trema::IP" ), rb_intern( "new" ), 1, ret ); }
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
#if 0
|
|
47
|
+
/*
|
|
48
|
+
* @overload initialize()
|
|
49
|
+
* Allocates and wraps a {PacketIn} object to store the details of
|
|
50
|
+
* the +OFPT_PACKET_IN+ message.
|
|
51
|
+
*
|
|
52
|
+
* @return [PacketIn] an object that encapsulates the +OPFT_PACKET_IN+ OpenFlow message.
|
|
53
|
+
*/
|
|
54
|
+
static VALUE
|
|
55
|
+
packet_in_init( VALUE kclass ) {
|
|
56
|
+
packet_in *_packet_in = xmalloc( sizeof( packet_in ) );
|
|
57
|
+
return Data_Wrap_Struct( klass, 0, xfree, _packet_in );
|
|
58
|
+
}
|
|
59
|
+
#endif
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
static VALUE
|
|
63
|
+
packet_in_alloc( VALUE klass ) {
|
|
64
|
+
packet_in *_packet_in = xmalloc( sizeof( packet_in ) );
|
|
65
|
+
return Data_Wrap_Struct( klass, 0, xfree, _packet_in );
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
static packet_in *
|
|
70
|
+
get_packet_in( VALUE self ) {
|
|
71
|
+
packet_in *cpacket;
|
|
72
|
+
Data_Get_Struct( self, packet_in, cpacket );
|
|
73
|
+
return cpacket;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
static packet_info *
|
|
78
|
+
get_packet_in_info( VALUE self ) {
|
|
79
|
+
packet_in *cpacket;
|
|
80
|
+
Data_Get_Struct( self, packet_in, cpacket );
|
|
81
|
+
return ( packet_info * ) cpacket->data->user_data;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
/*
|
|
86
|
+
* Message originator identifier.
|
|
87
|
+
*
|
|
88
|
+
* @return [Number] the value of datapath_id.
|
|
89
|
+
*/
|
|
90
|
+
static VALUE
|
|
91
|
+
packet_in_datapath_id( VALUE self ) {
|
|
92
|
+
return ULL2NUM( get_packet_in( self )->datapath_id );
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
/*
|
|
97
|
+
* For this asynchronous message the transaction_id is set to zero.
|
|
98
|
+
*
|
|
99
|
+
* @return [Number] the value of transaction_id.
|
|
100
|
+
*/
|
|
101
|
+
static VALUE
|
|
102
|
+
packet_in_transaction_id( VALUE self ) {
|
|
103
|
+
return ULONG2NUM( get_packet_in( self )->transaction_id );
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
/*
|
|
108
|
+
* Buffer id value signifies if the entire frame (packet is not buffered) or
|
|
109
|
+
* portion of it (packet is buffered) is included in the data field of
|
|
110
|
+
* this +OFPT_PACKET_IN+ message.
|
|
111
|
+
*
|
|
112
|
+
* @return [Number] the value of buffer id.
|
|
113
|
+
*/
|
|
114
|
+
static VALUE
|
|
115
|
+
packet_in_buffer_id( VALUE self ) {
|
|
116
|
+
return ULONG2NUM( get_packet_in( self )->buffer_id );
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
/*
|
|
121
|
+
* A buffer_id value either than +UINT32_MAX+ marks the packet_in as buffered.
|
|
122
|
+
*
|
|
123
|
+
* @return [true] if packet_in is buffered.
|
|
124
|
+
* @return [false] if packet_in is not buffered.
|
|
125
|
+
*/
|
|
126
|
+
static VALUE
|
|
127
|
+
packet_in_is_buffered( VALUE self ) {
|
|
128
|
+
if ( get_packet_in( self )->buffer_id == UINT32_MAX ) {
|
|
129
|
+
return Qfalse;
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
return Qtrue;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
/*
|
|
138
|
+
* The port the frame was received.
|
|
139
|
+
*
|
|
140
|
+
* @return [Number] the value of in_port.
|
|
141
|
+
*/
|
|
142
|
+
static VALUE
|
|
143
|
+
packet_in_in_port( VALUE self ) {
|
|
144
|
+
return INT2NUM( get_packet_in( self )->in_port );
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
/*
|
|
149
|
+
* The full length of the received frame.
|
|
150
|
+
*
|
|
151
|
+
* @return [Number] the value of total_len.
|
|
152
|
+
*/
|
|
153
|
+
static VALUE
|
|
154
|
+
packet_in_total_len( VALUE self ) {
|
|
155
|
+
return INT2NUM( get_packet_in( self )->total_len );
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
/*
|
|
160
|
+
* A String that holds the entire or portion of the received frame.
|
|
161
|
+
* Length of data, total_len - 20 bytes.
|
|
162
|
+
*
|
|
163
|
+
* @return [String] the value of data.
|
|
164
|
+
*/
|
|
165
|
+
static VALUE
|
|
166
|
+
packet_in_data( VALUE self ) {
|
|
167
|
+
const buffer *buf = get_packet_in( self )->data;
|
|
168
|
+
return rb_str_new( buf->data, ( long ) buf->length );
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
/*
|
|
173
|
+
* The reason why the +OFPT_PACKET_IN+ message was sent.
|
|
174
|
+
*
|
|
175
|
+
* @return [Number] the value of reason.
|
|
176
|
+
*/
|
|
177
|
+
static VALUE
|
|
178
|
+
packet_in_reason( VALUE self ) {
|
|
179
|
+
return INT2NUM( get_packet_in( self )->reason );
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
/*
|
|
184
|
+
* The MAC source address.
|
|
185
|
+
*
|
|
186
|
+
* @return [Trema::Mac] macsa MAC source address.
|
|
187
|
+
*/
|
|
188
|
+
static VALUE
|
|
189
|
+
packet_in_macsa( VALUE self ) {
|
|
190
|
+
PACKET_IN_RETURN_MAC( eth_macsa );
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
/*
|
|
195
|
+
* The MAC destination address.
|
|
196
|
+
*
|
|
197
|
+
* @return [Trema::Mac] macda MAC destination address.
|
|
198
|
+
*/
|
|
199
|
+
static VALUE
|
|
200
|
+
packet_in_macda( VALUE self ) {
|
|
201
|
+
PACKET_IN_RETURN_MAC( eth_macda );
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
/*
|
|
206
|
+
* The ethernet type.
|
|
207
|
+
*
|
|
208
|
+
* @return [integer] eth_type The ehternet type.
|
|
209
|
+
*/
|
|
210
|
+
static VALUE
|
|
211
|
+
packet_in_eth_type( VALUE self ) {
|
|
212
|
+
return UINT2NUM( get_packet_in_info( self )->eth_type );
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
/*
|
|
217
|
+
* Is an ARP packet?
|
|
218
|
+
*
|
|
219
|
+
* @return [bool] arp? Is an ARP packet?
|
|
220
|
+
*/
|
|
221
|
+
static VALUE
|
|
222
|
+
packet_in_is_arp( VALUE self ) {
|
|
223
|
+
if ( ( get_packet_in_info( self )->format & NW_ARP ) ) {
|
|
224
|
+
return Qtrue;
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
return Qfalse;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
/*
|
|
233
|
+
* The ARP operation code.
|
|
234
|
+
*
|
|
235
|
+
* @return [integer] arp_oper Operation code.
|
|
236
|
+
*/
|
|
237
|
+
static VALUE
|
|
238
|
+
packet_in_arp_oper( VALUE self ) {
|
|
239
|
+
return UINT2NUM( ( unsigned int ) get_packet_in_info( self )->arp_ar_op );
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
/*
|
|
244
|
+
* The ARP source hardware address.
|
|
245
|
+
*
|
|
246
|
+
* @return [Trema::Mac] arp_sha MAC hardware address.
|
|
247
|
+
*/
|
|
248
|
+
static VALUE
|
|
249
|
+
packet_in_arp_sha( VALUE self ) {
|
|
250
|
+
PACKET_IN_RETURN_MAC( arp_sha );
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
/*
|
|
255
|
+
* The ARP source protocol address.
|
|
256
|
+
*
|
|
257
|
+
* @return [Trema::IP] arp_spa IP protocol address.
|
|
258
|
+
*/
|
|
259
|
+
static VALUE
|
|
260
|
+
packet_in_arp_spa( VALUE self ) {
|
|
261
|
+
PACKET_IN_RETURN_IP( arp_spa );
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
/*
|
|
266
|
+
* The ARP target hardware address.
|
|
267
|
+
*
|
|
268
|
+
* @return [Trema::Mac] arp_tha MAC hardware address.
|
|
269
|
+
*/
|
|
270
|
+
static VALUE
|
|
271
|
+
packet_in_arp_tha( VALUE self ) {
|
|
272
|
+
PACKET_IN_RETURN_MAC( arp_tha );
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
/*
|
|
277
|
+
* The ARP target protocol address.
|
|
278
|
+
*
|
|
279
|
+
* @return [Trema::IP] arp_tpa IP protocol address.
|
|
280
|
+
*/
|
|
281
|
+
static VALUE
|
|
282
|
+
packet_in_arp_tpa( VALUE self ) {
|
|
283
|
+
PACKET_IN_RETURN_IP( arp_tpa );
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
/*
|
|
288
|
+
* Is an IPV4 packet?
|
|
289
|
+
*
|
|
290
|
+
* @return [bool] ipv4? Is an IPV4 packet?
|
|
291
|
+
*/
|
|
292
|
+
static VALUE
|
|
293
|
+
packet_in_is_ipv4( VALUE self ) {
|
|
294
|
+
if ( ( get_packet_in_info( self )->format & NW_IPV4 ) ) {
|
|
295
|
+
return Qtrue;
|
|
296
|
+
}
|
|
297
|
+
else {
|
|
298
|
+
return Qfalse;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
/*
|
|
304
|
+
* The IPV4 source protocol address.
|
|
305
|
+
*
|
|
306
|
+
* @return [Trema::IP] ipv4_saddr IP protocol address.
|
|
307
|
+
*/
|
|
308
|
+
static VALUE
|
|
309
|
+
packet_in_ipv4_saddr( VALUE self ) {
|
|
310
|
+
PACKET_IN_RETURN_IP( ipv4_saddr );
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
/*
|
|
315
|
+
* The IPV4 destination protocol address.
|
|
316
|
+
*
|
|
317
|
+
* @return [Trema::IP] ipv4_daddr IP protocol address.
|
|
318
|
+
*/
|
|
319
|
+
static VALUE
|
|
320
|
+
packet_in_ipv4_daddr( VALUE self ) {
|
|
321
|
+
PACKET_IN_RETURN_IP( ipv4_daddr );
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
/*
|
|
326
|
+
* Is an ICMPv4 packet?
|
|
327
|
+
*
|
|
328
|
+
* @return [bool] icmpv4? Is an ICMPv4 packet?
|
|
329
|
+
*/
|
|
330
|
+
static VALUE
|
|
331
|
+
packet_in_is_icmpv4( VALUE self ) {
|
|
332
|
+
if ( ( get_packet_in_info( self )->format & NW_ICMPV4 ) ) {
|
|
333
|
+
return Qtrue;
|
|
334
|
+
}
|
|
335
|
+
else {
|
|
336
|
+
return Qfalse;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
/*
|
|
342
|
+
* The ICMPv4 message type.
|
|
343
|
+
*
|
|
344
|
+
* @return [Integer] icmpv4_type The ICMPv4 message type.
|
|
345
|
+
*/
|
|
346
|
+
static VALUE
|
|
347
|
+
packet_in_icmpv4_type( VALUE self ) {
|
|
348
|
+
return get_packet_in_info( self )->icmpv4_type;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
/*
|
|
353
|
+
* The ICMPv4 message code.
|
|
354
|
+
*
|
|
355
|
+
* @return [Integer] icmpv4_code The ICMPv4 message code.
|
|
356
|
+
*/
|
|
357
|
+
static VALUE
|
|
358
|
+
packet_in_icmpv4_code( VALUE self ) {
|
|
359
|
+
return get_packet_in_info( self )->icmpv4_code;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
/*
|
|
364
|
+
* The ICMPv4 message checksum.
|
|
365
|
+
*
|
|
366
|
+
* @return [Integer] icmpv4_checksum The ICMPv4 message checksum.
|
|
367
|
+
*/
|
|
368
|
+
static VALUE
|
|
369
|
+
packet_in_icmpv4_checksum( VALUE self ) {
|
|
370
|
+
return UINT2NUM( get_packet_in_info( self )->icmpv4_checksum );
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
/*
|
|
375
|
+
* The identifier of ICMPv4 echo.
|
|
376
|
+
*
|
|
377
|
+
* @return [Integer] icmpv4_id The identifier of ICMPv4 echo.
|
|
378
|
+
*/
|
|
379
|
+
static VALUE
|
|
380
|
+
packet_in_icmpv4_id( VALUE self ) {
|
|
381
|
+
return UINT2NUM( get_packet_in_info( self )->icmpv4_id );
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
|
|
385
|
+
/*
|
|
386
|
+
* The sequence number of ICMPv4 echo.
|
|
387
|
+
*
|
|
388
|
+
* @return [Integer] icmpv4_id The sequence number of ICMPv4 echo.
|
|
389
|
+
*/
|
|
390
|
+
static VALUE
|
|
391
|
+
packet_in_icmpv4_seq( VALUE self ) {
|
|
392
|
+
return UINT2NUM( get_packet_in_info( self )->icmpv4_seq );
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
|
|
396
|
+
/*
|
|
397
|
+
* The gateway address of ICMPv4 redicect.
|
|
398
|
+
*
|
|
399
|
+
* @return [Trema::IP] icmp_gateway The gateway address of ICMPv4 redicect.
|
|
400
|
+
*/
|
|
401
|
+
static VALUE
|
|
402
|
+
packet_in_icmpv4_gateway( VALUE self ) {
|
|
403
|
+
PACKET_IN_RETURN_IP( icmpv4_gateway );
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
|
|
407
|
+
/*
|
|
408
|
+
* Is an IGMP packet?
|
|
409
|
+
*
|
|
410
|
+
* @return [bool] igmp? Is an IGMP packet?
|
|
411
|
+
*/
|
|
412
|
+
static VALUE
|
|
413
|
+
packet_in_is_igmp( VALUE self ) {
|
|
414
|
+
if ( ( get_packet_in_info( self )->format & NW_IGMP ) ) {
|
|
415
|
+
return Qtrue;
|
|
416
|
+
}
|
|
417
|
+
else {
|
|
418
|
+
return Qfalse;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
|
|
423
|
+
/*
|
|
424
|
+
* Is an IGMP membership query packet?
|
|
425
|
+
*
|
|
426
|
+
* @return [bool] igmp_membership_query? Is an IGMP membership query packet?
|
|
427
|
+
*/
|
|
428
|
+
static VALUE
|
|
429
|
+
packet_in_is_igmp_membership_query( VALUE self ) {
|
|
430
|
+
if ( packet_type_igmp_membership_query( get_packet_in( self )->data ) ) {
|
|
431
|
+
return Qtrue;
|
|
432
|
+
}
|
|
433
|
+
else {
|
|
434
|
+
return Qfalse;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
|
|
439
|
+
/*
|
|
440
|
+
* Is an IGMP v1 membership report packet?
|
|
441
|
+
*
|
|
442
|
+
* @return [bool] igmp_v1_membership_report? Is an IGMP v1 membership report packet?
|
|
443
|
+
*/
|
|
444
|
+
static VALUE
|
|
445
|
+
packet_in_is_igmp_v1_membership_report( VALUE self ) {
|
|
446
|
+
if ( packet_type_igmp_v1_membership_report( get_packet_in( self )->data ) ) {
|
|
447
|
+
return Qtrue;
|
|
448
|
+
}
|
|
449
|
+
else {
|
|
450
|
+
return Qfalse;
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
|
|
455
|
+
/*
|
|
456
|
+
* Is an IGMP v2 membership report packet?
|
|
457
|
+
*
|
|
458
|
+
* @return [bool] igmp_v2_membership_report? Is an IGMP v2 membership report packet?
|
|
459
|
+
*/
|
|
460
|
+
static VALUE
|
|
461
|
+
packet_in_is_igmp_v2_membership_report( VALUE self ) {
|
|
462
|
+
if ( packet_type_igmp_v2_membership_report( get_packet_in( self )->data ) ) {
|
|
463
|
+
return Qtrue;
|
|
464
|
+
}
|
|
465
|
+
else {
|
|
466
|
+
return Qfalse;
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
|
|
471
|
+
/*
|
|
472
|
+
* Is an IGMP v2 leave group packet?
|
|
473
|
+
*
|
|
474
|
+
* @return [bool] igmp_v2_leave_group? Is an IGMP v2 leave group packet?
|
|
475
|
+
*/
|
|
476
|
+
static VALUE
|
|
477
|
+
packet_in_is_igmp_v2_leave_group( VALUE self ) {
|
|
478
|
+
if ( packet_type_igmp_v2_leave_group( get_packet_in( self )->data ) ) {
|
|
479
|
+
return Qtrue;
|
|
480
|
+
}
|
|
481
|
+
else {
|
|
482
|
+
return Qfalse;
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
|
|
487
|
+
/*
|
|
488
|
+
* Is an IGMP v3 membership report packet?
|
|
489
|
+
*
|
|
490
|
+
* @return [bool] igmp_v3_membership_report? Is an IGMP v3 membership report packet?
|
|
491
|
+
*/
|
|
492
|
+
static VALUE
|
|
493
|
+
packet_in_is_igmp_v3_membership_report( VALUE self ) {
|
|
494
|
+
if ( packet_type_igmp_v3_membership_report( get_packet_in( self )->data ) ) {
|
|
495
|
+
return Qtrue;
|
|
496
|
+
}
|
|
497
|
+
else {
|
|
498
|
+
return Qfalse;
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
|
|
503
|
+
/*
|
|
504
|
+
* The IGMP message type.
|
|
505
|
+
*
|
|
506
|
+
* @return [Integer] igmp_type IGMP type.
|
|
507
|
+
*/
|
|
508
|
+
static VALUE
|
|
509
|
+
packet_in_igmp_type( VALUE self ) {
|
|
510
|
+
return UINT2NUM( get_packet_in_info( self )->igmp_type );
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
|
|
514
|
+
/*
|
|
515
|
+
* The IGMP group address.
|
|
516
|
+
*
|
|
517
|
+
* @return [Trema::IP] igmp_group an IGMP group address.
|
|
518
|
+
*/
|
|
519
|
+
static VALUE
|
|
520
|
+
packet_in_igmp_group( VALUE self ) {
|
|
521
|
+
PACKET_IN_RETURN_IP( igmp_group );
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
|
|
525
|
+
/*
|
|
526
|
+
* Is a TCP packet?
|
|
527
|
+
*
|
|
528
|
+
* @return [bool] tcp? Is a TCP packet?
|
|
529
|
+
*/
|
|
530
|
+
static VALUE
|
|
531
|
+
packet_in_is_tcp( VALUE self ) {
|
|
532
|
+
if ( ( get_packet_in_info( self )->format & TP_TCP ) ) {
|
|
533
|
+
return Qtrue;
|
|
534
|
+
}
|
|
535
|
+
else {
|
|
536
|
+
return Qfalse;
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
|
|
541
|
+
/*
|
|
542
|
+
* The TCP source port.
|
|
543
|
+
*
|
|
544
|
+
* @return [Integer] tcp_src_port TCP port.
|
|
545
|
+
*/
|
|
546
|
+
static VALUE
|
|
547
|
+
packet_in_tcp_src_port( VALUE self ) {
|
|
548
|
+
return ULONG2NUM( get_packet_in_info( self )->tcp_src_port );
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
|
|
552
|
+
/*
|
|
553
|
+
* The TCP destination port.
|
|
554
|
+
*
|
|
555
|
+
* @return [Integer] tcp_dst_port TCP port.
|
|
556
|
+
*/
|
|
557
|
+
static VALUE
|
|
558
|
+
packet_in_tcp_dst_port( VALUE self ) {
|
|
559
|
+
return ULONG2NUM( get_packet_in_info( self )->tcp_dst_port );
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
|
|
563
|
+
/*
|
|
564
|
+
* Is an UDP packet?
|
|
565
|
+
*
|
|
566
|
+
* @return [bool] udp? Is an UDP packet?
|
|
567
|
+
*/
|
|
568
|
+
static VALUE
|
|
569
|
+
packet_in_is_udp( VALUE self ) {
|
|
570
|
+
if ( ( get_packet_in_info( self )->format & TP_UDP ) ) {
|
|
571
|
+
return Qtrue;
|
|
572
|
+
}
|
|
573
|
+
else {
|
|
574
|
+
return Qfalse;
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
|
|
579
|
+
/*
|
|
580
|
+
* A String that holds the UDP payload.
|
|
581
|
+
* Length of data, total_len - 20 bytes.
|
|
582
|
+
*
|
|
583
|
+
* @return [String] the value of data.
|
|
584
|
+
*/
|
|
585
|
+
static VALUE
|
|
586
|
+
packet_in_udp_payload( VALUE self ) {
|
|
587
|
+
packet_info *cpacket = get_packet_in_info( self );
|
|
588
|
+
return rb_str_new( cpacket->l4_payload, ( long ) cpacket->l4_payload_length );
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
|
|
592
|
+
/*
|
|
593
|
+
* The UDP source port.
|
|
594
|
+
*
|
|
595
|
+
* @return [Integer] udp_src_port UDP port.
|
|
596
|
+
*/
|
|
597
|
+
static VALUE
|
|
598
|
+
packet_in_udp_src_port( VALUE self ) {
|
|
599
|
+
return ULONG2NUM( get_packet_in_info( self )->udp_src_port );
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
|
|
603
|
+
/*
|
|
604
|
+
* The UDP destination port.
|
|
605
|
+
*
|
|
606
|
+
* @return [Integer] udp_dst_port UDP port.
|
|
607
|
+
*/
|
|
608
|
+
static VALUE
|
|
609
|
+
packet_in_udp_dst_port( VALUE self ) {
|
|
610
|
+
return ULONG2NUM( get_packet_in_info( self )->udp_dst_port );
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
|
|
614
|
+
void
|
|
615
|
+
Init_packet_in() {
|
|
616
|
+
rb_require( "trema/ip" );
|
|
617
|
+
rb_require( "trema/mac" );
|
|
618
|
+
cPacketIn = rb_define_class_under( mTrema, "PacketIn", rb_cObject );
|
|
619
|
+
rb_define_alloc_func( cPacketIn, packet_in_alloc );
|
|
620
|
+
#if 0
|
|
621
|
+
/*
|
|
622
|
+
* Do not remove this is to fake yard to create a constructor for
|
|
623
|
+
* PacketIn object.
|
|
624
|
+
*/
|
|
625
|
+
rb_define_method( cPacketIn, "initialize", packet_in_init, 0 );
|
|
626
|
+
#endif
|
|
627
|
+
rb_define_method( cPacketIn, "datapath_id", packet_in_datapath_id, 0 );
|
|
628
|
+
rb_define_method( cPacketIn, "transaction_id", packet_in_transaction_id, 0 );
|
|
629
|
+
rb_define_method( cPacketIn, "buffer_id", packet_in_buffer_id, 0 );
|
|
630
|
+
rb_define_method( cPacketIn, "buffered?", packet_in_is_buffered, 0 );
|
|
631
|
+
rb_define_method( cPacketIn, "in_port", packet_in_in_port, 0 );
|
|
632
|
+
rb_define_method( cPacketIn, "total_len", packet_in_total_len, 0 );
|
|
633
|
+
rb_define_method( cPacketIn, "reason", packet_in_reason, 0 );
|
|
634
|
+
rb_define_method( cPacketIn, "data", packet_in_data, 0 );
|
|
635
|
+
|
|
636
|
+
rb_define_method( cPacketIn, "macsa", packet_in_macsa, 0 );
|
|
637
|
+
rb_define_method( cPacketIn, "macda", packet_in_macda, 0 );
|
|
638
|
+
rb_define_method( cPacketIn, "eth_type", packet_in_eth_type, 0 );
|
|
639
|
+
|
|
640
|
+
rb_define_method( cPacketIn, "arp?", packet_in_is_arp, 0 );
|
|
641
|
+
rb_define_method( cPacketIn, "ipv4?", packet_in_is_ipv4, 0 );
|
|
642
|
+
rb_define_method( cPacketIn, "icmpv4?", packet_in_is_icmpv4, 0 );
|
|
643
|
+
rb_define_method( cPacketIn, "igmp?", packet_in_is_igmp, 0 );
|
|
644
|
+
rb_define_method( cPacketIn, "tcp?", packet_in_is_tcp, 0 );
|
|
645
|
+
rb_define_method( cPacketIn, "udp?", packet_in_is_udp, 0 );
|
|
646
|
+
|
|
647
|
+
mPacketInARP = rb_define_module_under( mTrema, "PacketInARP" );
|
|
648
|
+
rb_define_method( mPacketInARP, "arp_oper", packet_in_arp_oper, 0 );
|
|
649
|
+
rb_define_method( mPacketInARP, "arp_sha", packet_in_arp_sha, 0 );
|
|
650
|
+
rb_define_method( mPacketInARP, "arp_spa", packet_in_arp_spa, 0 );
|
|
651
|
+
rb_define_method( mPacketInARP, "arp_tha", packet_in_arp_tha, 0 );
|
|
652
|
+
rb_define_method( mPacketInARP, "arp_tpa", packet_in_arp_tpa, 0 );
|
|
653
|
+
|
|
654
|
+
mPacketInIPv4 = rb_define_module_under( mTrema, "PacketInIPv4" );
|
|
655
|
+
rb_define_method( mPacketInIPv4, "ipv4_saddr", packet_in_ipv4_saddr, 0 );
|
|
656
|
+
rb_define_method( mPacketInIPv4, "ipv4_daddr", packet_in_ipv4_daddr, 0 );
|
|
657
|
+
|
|
658
|
+
mPacketInICMPv4 = rb_define_module_under( mTrema, "PacketInICMPv4" );
|
|
659
|
+
rb_define_method( mPacketInICMPv4, "icmpv4_type", packet_in_icmpv4_type, 0 );
|
|
660
|
+
rb_define_method( mPacketInICMPv4, "icmpv4_code", packet_in_icmpv4_code, 0 );
|
|
661
|
+
rb_define_method( mPacketInICMPv4, "icmpv4_checksum", packet_in_icmpv4_checksum, 0 );
|
|
662
|
+
rb_define_method( mPacketInICMPv4, "icmpv4_id", packet_in_icmpv4_id, 0 );
|
|
663
|
+
rb_define_method( mPacketInICMPv4, "icmpv4_seq", packet_in_icmpv4_seq, 0 );
|
|
664
|
+
rb_define_method( mPacketInICMPv4, "icmpv4_group", packet_in_icmpv4_gateway, 0 );
|
|
665
|
+
|
|
666
|
+
mPacketInIGMP = rb_define_module_under( mTrema, "PacketInIGMP" );
|
|
667
|
+
rb_define_method( mPacketInIGMP, "igmp_type", packet_in_igmp_type, 0 );
|
|
668
|
+
rb_define_method( mPacketInIGMP, "igmp_group", packet_in_igmp_group, 0 );
|
|
669
|
+
rb_define_method( mPacketInIGMP, "igmp_membership_query?", packet_in_is_igmp_membership_query, 0 );
|
|
670
|
+
rb_define_method( mPacketInIGMP, "igmp_v1_membership_report?", packet_in_is_igmp_v1_membership_report, 0 );
|
|
671
|
+
rb_define_method( mPacketInIGMP, "igmp_v2_membership_report?", packet_in_is_igmp_v2_membership_report, 0 );
|
|
672
|
+
rb_define_method( mPacketInIGMP, "igmp_v2_leave_group?", packet_in_is_igmp_v2_leave_group, 0 );
|
|
673
|
+
rb_define_method( mPacketInIGMP, "igmp_v3_membership_report?", packet_in_is_igmp_v3_membership_report, 0 );
|
|
674
|
+
|
|
675
|
+
mPacketInTCP = rb_define_module_under( mTrema, "PacketInTCP" );
|
|
676
|
+
rb_define_method( mPacketInTCP, "tcp_src_port", packet_in_tcp_src_port, 0 );
|
|
677
|
+
rb_define_method( mPacketInTCP, "tcp_dst_port", packet_in_tcp_dst_port, 0 );
|
|
678
|
+
|
|
679
|
+
mPacketInUDP = rb_define_module_under( mTrema, "PacketInUDP" );
|
|
680
|
+
rb_define_method( mPacketInUDP, "udp_payload", packet_in_udp_payload, 0 );
|
|
681
|
+
rb_define_method( mPacketInUDP, "udp_src_port", packet_in_udp_src_port, 0 );
|
|
682
|
+
rb_define_method( mPacketInUDP, "udp_dst_port", packet_in_udp_dst_port, 0 );
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
|
|
686
|
+
/*
|
|
687
|
+
* Handler called when +OFPT_PACKET_IN+ message is received.
|
|
688
|
+
*/
|
|
689
|
+
void
|
|
690
|
+
handle_packet_in( uint64_t datapath_id, packet_in message ) {
|
|
691
|
+
VALUE controller = ( VALUE ) message.user_data;
|
|
692
|
+
if ( rb_respond_to( controller, rb_intern( "packet_in" ) ) == Qfalse ) {
|
|
693
|
+
return;
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
VALUE r_message = rb_funcall( cPacketIn, rb_intern( "new" ), 0 );
|
|
697
|
+
packet_in *tmp = NULL;
|
|
698
|
+
Data_Get_Struct( r_message, packet_in, tmp );
|
|
699
|
+
memcpy( tmp, &message, sizeof( packet_in ) );
|
|
700
|
+
|
|
701
|
+
packet_info* info = ( packet_info * ) tmp->data->user_data;
|
|
702
|
+
|
|
703
|
+
if ( ( info->format & NW_ARP ) ) {
|
|
704
|
+
rb_funcall( cPacketIn, rb_intern( "include" ), 1, mPacketInARP );
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
if ( ( info->format & NW_IPV4 ) ) {
|
|
708
|
+
rb_funcall( cPacketIn, rb_intern( "include" ), 1, mPacketInIPv4 );
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
if ( ( info->format & NW_ICMPV4 ) ) {
|
|
712
|
+
rb_funcall( cPacketIn, rb_intern( "include" ), 1, mPacketInICMPv4 );
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
if ( ( info->format & NW_IGMP ) ) {
|
|
716
|
+
rb_funcall( cPacketIn, rb_intern( "include" ), 1, mPacketInIGMP );
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
if ( ( info->format & TP_TCP ) ) {
|
|
720
|
+
rb_funcall( cPacketIn, rb_intern( "include" ), 1, mPacketInTCP );
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
if ( ( info->format & TP_UDP ) ) {
|
|
724
|
+
rb_funcall( cPacketIn, rb_intern( "include" ), 1, mPacketInUDP );
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
rb_funcall( controller, rb_intern( "packet_in" ), 2, ULL2NUM( datapath_id ), r_message );
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
|
|
731
|
+
/*
|
|
732
|
+
* Local variables:
|
|
733
|
+
* c-basic-offset: 2
|
|
734
|
+
* indent-tabs-mode: nil
|
|
735
|
+
* End:
|
|
736
|
+
*/
|