trema 0.4.7 → 0.4.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +33 -54
- data/.hound.yml +3 -0
- data/.rspec +3 -0
- data/.rubocop.yml +17 -1
- data/.travis.yml +14 -18
- data/CHANGELOG.md +10 -0
- data/Gemfile +1 -26
- data/README.md +25 -241
- data/Rakefile +4 -1056
- data/bin/.gitignore +3 -0
- data/bin/trema +163 -237
- data/features/cleanup_on_failure.feature +118 -0
- data/features/logging.feature +73 -0
- data/features/open_flow13.feature +21 -0
- data/features/step_definitions/.gitignore +35 -0
- data/features/step_definitions/.rubocop.yml +5 -0
- data/features/step_definitions/.travis.yml +19 -0
- data/features/step_definitions/Gemfile +9 -0
- data/features/step_definitions/Guardfile +4 -0
- data/features/step_definitions/LICENSE +675 -0
- data/features/step_definitions/README.md +7 -0
- data/features/step_definitions/Rakefile +10 -0
- data/features/step_definitions/show_stats_steps.rb +56 -0
- data/features/step_definitions/virtual_link_steps.rb +8 -0
- data/features/support/env.rb +0 -73
- data/features/support/hooks.rb +6 -50
- data/features/trema_delete_link.feature +30 -0
- data/features/trema_killall.feature +56 -0
- data/features/trema_run.feature +47 -0
- data/features/trema_start.feature +73 -0
- data/features/trema_stop.feature +50 -0
- data/lib/trema.rb +4 -0
- data/lib/trema/command.rb +184 -0
- data/lib/trema/controller.rb +289 -0
- data/lib/trema/dirs.rb +14 -0
- data/lib/trema/drb.rb +32 -0
- data/lib/trema/logger.rb +63 -0
- data/lib/trema/monkey_patch/integer.rb +8 -0
- data/lib/trema/monkey_patch/integer/base_conversions.rb +12 -0
- data/lib/trema/monkey_patch/integer/durations.rb +12 -0
- data/lib/trema/switch.rb +83 -0
- data/lib/trema/version.rb +5 -0
- data/spec/spec_helper.rb +9 -178
- data/spec/trema/controller_spec.rb +4 -53
- data/tasks/.gitignore +34 -0
- data/tasks/LICENSE +675 -0
- data/tasks/README.md +6 -0
- data/tasks/cucumber.rake +14 -0
- data/tasks/flay.rake +15 -0
- data/tasks/flog.rake +25 -0
- data/tasks/gem.rake +15 -0
- data/tasks/reek.rake +11 -0
- data/tasks/relish.rake +8 -0
- data/tasks/rspec.rake +8 -0
- data/tasks/rubocop.rake +2 -16
- data/tasks/yard.rake +11 -0
- data/trema.gemspec +24 -23
- metadata +180 -720
- data/.yardopts +0 -4
- data/Doxyfile +0 -1679
- data/Guardfile +0 -14
- data/bin/quality +0 -31
- data/bin/trema-config +0 -59
- data/build.rb +0 -32
- data/cruise.rb +0 -409
- data/features/.nav +0 -50
- data/features/README.md +0 -7
- data/features/core/get_pid_by_trema_name.feature +0 -137
- data/features/core/packetin_filter.feature +0 -55
- data/features/core/switch_manager.feature +0 -41
- data/features/core/trema-config.feature +0 -55
- data/features/dsl/switch_port_specifier.feature +0 -15
- data/features/examples/dumper.feature +0 -35
- data/features/examples/hello_trema.feature +0 -23
- data/features/examples/learning_switch.feature +0 -37
- data/features/examples/list_switches.feature +0 -24
- data/features/examples/message.set_config.feature +0 -27
- data/features/examples/message.vendor-action.feature +0 -25
- data/features/examples/message.vendor-stats-request.feature +0 -20
- data/features/examples/multi_learning_switch.feature +0 -107
- data/features/examples/openflow_message.echo.feature +0 -59
- data/features/examples/openflow_message.features_request.feature +0 -35
- data/features/examples/openflow_message.hello.feature +0 -59
- data/features/examples/packet_in.feature +0 -33
- data/features/examples/packetin_filter_config.feature +0 -95
- data/features/examples/patch_panel.feature +0 -29
- data/features/examples/repeater_hub.feature +0 -52
- data/features/examples/switch_info.feature +0 -51
- data/features/examples/switch_monitor.feature +0 -35
- data/features/examples/transparent_firewall.feature +0 -73
- data/features/handlers/switch_ready.feature +0 -40
- data/features/step_definitions/misc_steps.rb +0 -85
- data/features/step_definitions/send_packets_steps.rb +0 -33
- data/features/step_definitions/stats_steps.rb +0 -39
- data/features/switch_event/C-add_forward_entry.feature +0 -114
- data/features/switch_event/C-delete_forward_entry.feature +0 -85
- data/features/switch_event/C-dump_forward_entries.feature +0 -72
- data/features/switch_event/C-set_forward_entries.feature +0 -77
- data/features/switch_event/README.md +0 -40
- data/features/switch_event/add_forward_entry.feature +0 -160
- data/features/switch_event/delete_forward_entry.feature +0 -160
- data/features/switch_event/dump_forward_entries.feature +0 -103
- data/features/switch_event/set_forward_entries.feature +0 -102
- data/features/trema_commands/README.md +0 -8
- data/features/trema_commands/dump_flows.feature +0 -41
- data/features/trema_commands/help.feature +0 -27
- data/features/trema_commands/help_option.feature +0 -20
- data/features/trema_commands/kill.feature +0 -56
- data/features/trema_commands/killall.feature +0 -32
- data/features/trema_commands/port_down.feature +0 -71
- data/features/trema_commands/port_up.feature +0 -75
- data/features/trema_commands/reset_stats.feature +0 -56
- data/features/trema_commands/run.feature +0 -56
- data/features/trema_commands/send_packets.feature +0 -46
- data/features/trema_commands/show_stats.feature +0 -66
- data/features/trema_commands/up.feature +0 -34
- data/features/trema_commands/version.feature +0 -10
- data/features/trema_commands/version_option.feature +0 -8
- data/rubocop-todo.yml +0 -159
- data/ruby/.gitignore +0 -4
- data/ruby/blocker.rb +0 -74
- data/ruby/extconf.rb +0 -80
- data/ruby/sub-process.rb +0 -289
- data/ruby/trema/action-common.c +0 -46
- data/ruby/trema/action-common.h +0 -38
- data/ruby/trema/action.rb +0 -33
- data/ruby/trema/aggregate-stats-reply.rb +0 -68
- data/ruby/trema/app.rb +0 -114
- data/ruby/trema/barrier-reply.c +0 -98
- data/ruby/trema/barrier-reply.h +0 -44
- data/ruby/trema/barrier-request.c +0 -135
- data/ruby/trema/barrier-request.h +0 -42
- data/ruby/trema/cli.rb +0 -267
- data/ruby/trema/command.rb +0 -41
- data/ruby/trema/command/dump_flows.rb +0 -43
- data/ruby/trema/command/kill.rb +0 -75
- data/ruby/trema/command/killall.rb +0 -38
- data/ruby/trema/command/netns.rb +0 -38
- data/ruby/trema/command/port_down.rb +0 -43
- data/ruby/trema/command/port_up.rb +0 -43
- data/ruby/trema/command/reset_stats.rb +0 -41
- data/ruby/trema/command/ruby.rb +0 -38
- data/ruby/trema/command/run.rb +0 -110
- data/ruby/trema/command/send_packets.rb +0 -46
- data/ruby/trema/command/shell.rb +0 -57
- data/ruby/trema/command/show_stats.rb +0 -65
- data/ruby/trema/command/up.rb +0 -44
- data/ruby/trema/command/version.rb +0 -35
- data/ruby/trema/compat.h +0 -36
- data/ruby/trema/controller.c +0 -691
- data/ruby/trema/controller.h +0 -42
- data/ruby/trema/controller.rb +0 -255
- data/ruby/trema/custom-switch.rb +0 -56
- data/ruby/trema/daemon.rb +0 -184
- data/ruby/trema/default-logger.c +0 -161
- data/ruby/trema/default-logger.h +0 -42
- data/ruby/trema/default-logger.rb +0 -29
- data/ruby/trema/default_openflow_channel_port.rb +0 -26
- data/ruby/trema/desc-stats-reply.rb +0 -75
- data/ruby/trema/dsl.rb +0 -32
- data/ruby/trema/dsl/configuration.rb +0 -145
- data/ruby/trema/dsl/context.rb +0 -69
- data/ruby/trema/dsl/custom-switch.rb +0 -44
- data/ruby/trema/dsl/link.rb +0 -39
- data/ruby/trema/dsl/netns.rb +0 -78
- data/ruby/trema/dsl/parser.rb +0 -70
- data/ruby/trema/dsl/rswitch.rb +0 -47
- data/ruby/trema/dsl/run.rb +0 -47
- data/ruby/trema/dsl/runner.rb +0 -178
- data/ruby/trema/dsl/stanza.rb +0 -51
- data/ruby/trema/dsl/switch.rb +0 -76
- data/ruby/trema/dsl/syntax-error.rb +0 -31
- data/ruby/trema/dsl/syntax.rb +0 -128
- data/ruby/trema/dsl/vhost.rb +0 -106
- data/ruby/trema/dsl/vswitch.rb +0 -45
- data/ruby/trema/echo-reply.c +0 -122
- data/ruby/trema/echo-reply.h +0 -40
- data/ruby/trema/echo-request.c +0 -117
- data/ruby/trema/echo-request.h +0 -40
- data/ruby/trema/echo.c +0 -99
- data/ruby/trema/echo.h +0 -39
- data/ruby/trema/enqueue.rb +0 -87
- data/ruby/trema/error.c +0 -262
- data/ruby/trema/error.h +0 -42
- data/ruby/trema/exact-match.rb +0 -34
- data/ruby/trema/executables.rb +0 -99
- data/ruby/trema/features-reply.c +0 -330
- data/ruby/trema/features-reply.h +0 -54
- data/ruby/trema/features-request.c +0 -134
- data/ruby/trema/features-request.h +0 -42
- data/ruby/trema/flow-mod.c +0 -150
- data/ruby/trema/flow-mod.h +0 -42
- data/ruby/trema/flow-removed.c +0 -280
- data/ruby/trema/flow-removed.h +0 -44
- data/ruby/trema/flow-stats-reply.rb +0 -107
- data/ruby/trema/flow.rb +0 -65
- data/ruby/trema/get-config-reply.c +0 -158
- data/ruby/trema/get-config-reply.h +0 -50
- data/ruby/trema/get-config-request.c +0 -136
- data/ruby/trema/get-config-request.h +0 -42
- data/ruby/trema/hardware-switch.rb +0 -86
- data/ruby/trema/hello.c +0 -133
- data/ruby/trema/hello.h +0 -42
- data/ruby/trema/host.rb +0 -263
- data/ruby/trema/link.rb +0 -177
- data/ruby/trema/list-switches-reply.c +0 -44
- data/ruby/trema/list-switches-reply.h +0 -38
- data/ruby/trema/mac.rb +0 -29
- data/ruby/trema/match.c +0 -621
- data/ruby/trema/match.h +0 -34
- data/ruby/trema/monkey-patch/integer.rb +0 -35
- data/ruby/trema/monkey-patch/integer/base-conversions.rb +0 -34
- data/ruby/trema/monkey-patch/integer/ranges.rb +0 -49
- data/ruby/trema/monkey-patch/integer/validators.rb +0 -36
- data/ruby/trema/monkey-patch/module.rb +0 -33
- data/ruby/trema/monkey-patch/module/class-method.rb +0 -38
- data/ruby/trema/monkey-patch/module/deprecation.rb +0 -39
- data/ruby/trema/monkey-patch/string.rb +0 -31
- data/ruby/trema/monkey-patch/string/inflectors.rb +0 -52
- data/ruby/trema/netns.rb +0 -127
- data/ruby/trema/network-component.rb +0 -151
- data/ruby/trema/ofctl.rb +0 -70
- data/ruby/trema/open-vswitch.rb +0 -160
- data/ruby/trema/openflow-error.c +0 -193
- data/ruby/trema/openflow-error.h +0 -51
- data/ruby/trema/openflow-switch.rb +0 -35
- data/ruby/trema/ordered-hash.rb +0 -75
- data/ruby/trema/packet-in.c +0 -1365
- data/ruby/trema/packet-in.h +0 -44
- data/ruby/trema/packet-queue.rb +0 -181
- data/ruby/trema/packetin-filter.rb +0 -124
- data/ruby/trema/path.rb +0 -85
- data/ruby/trema/phost.rb +0 -76
- data/ruby/trema/port-mod.c +0 -232
- data/ruby/trema/port-mod.h +0 -34
- data/ruby/trema/port-stats-reply.rb +0 -109
- data/ruby/trema/port-status-add.rb +0 -60
- data/ruby/trema/port-status-delete.rb +0 -60
- data/ruby/trema/port-status-modify.rb +0 -60
- data/ruby/trema/port-status.c +0 -192
- data/ruby/trema/port-status.h +0 -41
- data/ruby/trema/port.c +0 -398
- data/ruby/trema/port.h +0 -45
- data/ruby/trema/process.rb +0 -103
- data/ruby/trema/queue-get-config-reply.c +0 -205
- data/ruby/trema/queue-get-config-reply.h +0 -45
- data/ruby/trema/queue-get-config-request.c +0 -141
- data/ruby/trema/queue-get-config-request.h +0 -42
- data/ruby/trema/queue-stats-reply.rb +0 -76
- data/ruby/trema/ruby-switch.rb +0 -62
- data/ruby/trema/send-out-port.rb +0 -113
- data/ruby/trema/set-config.c +0 -174
- data/ruby/trema/set-config.h +0 -42
- data/ruby/trema/set-eth-addr.rb +0 -54
- data/ruby/trema/set-eth-dst-addr.rb +0 -52
- data/ruby/trema/set-eth-src-addr.rb +0 -53
- data/ruby/trema/set-ip-addr.rb +0 -54
- data/ruby/trema/set-ip-dst-addr.rb +0 -53
- data/ruby/trema/set-ip-src-addr.rb +0 -52
- data/ruby/trema/set-ip-tos.rb +0 -64
- data/ruby/trema/set-transport-dst-port.rb +0 -53
- data/ruby/trema/set-transport-port.rb +0 -53
- data/ruby/trema/set-transport-src-port.rb +0 -54
- data/ruby/trema/set-vlan-priority.rb +0 -66
- data/ruby/trema/set-vlan-vid.rb +0 -65
- data/ruby/trema/shell.rb +0 -37
- data/ruby/trema/shell/down.rb +0 -37
- data/ruby/trema/shell/killall.rb +0 -38
- data/ruby/trema/shell/link.rb +0 -59
- data/ruby/trema/shell/reset_stats.rb +0 -49
- data/ruby/trema/shell/run.rb +0 -67
- data/ruby/trema/shell/send_packets.rb +0 -40
- data/ruby/trema/shell/show_stats.rb +0 -47
- data/ruby/trema/shell/up.rb +0 -41
- data/ruby/trema/shell/vhost.rb +0 -42
- data/ruby/trema/shell/vswitch.rb +0 -47
- data/ruby/trema/stats-helper.rb +0 -63
- data/ruby/trema/stats-reply.c +0 -540
- data/ruby/trema/stats-reply.h +0 -51
- data/ruby/trema/stats-request.c +0 -715
- data/ruby/trema/stats-request.h +0 -40
- data/ruby/trema/strip-vlan-header.rb +0 -41
- data/ruby/trema/switch-daemon.rb +0 -90
- data/ruby/trema/switch-disconnected.c +0 -38
- data/ruby/trema/switch-disconnected.h +0 -36
- data/ruby/trema/switch-event.c +0 -648
- data/ruby/trema/switch-event.h +0 -27
- data/ruby/trema/switch-manager.rb +0 -119
- data/ruby/trema/switch.c +0 -197
- data/ruby/trema/switch.h +0 -40
- data/ruby/trema/switch.rb +0 -56
- data/ruby/trema/table-stats-reply.rb +0 -85
- data/ruby/trema/timers.rb +0 -95
- data/ruby/trema/trema-ruby-utils.c +0 -66
- data/ruby/trema/trema-ruby-utils.h +0 -42
- data/ruby/trema/trema.c +0 -126
- data/ruby/trema/tremashark.rb +0 -46
- data/ruby/trema/util.rb +0 -116
- data/ruby/trema/vendor-action.rb +0 -82
- data/ruby/trema/vendor-stats-reply.rb +0 -64
- data/ruby/trema/vendor.c +0 -230
- data/ruby/trema/vendor.h +0 -48
- data/ruby/trema/version.rb +0 -28
- data/spec/support/action.rb +0 -49
- data/spec/support/mandatory-option.rb +0 -53
- data/spec/support/matchers/constant.rb +0 -25
- data/spec/support/openflow-message.rb +0 -173
- data/spec/support/port-status.rb +0 -35
- data/spec/trema/app_spec.rb +0 -88
- data/spec/trema/barrier-reply_spec.rb +0 -43
- data/spec/trema/barrier-request_spec.rb +0 -92
- data/spec/trema/cli_spec.rb +0 -156
- data/spec/trema/default-logger_spec.rb +0 -46
- data/spec/trema/dsl/configuration_spec.rb +0 -120
- data/spec/trema/dsl/link_spec.rb +0 -50
- data/spec/trema/dsl/run_spec.rb +0 -72
- data/spec/trema/dsl/runner_spec.rb +0 -247
- data/spec/trema/dsl/switch_spec.rb +0 -69
- data/spec/trema/dsl/syntax_spec.rb +0 -110
- data/spec/trema/dsl/vhost_spec.rb +0 -144
- data/spec/trema/dsl/vswitch_spec.rb +0 -80
- data/spec/trema/echo-reply_spec.rb +0 -84
- data/spec/trema/echo-request_spec.rb +0 -128
- data/spec/trema/enqueue_spec.rb +0 -76
- data/spec/trema/error_spec.rb +0 -81
- data/spec/trema/executables_spec.rb +0 -54
- data/spec/trema/features-reply_spec.rb +0 -91
- data/spec/trema/features-request_spec.rb +0 -93
- data/spec/trema/flow-mod_spec.rb +0 -99
- data/spec/trema/flow-removed_spec.rb +0 -144
- data/spec/trema/get-config-reply_spec.rb +0 -43
- data/spec/trema/get-config-request_spec.rb +0 -92
- data/spec/trema/hardware-switch_spec.rb +0 -54
- data/spec/trema/hello_spec.rb +0 -63
- data/spec/trema/host_spec.rb +0 -191
- data/spec/trema/link_spec.rb +0 -62
- data/spec/trema/list-switches-reply_spec.rb +0 -46
- data/spec/trema/match_spec.rb +0 -111
- data/spec/trema/open-vswitch_spec.rb +0 -121
- data/spec/trema/openflow-error_spec.rb +0 -141
- data/spec/trema/packet-in_spec.rb +0 -717
- data/spec/trema/packet-out_spec.rb +0 -125
- data/spec/trema/packetin-filter_spec.rb +0 -39
- data/spec/trema/port-mod_spec.rb +0 -98
- data/spec/trema/port-status-add_spec.rb +0 -32
- data/spec/trema/port-status-delete_spec.rb +0 -32
- data/spec/trema/port-status-modify_spec.rb +0 -71
- data/spec/trema/port-status_spec.rb +0 -38
- data/spec/trema/port_spec.rb +0 -59
- data/spec/trema/process_spec.rb +0 -69
- data/spec/trema/queue-get-config-reply_spec.rb +0 -65
- data/spec/trema/queue-get-config-request_spec.rb +0 -67
- data/spec/trema/send-out-port_spec.rb +0 -106
- data/spec/trema/set-config_spec.rb +0 -78
- data/spec/trema/set-eth-addr_spec.rb +0 -62
- data/spec/trema/set-ip-addr_spec.rb +0 -81
- data/spec/trema/set-ip-tos_spec.rb +0 -70
- data/spec/trema/set-transport-dst-port_spec.rb +0 -65
- data/spec/trema/set-transport-src-port_spec.rb +0 -65
- data/spec/trema/set-vlan-priority_spec.rb +0 -65
- data/spec/trema/set-vlan-vid_spec.rb +0 -65
- data/spec/trema/shell/vhost_spec.rb +0 -58
- data/spec/trema/shell/vswitch_spec.rb +0 -87
- data/spec/trema/stats-reply_spec.rb +0 -363
- data/spec/trema/stats-request_spec.rb +0 -166
- data/spec/trema/strip-vlan-header_spec.rb +0 -44
- data/spec/trema/switch-daemon_spec.rb +0 -81
- data/spec/trema/switch-disconnected_spec.rb +0 -56
- data/spec/trema/switch-manager_spec.rb +0 -41
- data/spec/trema/tremashark_spec.rb +0 -39
- data/spec/trema/util_spec.rb +0 -88
- data/spec/trema/vendor-action_spec.rb +0 -75
- data/spec/trema/vendor_spec.rb +0 -76
- data/spec/trema_spec.rb +0 -94
- data/src/examples/cbench_switch/README +0 -21
- data/src/examples/cbench_switch/cbench-switch.rb +0 -38
- data/src/examples/cbench_switch/cbench_switch.c +0 -66
- data/src/examples/dumper/dumper.c +0 -362
- data/src/examples/dumper/dumper.conf +0 -7
- data/src/examples/dumper/dumper.rb +0 -195
- data/src/examples/hello_trema/.gitignore +0 -2
- data/src/examples/hello_trema/README.md +0 -2
- data/src/examples/hello_trema/hello-trema.rb +0 -30
- data/src/examples/hello_trema/hello_trema.c +0 -48
- data/src/examples/hello_trema/sample.conf +0 -1
- data/src/examples/learning_switch/README +0 -15
- data/src/examples/learning_switch/fdb.rb +0 -110
- data/src/examples/learning_switch/learning-switch.rb +0 -90
- data/src/examples/learning_switch/learning_switch.c +0 -217
- data/src/examples/learning_switch/learning_switch.conf +0 -18
- data/src/examples/list_switches/README +0 -19
- data/src/examples/list_switches/list-switches.rb +0 -43
- data/src/examples/list_switches/list_switches.c +0 -79
- data/src/examples/list_switches/list_switches.conf +0 -15
- data/src/examples/match_compare/match-compare.conf +0 -30
- data/src/examples/match_compare/match-compare.rb +0 -97
- data/src/examples/multi_learning_switch/README +0 -14
- data/src/examples/multi_learning_switch/multi-learning-switch.rb +0 -94
- data/src/examples/multi_learning_switch/multi_learning_switch.c +0 -294
- data/src/examples/multi_learning_switch/multi_learning_switch.conf +0 -17
- data/src/examples/openflow_message/README +0 -11
- data/src/examples/openflow_message/echo.c +0 -80
- data/src/examples/openflow_message/echo.rb +0 -56
- data/src/examples/openflow_message/example.rb +0 -60
- data/src/examples/openflow_message/features-request.rb +0 -96
- data/src/examples/openflow_message/features_request.c +0 -167
- data/src/examples/openflow_message/hello.c +0 -68
- data/src/examples/openflow_message/hello.rb +0 -43
- data/src/examples/openflow_message/set-config.rb +0 -57
- data/src/examples/openflow_message/set_config.c +0 -68
- data/src/examples/openflow_message/vendor-action.rb +0 -43
- data/src/examples/openflow_message/vendor-stats-request.rb +0 -66
- data/src/examples/openflow_message/vendor_action.c +0 -103
- data/src/examples/openflow_switch/echo_switch.c +0 -89
- data/src/examples/openflow_switch/hello_switch.c +0 -85
- data/src/examples/packet_in/README +0 -15
- data/src/examples/packet_in/packet-in.rb +0 -37
- data/src/examples/packet_in/packet_in.c +0 -53
- data/src/examples/packet_in/packet_in.conf +0 -15
- data/src/examples/packetin_filter_config/README +0 -12
- data/src/examples/packetin_filter_config/add_filter.c +0 -71
- data/src/examples/packetin_filter_config/delete_filter.c +0 -63
- data/src/examples/packetin_filter_config/delete_filter_strict.c +0 -73
- data/src/examples/packetin_filter_config/dump_filter.c +0 -63
- data/src/examples/packetin_filter_config/dump_filter_strict.c +0 -73
- data/src/examples/packetin_filter_config/packetin_filter_config.c +0 -132
- data/src/examples/packetin_filter_config/packetin_filter_config.conf +0 -7
- data/src/examples/packetin_filter_config/utils.c +0 -100
- data/src/examples/packetin_filter_config/utils.h +0 -40
- data/src/examples/patch_panel/network.conf +0 -14
- data/src/examples/patch_panel/patch-panel.conf +0 -1
- data/src/examples/patch_panel/patch-panel.rb +0 -59
- data/src/examples/repeater_hub/README +0 -8
- data/src/examples/repeater_hub/repeater-hub.rb +0 -41
- data/src/examples/repeater_hub/repeater-hub_spec.rb +0 -154
- data/src/examples/repeater_hub/repeater_hub.c +0 -81
- data/src/examples/repeater_hub/repeater_hub.conf +0 -28
- data/src/examples/simple_router/README +0 -18
- data/src/examples/simple_router/arp-table.rb +0 -81
- data/src/examples/simple_router/interface.rb +0 -90
- data/src/examples/simple_router/routing-table.rb +0 -60
- data/src/examples/simple_router/simple-router.rb +0 -191
- data/src/examples/simple_router/simple_router.conf +0 -24
- data/src/examples/simple_router/simple_router_netns.conf +0 -15
- data/src/examples/simple_router/simple_router_network.conf +0 -6
- data/src/examples/switch_event_config/.gitignore +0 -6
- data/src/examples/switch_event_config/add_forward_entry.c +0 -227
- data/src/examples/switch_event_config/delete_forward_entry.c +0 -226
- data/src/examples/switch_event_config/dump_forward_entries.c +0 -190
- data/src/examples/switch_event_config/network.conf +0 -2
- data/src/examples/switch_event_config/set_forward_entries.c +0 -210
- data/src/examples/switch_info/README +0 -13
- data/src/examples/switch_info/switch-info.rb +0 -44
- data/src/examples/switch_info/switch_info.c +0 -78
- data/src/examples/switch_info/switch_info.conf +0 -3
- data/src/examples/switch_monitor/switch-monitor.conf +0 -3
- data/src/examples/switch_monitor/switch-monitor.rb +0 -56
- data/src/examples/switch_monitor/switch_monitor.c +0 -152
- data/src/examples/traffic_monitor/counter.c +0 -72
- data/src/examples/traffic_monitor/counter.h +0 -46
- data/src/examples/traffic_monitor/counter.rb +0 -44
- data/src/examples/traffic_monitor/fdb.c +0 -74
- data/src/examples/traffic_monitor/fdb.h +0 -48
- data/src/examples/traffic_monitor/fdb.rb +0 -42
- data/src/examples/traffic_monitor/traffic-monitor.rb +0 -98
- data/src/examples/traffic_monitor/traffic_monitor.c +0 -161
- data/src/examples/traffic_monitor/traffic_monitor.conf +0 -16
- data/src/examples/transparent_firewall/README.md +0 -61
- data/src/examples/transparent_firewall/aggregated-delegated-afrinic.txt +0 -713
- data/src/examples/transparent_firewall/aggregated-delegated-apnic.txt +0 -3440
- data/src/examples/transparent_firewall/aggregated-delegated-arin.txt +0 -11342
- data/src/examples/transparent_firewall/aggregated-delegated-lacnic.txt +0 -1937
- data/src/examples/transparent_firewall/aggregated-delegated-ripencc.txt +0 -7329
- data/src/examples/transparent_firewall/block-rfc1918.rb +0 -86
- data/src/examples/transparent_firewall/pass-delegated.rb +0 -178
- data/src/examples/transparent_firewall/regen_aggregated.sh +0 -53
- data/src/examples/transparent_firewall/stats-to-cidrs.rb +0 -59
- data/src/lib/arp.h +0 -64
- data/src/lib/bool.h +0 -47
- data/src/lib/buffer.c +0 -304
- data/src/lib/buffer.h +0 -54
- data/src/lib/byteorder.c +0 -571
- data/src/lib/byteorder.h +0 -108
- data/src/lib/checks.h +0 -40
- data/src/lib/chibach.c +0 -392
- data/src/lib/chibach.h +0 -69
- data/src/lib/chibach_private.c +0 -168
- data/src/lib/chibach_private.h +0 -50
- data/src/lib/daemon.c +0 -429
- data/src/lib/daemon.h +0 -40
- data/src/lib/doubly_linked_list.c +0 -284
- data/src/lib/doubly_linked_list.h +0 -86
- data/src/lib/ether.c +0 -47
- data/src/lib/ether.h +0 -92
- data/src/lib/etherip.h +0 -44
- data/src/lib/event_forward_interface.c +0 -788
- data/src/lib/event_forward_interface.h +0 -138
- data/src/lib/event_handler.c +0 -419
- data/src/lib/event_handler.h +0 -57
- data/src/lib/external_callback.c +0 -126
- data/src/lib/external_callback.h +0 -46
- data/src/lib/hash_table.c +0 -415
- data/src/lib/hash_table.h +0 -136
- data/src/lib/icmp.h +0 -72
- data/src/lib/igmp.h +0 -48
- data/src/lib/ipv4.h +0 -64
- data/src/lib/ipv6.h +0 -46
- data/src/lib/linked_list.c +0 -244
- data/src/lib/linked_list.h +0 -84
- data/src/lib/log.c +0 -636
- data/src/lib/log.h +0 -77
- data/src/lib/management_interface.c +0 -359
- data/src/lib/management_interface.h +0 -40
- data/src/lib/management_service_interface.c +0 -102
- data/src/lib/management_service_interface.h +0 -134
- data/src/lib/match.h +0 -82
- data/src/lib/match_table.c +0 -606
- data/src/lib/match_table.h +0 -49
- data/src/lib/message_queue.c +0 -143
- data/src/lib/message_queue.h +0 -59
- data/src/lib/messenger.c +0 -1821
- data/src/lib/messenger.h +0 -145
- data/src/lib/openflow_application_interface.c +0 -1800
- data/src/lib/openflow_application_interface.h +0 -359
- data/src/lib/openflow_message.c +0 -4240
- data/src/lib/openflow_message.h +0 -291
- data/src/lib/openflow_service_interface.h +0 -58
- data/src/lib/openflow_switch_interface.c +0 -1378
- data/src/lib/openflow_switch_interface.h +0 -262
- data/src/lib/packet_info.c +0 -336
- data/src/lib/packet_info.h +0 -233
- data/src/lib/packet_parser.c +0 -522
- data/src/lib/packetin_filter_interface.c +0 -292
- data/src/lib/packetin_filter_interface.h +0 -125
- data/src/lib/persistent_storage.c +0 -478
- data/src/lib/persistent_storage.h +0 -44
- data/src/lib/secure_channel.c +0 -496
- data/src/lib/secure_channel.h +0 -43
- data/src/lib/stat.c +0 -248
- data/src/lib/stat.h +0 -51
- data/src/lib/tcp.h +0 -62
- data/src/lib/timer.c +0 -349
- data/src/lib/timer.h +0 -51
- data/src/lib/trema.c +0 -776
- data/src/lib/trema.h +0 -80
- data/src/lib/trema.hpp +0 -49
- data/src/lib/trema_private.c +0 -175
- data/src/lib/trema_private.h +0 -64
- data/src/lib/trema_wrapper.c +0 -59
- data/src/lib/trema_wrapper.h +0 -66
- data/src/lib/udp.h +0 -41
- data/src/lib/utility.c +0 -625
- data/src/lib/utility.h +0 -84
- data/src/lib/wrapper.c +0 -121
- data/src/lib/wrapper.h +0 -76
- data/src/management/application.c +0 -222
- data/src/management/echo.c +0 -183
- data/src/management/set_logging_level.c +0 -151
- data/src/management/show_stats.c +0 -148
- data/src/management/trema_manager +0 -184
- data/src/packetin_filter/README +0 -17
- data/src/packetin_filter/packetin_filter.c +0 -575
- data/src/switch_manager/README +0 -20
- data/src/switch_manager/cookie_table.c +0 -290
- data/src/switch_manager/cookie_table.h +0 -70
- data/src/switch_manager/dpid_table.c +0 -108
- data/src/switch_manager/dpid_table.h +0 -43
- data/src/switch_manager/event_forward_entry_manipulation.c +0 -120
- data/src/switch_manager/event_forward_entry_manipulation.h +0 -31
- data/src/switch_manager/ofpmsg_recv.c +0 -497
- data/src/switch_manager/ofpmsg_recv.h +0 -39
- data/src/switch_manager/ofpmsg_send.c +0 -274
- data/src/switch_manager/ofpmsg_send.h +0 -51
- data/src/switch_manager/secure_channel_listener.c +0 -296
- data/src/switch_manager/secure_channel_listener.h +0 -40
- data/src/switch_manager/secure_channel_receiver.c +0 -129
- data/src/switch_manager/secure_channel_receiver.h +0 -40
- data/src/switch_manager/secure_channel_sender.c +0 -131
- data/src/switch_manager/secure_channel_sender.h +0 -41
- data/src/switch_manager/service_interface.c +0 -180
- data/src/switch_manager/service_interface.h +0 -44
- data/src/switch_manager/switch.c +0 -988
- data/src/switch_manager/switch.h +0 -50
- data/src/switch_manager/switch_manager.c +0 -643
- data/src/switch_manager/switch_manager.h +0 -65
- data/src/switch_manager/switch_option.c +0 -30
- data/src/switch_manager/switch_option.h +0 -41
- data/src/switch_manager/switchinfo.h +0 -81
- data/src/switch_manager/xid_table.c +0 -182
- data/src/switch_manager/xid_table.h +0 -53
- data/src/tremashark/README +0 -79
- data/src/tremashark/packet_capture.c +0 -358
- data/src/tremashark/pcap_private.h +0 -45
- data/src/tremashark/pcap_queue.c +0 -195
- data/src/tremashark/pcap_queue.h +0 -56
- data/src/tremashark/plugin/.gitignore +0 -6
- data/src/tremashark/plugin/packet-trema/.gitignore +0 -5
- data/src/tremashark/plugin/packet-trema/Makefile +0 -77
- data/src/tremashark/plugin/packet-trema/Makefile.am +0 -110
- data/src/tremashark/plugin/packet-trema/Makefile.common +0 -29
- data/src/tremashark/plugin/packet-trema/moduleinfo.h +0 -39
- data/src/tremashark/plugin/packet-trema/packet-trema.c +0 -1671
- data/src/tremashark/plugin/packet-trema/plugin.c +0 -31
- data/src/tremashark/plugin/user_dlts +0 -2
- data/src/tremashark/queue.c +0 -167
- data/src/tremashark/queue.h +0 -58
- data/src/tremashark/stdin_relay.c +0 -257
- data/src/tremashark/syslog_relay.c +0 -247
- data/src/tremashark/tremashark.c +0 -554
- data/trema +0 -11
- data/trema-config +0 -11
- data/unittests/buffer_stubs.c +0 -72
- data/unittests/cmockery_trema.c +0 -121
- data/unittests/cmockery_trema.h +0 -95
- data/unittests/lib/buffer_test.c +0 -368
- data/unittests/lib/byteorder_test.c +0 -1798
- data/unittests/lib/daemon_test.c +0 -804
- data/unittests/lib/doubly_linked_list_test.c +0 -348
- data/unittests/lib/ether_test.c +0 -125
- data/unittests/lib/event_forward_interface_test.c +0 -1676
- data/unittests/lib/external_callback_test.c +0 -282
- data/unittests/lib/hash_table_test.c +0 -278
- data/unittests/lib/linked_list_test.c +0 -434
- data/unittests/lib/log_test.c +0 -672
- data/unittests/lib/management_interface_test.c +0 -238
- data/unittests/lib/management_service_interface_test.c +0 -317
- data/unittests/lib/match_table_test.c +0 -1507
- data/unittests/lib/message_queue_test.c +0 -381
- data/unittests/lib/messenger_test.c +0 -623
- data/unittests/lib/openflow_application_interface_test.c +0 -3713
- data/unittests/lib/openflow_message_test.c +0 -8047
- data/unittests/lib/packet_info_test.c +0 -558
- data/unittests/lib/packet_parser_test.c +0 -784
- data/unittests/lib/packetin_filter_interface_test.c +0 -721
- data/unittests/lib/persistent_storage_test.c +0 -800
- data/unittests/lib/stat_test.c +0 -433
- 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/icmp6_echo_rep.cap +0 -0
- data/unittests/lib/test_packets/icmp6_echo_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/rarp_req.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 +0 -246
- data/unittests/lib/trema_private_test.c +0 -321
- data/unittests/lib/trema_test.c +0 -1030
- data/unittests/lib/utility_test.c +0 -711
- data/unittests/lib/wrapper_test.c +0 -228
- data/unittests/packetin_filter/packetin_filter_test.c +0 -476
- data/unittests/switch_manager/switch_manager_test.c +0 -1183
- data/unittests/wrapper_stubs.c +0 -37
- data/vendor/.gitignore +0 -6
- data/vendor/README.md +0 -29
- data/vendor/cmockery-20110428.tar.gz +0 -0
- data/vendor/oflops-0.03.trema1.tar.gz +0 -0
- data/vendor/oflops_no_snmp+1.0.0.diff +0 -340
- data/vendor/openflow-1.0.0.tar.gz +0 -0
- data/vendor/openflow.git.tar.gz +0 -0
- data/vendor/openvswitch-1.2.2.trema1.tar.gz +0 -0
- data/vendor/openvswitch-1.2.2_librt-check.diff +0 -21
- data/vendor/packet-openflow.diff +0 -13
- data/vendor/ruby-ifconfig-1.2/COPYING +0 -340
- data/vendor/ruby-ifconfig-1.2/Changelog +0 -16
- data/vendor/ruby-ifconfig-1.2/INSTALL +0 -239
- data/vendor/ruby-ifconfig-1.2/README +0 -38
- data/vendor/ruby-ifconfig-1.2/Rakefile +0 -14
- data/vendor/ruby-ifconfig-1.2/TODO +0 -8
- data/vendor/ruby-ifconfig-1.2/ifconfig_examples/darwin.txt +0 -17
- data/vendor/ruby-ifconfig-1.2/ifconfig_examples/dragonflybsd.txt +0 -10
- data/vendor/ruby-ifconfig-1.2/ifconfig_examples/dragonflybsd_netstat.txt +0 -14
- data/vendor/ruby-ifconfig-1.2/ifconfig_examples/freebsd.txt +0 -17
- data/vendor/ruby-ifconfig-1.2/ifconfig_examples/freebsd_netstat.txt +0 -24
- data/vendor/ruby-ifconfig-1.2/ifconfig_examples/linux.txt +0 -60
- data/vendor/ruby-ifconfig-1.2/ifconfig_examples/linux_ethernet.txt +0 -20
- data/vendor/ruby-ifconfig-1.2/ifconfig_examples/netbsd.txt +0 -10
- data/vendor/ruby-ifconfig-1.2/ifconfig_examples/openbsd.txt +0 -36
- data/vendor/ruby-ifconfig-1.2/ifconfig_examples/sunos.txt +0 -10
- data/vendor/ruby-ifconfig-1.2/lib/ifconfig.rb +0 -71
- data/vendor/ruby-ifconfig-1.2/lib/ifconfig/bsd/ifconfig.rb +0 -72
- data/vendor/ruby-ifconfig-1.2/lib/ifconfig/bsd/interface_types.rb +0 -69
- data/vendor/ruby-ifconfig-1.2/lib/ifconfig/bsd/network_types.rb +0 -3
- data/vendor/ruby-ifconfig-1.2/lib/ifconfig/common/ifconfig.rb +0 -84
- data/vendor/ruby-ifconfig-1.2/lib/ifconfig/common/interface_types.rb +0 -130
- data/vendor/ruby-ifconfig-1.2/lib/ifconfig/common/network_types.rb +0 -49
- data/vendor/ruby-ifconfig-1.2/lib/ifconfig/linux/ifconfig.rb +0 -43
- data/vendor/ruby-ifconfig-1.2/lib/ifconfig/linux/interface_types.rb +0 -112
- data/vendor/ruby-ifconfig-1.2/lib/ifconfig/linux/network_types.rb +0 -55
- data/vendor/ruby-ifconfig-1.2/lib/ifconfig/sunos/ifconfig.rb +0 -38
- data/vendor/ruby-ifconfig-1.2/lib/ifconfig/sunos/interface_types.rb +0 -77
- data/vendor/ruby-ifconfig-1.2/lib/ifconfig/sunos/network_types.rb +0 -4
- data/vendor/ruby-ifconfig-1.2/setup.rb +0 -1306
- data/vendor/ruby-ifconfig-1.2/test/test_bsd.rb +0 -35
- data/vendor/ruby-ifconfig-1.2/test/test_darwin.rb +0 -33
- data/vendor/ruby-ifconfig-1.2/test/test_dragonflybsd.rb +0 -35
- data/vendor/ruby-ifconfig-1.2/test/test_helper.rb +0 -4
- data/vendor/ruby-ifconfig-1.2/test/test_linux.rb +0 -31
- data/vendor/ruby-ifconfig-1.2/test/test_netbsd.rb +0 -33
- data/vendor/ruby-ifconfig-1.2/test/test_openbsd.rb +0 -33
- data/vendor/ruby-ifconfig-1.2/test/test_sunos.rb +0 -35
- data/vendor/ruby-ifconfig-1.2/test/unit/tc_darwin.rb +0 -40
- data/vendor/ruby-ifconfig-1.2/test/unit/tc_dragonflybsd.rb +0 -39
- data/vendor/ruby-ifconfig-1.2/test/unit/tc_freebsd.rb +0 -40
- data/vendor/ruby-ifconfig-1.2/test/unit/tc_linux.rb +0 -49
- data/vendor/ruby-ifconfig-1.2/test/unit/tc_netbsd.rb +0 -39
- data/vendor/ruby-ifconfig-1.2/test/unit/tc_openbsd.rb +0 -39
- data/vendor/ruby-ifconfig-1.2/test/unit/tc_sunos.rb +0 -44
data/src/lib/openflow_message.h
DELETED
@@ -1,291 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* An OpenFlow message library.
|
3
|
-
*
|
4
|
-
* Copyright (C) 2008-2013 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
|
-
#ifndef OPENFLOW_MESSAGE_H
|
22
|
-
#define OPENFLOW_MESSAGE_H
|
23
|
-
|
24
|
-
|
25
|
-
#include <openflow.h>
|
26
|
-
#include "bool.h"
|
27
|
-
#include "buffer.h"
|
28
|
-
#include "byteorder.h"
|
29
|
-
#include "linked_list.h"
|
30
|
-
#include "packet_info.h"
|
31
|
-
|
32
|
-
|
33
|
-
// A structure for storing OpenFlow actions
|
34
|
-
typedef struct openflow_actions {
|
35
|
-
int n_actions;
|
36
|
-
list_element *list;
|
37
|
-
} openflow_actions;
|
38
|
-
|
39
|
-
|
40
|
-
// Initialization
|
41
|
-
bool init_openflow_message( void );
|
42
|
-
|
43
|
-
// Functions for creating OpenFlow messages
|
44
|
-
buffer *create_hello( const uint32_t transaction_id );
|
45
|
-
buffer *create_error( const uint32_t transaction_id, const uint16_t type,
|
46
|
-
const uint16_t code, const buffer *data );
|
47
|
-
buffer *create_echo_request( const uint32_t transaction_id, const buffer *body );
|
48
|
-
buffer *create_echo_reply( const uint32_t transaction_id, const buffer *body );
|
49
|
-
buffer *create_vendor( const uint32_t transaction_id, const uint32_t vendor,
|
50
|
-
const buffer *body );
|
51
|
-
buffer *create_features_request( const uint32_t transaction_id );
|
52
|
-
buffer *create_features_reply( const uint32_t transaction_id, const uint64_t datapath_id,
|
53
|
-
const uint32_t n_buffers, const uint8_t n_tables,
|
54
|
-
const uint32_t capabilities, const uint32_t actions,
|
55
|
-
const list_element *ports );
|
56
|
-
buffer *create_get_config_request( const uint32_t transaction_id );
|
57
|
-
buffer *create_get_config_reply( const uint32_t transaction_id, const uint16_t flags,
|
58
|
-
const uint16_t miss_send_len );
|
59
|
-
buffer *create_set_config( const uint32_t transaction_id, const uint16_t flags,
|
60
|
-
const uint16_t miss_send_len );
|
61
|
-
buffer *create_packet_in( const uint32_t transaction_id, const uint32_t buffer_id,
|
62
|
-
const uint16_t total_len, uint16_t in_port,
|
63
|
-
const uint8_t reason, const buffer *data );
|
64
|
-
buffer *create_flow_removed( const uint32_t transaction_id, const struct ofp_match match,
|
65
|
-
const uint64_t cookie, const uint16_t priority,
|
66
|
-
const uint8_t reason, const uint32_t duration_sec,
|
67
|
-
const uint32_t duration_nsec, const uint16_t idle_timeout,
|
68
|
-
const uint64_t packet_count, const uint64_t byte_count );
|
69
|
-
buffer *create_port_status( const uint32_t transaction_id, const uint8_t reason,
|
70
|
-
const struct ofp_phy_port desc );
|
71
|
-
buffer *create_packet_out( const uint32_t transaction_id, const uint32_t buffer_id,
|
72
|
-
const uint16_t in_port, const openflow_actions *actions,
|
73
|
-
const buffer *data );
|
74
|
-
buffer *create_flow_mod(
|
75
|
-
const uint32_t transaction_id,
|
76
|
-
const struct ofp_match match,
|
77
|
-
const uint64_t cookie,
|
78
|
-
const uint16_t command,
|
79
|
-
const uint16_t idle_timeout,
|
80
|
-
const uint16_t hard_timeout,
|
81
|
-
const uint16_t priority,
|
82
|
-
const uint32_t buffer_id,
|
83
|
-
const uint16_t out_port,
|
84
|
-
const uint16_t flags,
|
85
|
-
const openflow_actions *actions
|
86
|
-
);
|
87
|
-
buffer *create_port_mod( const uint32_t transaction_id, const uint16_t port_no,
|
88
|
-
const uint8_t hw_addr[ OFP_ETH_ALEN ], const uint32_t config,
|
89
|
-
const uint32_t mask, const uint32_t advertise );
|
90
|
-
buffer *create_desc_stats_request( const uint32_t transaction_id, const uint16_t flags );
|
91
|
-
buffer *create_flow_stats_request( const uint32_t transaction_id, const uint16_t flags,
|
92
|
-
const struct ofp_match match, const uint8_t table_id,
|
93
|
-
const uint16_t out_port );
|
94
|
-
buffer *create_aggregate_stats_request( const uint32_t transaction_id,
|
95
|
-
const uint16_t flags, const struct ofp_match match,
|
96
|
-
const uint8_t table_id, const uint16_t out_port );
|
97
|
-
buffer *create_table_stats_request( const uint32_t transaction_id, const uint16_t flags );
|
98
|
-
buffer *create_port_stats_request( const uint32_t transaction_id, const uint16_t flags,
|
99
|
-
const uint16_t port_no );
|
100
|
-
buffer *create_queue_stats_request( const uint32_t transaction_id, const uint16_t flags,
|
101
|
-
const uint16_t port_no, const uint32_t queue_id );
|
102
|
-
buffer *create_vendor_stats_request( const uint32_t transaction_id, const uint16_t flags,
|
103
|
-
const uint32_t vendor, const buffer *body );
|
104
|
-
buffer *create_desc_stats_reply( const uint32_t transaction_id, const uint16_t flags,
|
105
|
-
const char mfr_desc[ DESC_STR_LEN ],
|
106
|
-
const char hw_desc[ DESC_STR_LEN ],
|
107
|
-
const char sw_desc[ DESC_STR_LEN ],
|
108
|
-
const char serial_num[ SERIAL_NUM_LEN ],
|
109
|
-
const char dp_desc[ DESC_STR_LEN ] );
|
110
|
-
buffer *create_flow_stats_reply( const uint32_t transaction_id, const uint16_t flags,
|
111
|
-
const list_element *flows_stats_head );
|
112
|
-
buffer *create_aggregate_stats_reply( const uint32_t transaction_id,
|
113
|
-
const uint16_t flags,
|
114
|
-
const uint64_t packet_count, const uint64_t byte_count,
|
115
|
-
const uint32_t flow_count );
|
116
|
-
buffer *create_table_stats_reply( const uint32_t transaction_id, const uint16_t flags,
|
117
|
-
const list_element *table_stats_head );
|
118
|
-
buffer *create_port_stats_reply( const uint32_t transaction_id, const uint16_t flags,
|
119
|
-
const list_element *port_stats_head );
|
120
|
-
buffer *create_queue_stats_reply( const uint32_t transaction_id, const uint16_t flags,
|
121
|
-
const list_element *queue_stats_head );
|
122
|
-
buffer *create_vendor_stats_reply( const uint32_t transaction_id, const uint16_t flags,
|
123
|
-
const uint32_t vendor, const buffer *body );
|
124
|
-
buffer *create_barrier_request( const uint32_t transaction_id );
|
125
|
-
buffer *create_barrier_reply( const uint32_t transaction_id );
|
126
|
-
buffer *create_queue_get_config_request( const uint32_t transaction_id, const uint16_t port );
|
127
|
-
buffer *create_queue_get_config_reply( const uint32_t transaction_id, const uint16_t port,
|
128
|
-
const list_element *queues );
|
129
|
-
uint32_t get_transaction_id( void );
|
130
|
-
uint64_t get_cookie( void );
|
131
|
-
openflow_actions *create_actions( void );
|
132
|
-
bool delete_actions( openflow_actions *actions );
|
133
|
-
bool append_action_output( openflow_actions *actions, const uint16_t port, const uint16_t max_len );
|
134
|
-
bool append_action_set_vlan_vid( openflow_actions *actions, const uint16_t vlan_vid );
|
135
|
-
bool append_action_set_vlan_pcp( openflow_actions *actions, const uint8_t vlan_pcp );
|
136
|
-
bool append_action_strip_vlan( openflow_actions *actions );
|
137
|
-
bool append_action_set_dl_src( openflow_actions *actions, const uint8_t hw_addr[ OFP_ETH_ALEN ] );
|
138
|
-
bool append_action_set_dl_dst( openflow_actions *actions, const uint8_t hw_addr[ OFP_ETH_ALEN ] );
|
139
|
-
bool append_action_set_nw_src( openflow_actions *actions, const uint32_t nw_addr );
|
140
|
-
bool append_action_set_nw_dst( openflow_actions *actions, const uint32_t nw_addr );
|
141
|
-
bool append_action_set_nw_tos( openflow_actions *actions, const uint8_t nw_tos );
|
142
|
-
bool append_action_set_tp_src( openflow_actions *actions, const uint16_t tp_port );
|
143
|
-
bool append_action_set_tp_dst( openflow_actions *actions, const uint16_t tp_port );
|
144
|
-
bool append_action_enqueue( openflow_actions *actions, const uint16_t port,
|
145
|
-
const uint32_t queue_id );
|
146
|
-
bool append_action_vendor( openflow_actions *actions, const uint32_t vendor,
|
147
|
-
const buffer *data );
|
148
|
-
|
149
|
-
|
150
|
-
// Return code definitions indicating the result of OpenFlow message validation.
|
151
|
-
enum {
|
152
|
-
SUCCESS = 0,
|
153
|
-
ERROR_UNSUPPORTED_VERSION = -63,
|
154
|
-
ERROR_INVALID_LENGTH,
|
155
|
-
ERROR_TOO_SHORT_MESSAGE,
|
156
|
-
ERROR_TOO_LONG_MESSAGE,
|
157
|
-
ERROR_INVALID_TYPE,
|
158
|
-
ERROR_UNDEFINED_TYPE,
|
159
|
-
ERROR_UNSUPPORTED_TYPE,
|
160
|
-
ERROR_NO_TABLE_AVAILABLE,
|
161
|
-
ERROR_INVALID_PORT_NO,
|
162
|
-
ERROR_INVALID_PORT_CONFIG,
|
163
|
-
ERROR_INVALID_PORT_STATE,
|
164
|
-
ERROR_INVALID_PORT_FEATURES,
|
165
|
-
ERROR_INVALID_SWITCH_CONFIG,
|
166
|
-
ERROR_INVALID_PACKET_IN_REASON,
|
167
|
-
ERROR_INVALID_FLOW_REMOVED_REASON,
|
168
|
-
ERROR_INVALID_WILDCARDS,
|
169
|
-
ERROR_INVALID_VLAN_VID,
|
170
|
-
ERROR_INVALID_VLAN_PCP,
|
171
|
-
ERROR_INVALID_NW_TOS,
|
172
|
-
ERROR_INVALID_PORT_STATUS_REASON,
|
173
|
-
ERROR_TOO_SHORT_QUEUE_DESCRIPTION,
|
174
|
-
ERROR_TOO_SHORT_QUEUE_PROPERTY,
|
175
|
-
ERROR_TOO_LONG_QUEUE_PROPERTY,
|
176
|
-
ERROR_UNDEFINED_QUEUE_PROPERTY,
|
177
|
-
ERROR_TOO_SHORT_ACTION,
|
178
|
-
ERROR_UNDEFINED_ACTION_TYPE,
|
179
|
-
ERROR_INVALID_ACTION_TYPE,
|
180
|
-
ERROR_TOO_SHORT_ACTION_OUTPUT,
|
181
|
-
ERROR_TOO_LONG_ACTION_OUTPUT,
|
182
|
-
ERROR_TOO_SHORT_ACTION_VLAN_VID,
|
183
|
-
ERROR_TOO_LONG_ACTION_VLAN_VID,
|
184
|
-
ERROR_TOO_SHORT_ACTION_VLAN_PCP,
|
185
|
-
ERROR_TOO_LONG_ACTION_VLAN_PCP,
|
186
|
-
ERROR_TOO_SHORT_ACTION_STRIP_VLAN,
|
187
|
-
ERROR_TOO_LONG_ACTION_STRIP_VLAN,
|
188
|
-
ERROR_TOO_SHORT_ACTION_DL_SRC,
|
189
|
-
ERROR_TOO_LONG_ACTION_DL_SRC,
|
190
|
-
ERROR_TOO_SHORT_ACTION_DL_DST,
|
191
|
-
ERROR_TOO_LONG_ACTION_DL_DST,
|
192
|
-
ERROR_TOO_SHORT_ACTION_NW_SRC,
|
193
|
-
ERROR_TOO_LONG_ACTION_NW_SRC,
|
194
|
-
ERROR_TOO_SHORT_ACTION_NW_DST,
|
195
|
-
ERROR_TOO_LONG_ACTION_NW_DST,
|
196
|
-
ERROR_TOO_SHORT_ACTION_NW_TOS,
|
197
|
-
ERROR_TOO_LONG_ACTION_NW_TOS,
|
198
|
-
ERROR_TOO_SHORT_ACTION_TP_SRC,
|
199
|
-
ERROR_TOO_LONG_ACTION_TP_SRC,
|
200
|
-
ERROR_TOO_SHORT_ACTION_TP_DST,
|
201
|
-
ERROR_TOO_LONG_ACTION_TP_DST,
|
202
|
-
ERROR_TOO_SHORT_ACTION_ENQUEUE,
|
203
|
-
ERROR_TOO_LONG_ACTION_ENQUEUE,
|
204
|
-
ERROR_TOO_SHORT_ACTION_VENDOR,
|
205
|
-
ERROR_INVALID_LENGTH_ACTION_VENDOR,
|
206
|
-
ERROR_UNSUPPORTED_STATS_TYPE,
|
207
|
-
ERROR_INVALID_STATS_REPLY_FLAGS,
|
208
|
-
ERROR_INVALID_FLOW_PRIORITY,
|
209
|
-
ERROR_INVALID_FLOW_MOD_FLAGS,
|
210
|
-
ERROR_INVALID_PORT_MASK,
|
211
|
-
ERROR_INVALID_STATS_TYPE,
|
212
|
-
ERROR_INVALID_STATS_REQUEST_FLAGS,
|
213
|
-
ERROR_UNDEFINED_FLOW_MOD_COMMAND,
|
214
|
-
ERROR_INVALID_ERROR_TYPE,
|
215
|
-
ERROR_INVALID_ERROR_CODE,
|
216
|
-
ERROR_UNEXPECTED_ERROR = -255
|
217
|
-
};
|
218
|
-
|
219
|
-
|
220
|
-
// Functions for validating OpenFlow messages
|
221
|
-
int validate_hello( const buffer *message );
|
222
|
-
int validate_error( const buffer *message );
|
223
|
-
int validate_echo_request( const buffer *message );
|
224
|
-
int validate_echo_reply( const buffer *message );
|
225
|
-
int validate_vendor( const buffer *message );
|
226
|
-
int validate_features_request( const buffer *message );
|
227
|
-
int validate_features_reply( const buffer *message );
|
228
|
-
int validate_get_config_request( const buffer *message );
|
229
|
-
int validate_get_config_reply( const buffer *message );
|
230
|
-
int validate_set_config( const buffer *message );
|
231
|
-
int validate_packet_in( const buffer *message );
|
232
|
-
int validate_flow_removed( const buffer *message );
|
233
|
-
int validate_port_status( const buffer *message );
|
234
|
-
int validate_packet_out( const buffer *message );
|
235
|
-
int validate_flow_mod( const buffer *message );
|
236
|
-
int validate_port_mod( const buffer *message );
|
237
|
-
int validate_desc_stats_request( const buffer *message );
|
238
|
-
int validate_flow_stats_request( const buffer *message );
|
239
|
-
int validate_aggregate_stats_request( const buffer *message );
|
240
|
-
int validate_table_stats_request( const buffer *message );
|
241
|
-
int validate_port_stats_request( const buffer *message );
|
242
|
-
int validate_queue_stats_request( const buffer *message );
|
243
|
-
int validate_vendor_stats_request( const buffer *message );
|
244
|
-
int validate_stats_request( const buffer *message );
|
245
|
-
int validate_desc_stats_reply( const buffer *message );
|
246
|
-
int validate_flow_stats_reply( const buffer *message );
|
247
|
-
int validate_aggregate_stats_reply( const buffer *message );
|
248
|
-
int validate_table_stats_reply( const buffer *message );
|
249
|
-
int validate_port_stats_reply( const buffer *message );
|
250
|
-
int validate_queue_stats_reply( const buffer *message );
|
251
|
-
int validate_vendor_stats_reply( const buffer *message );
|
252
|
-
int validate_stats_reply( const buffer *message );
|
253
|
-
int validate_barrier_request( const buffer *message );
|
254
|
-
int validate_barrier_reply( const buffer *message );
|
255
|
-
int validate_queue_get_config_request( const buffer *message );
|
256
|
-
int validate_queue_get_config_reply( const buffer *message );
|
257
|
-
int validate_actions( struct ofp_action_header *actions_head, const uint16_t length );
|
258
|
-
int validate_action_output( const struct ofp_action_output *action );
|
259
|
-
int validate_action_set_vlan_vid( const struct ofp_action_vlan_vid *action );
|
260
|
-
int validate_action_set_vlan_pcp( const struct ofp_action_vlan_pcp *action );
|
261
|
-
int validate_action_strip_vlan( const struct ofp_action_header *action );
|
262
|
-
int validate_action_set_dl_src( const struct ofp_action_dl_addr *action );
|
263
|
-
int validate_action_set_dl_dst( const struct ofp_action_dl_addr *action );
|
264
|
-
int validate_action_set_nw_src( const struct ofp_action_nw_addr *action );
|
265
|
-
int validate_action_set_nw_dst( const struct ofp_action_nw_addr *action );
|
266
|
-
int validate_action_set_nw_tos( const struct ofp_action_nw_tos *action );
|
267
|
-
int validate_action_set_tp_src( const struct ofp_action_tp_port *action );
|
268
|
-
int validate_action_set_tp_dst( const struct ofp_action_tp_port *action );
|
269
|
-
int validate_action_enqueue( const struct ofp_action_enqueue *action );
|
270
|
-
int validate_action_vendor( const struct ofp_action_vendor_header *action );
|
271
|
-
int validate_openflow_message( const buffer *message );
|
272
|
-
bool valid_openflow_message( const buffer *message );
|
273
|
-
bool valid_message_version( const uint8_t type, const uint8_t version );
|
274
|
-
|
275
|
-
// Utility functions
|
276
|
-
bool get_error_type_and_code( const uint8_t type, const int error_no,
|
277
|
-
uint16_t *error_type, uint16_t *error_code );
|
278
|
-
void set_match_from_packet( struct ofp_match *match, const uint16_t in_port,
|
279
|
-
const uint32_t wildcards, const buffer *packet );
|
280
|
-
void normalize_match( struct ofp_match *match );
|
281
|
-
|
282
|
-
|
283
|
-
#endif // OPENFLOW_MESSAGE_H
|
284
|
-
|
285
|
-
|
286
|
-
/*
|
287
|
-
* Local variables:
|
288
|
-
* c-basic-offset: 2
|
289
|
-
* indent-tabs-mode: nil
|
290
|
-
* End:
|
291
|
-
*/
|
@@ -1,58 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* OpenFlow service interface.
|
3
|
-
*
|
4
|
-
* Copyright (C) 2008-2013 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
|
-
#ifndef OPENFLOW_SERVICE_INTERFACE_H
|
22
|
-
#define OPENFLOW_SERVICE_INTERFACE_H
|
23
|
-
|
24
|
-
|
25
|
-
/**
|
26
|
-
* Message type definitions for sending/receiving OpenFlow messages or
|
27
|
-
* related events via messenger.
|
28
|
-
*/
|
29
|
-
#define MESSENGER_OPENFLOW_MESSAGE 1
|
30
|
-
#define MESSENGER_OPENFLOW_CONNECTED 2
|
31
|
-
#define MESSENGER_OPENFLOW_READY 3
|
32
|
-
#define MESSENGER_OPENFLOW_DISCONNECTED 4
|
33
|
-
#define MESSENGER_OPENFLOW_DISCONNECT_REQUEST 5
|
34
|
-
#define MESSENGER_OPENFLOW_FAILD_TO_CONNECT 6
|
35
|
-
|
36
|
-
|
37
|
-
/**
|
38
|
-
* Header for sending/receiving OpenFlow messages or events via messenger.
|
39
|
-
* A null-terminated service name can be provided after service_name_len
|
40
|
-
* and an OpenFlow message must be included in the rest of part in case of
|
41
|
-
* MESSENGER_OPENFLOW_MESSAGE. service_name_length can be zero if service
|
42
|
-
* name notification is not necessary.
|
43
|
-
*/
|
44
|
-
typedef struct openflow_service_header {
|
45
|
-
uint64_t datapath_id;
|
46
|
-
uint16_t service_name_length;
|
47
|
-
} __attribute__( ( packed ) ) openflow_service_header_t;
|
48
|
-
|
49
|
-
|
50
|
-
#endif // OPENFLOW_SERVICE_INTERFACE_H
|
51
|
-
|
52
|
-
|
53
|
-
/*
|
54
|
-
* Local variables:
|
55
|
-
* c-basic-offset: 2
|
56
|
-
* indent-tabs-mode: nil
|
57
|
-
* End:
|
58
|
-
*/
|
@@ -1,1378 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* Copyright (C) 2008-2013 NEC Corporation
|
3
|
-
*
|
4
|
-
* This program is free software; you can redistribute it and/or modify
|
5
|
-
* it under the terms of the GNU General Public License, version 2, as
|
6
|
-
* published by the Free Software Foundation.
|
7
|
-
*
|
8
|
-
* This program is distributed in the hope that it will be useful,
|
9
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
11
|
-
* GNU General Public License for more details.
|
12
|
-
*
|
13
|
-
* You should have received a copy of the GNU General Public License along
|
14
|
-
* with this program; if not, write to the Free Software Foundation, Inc.,
|
15
|
-
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
16
|
-
*/
|
17
|
-
|
18
|
-
|
19
|
-
#include <arpa/inet.h>
|
20
|
-
#include <assert.h>
|
21
|
-
#include <inttypes.h>
|
22
|
-
#include <syslog.h>
|
23
|
-
#include "chibach_private.h"
|
24
|
-
#include "hash_table.h"
|
25
|
-
#include "log.h"
|
26
|
-
#include "messenger.h"
|
27
|
-
#include "openflow_message.h"
|
28
|
-
#include "openflow_service_interface.h"
|
29
|
-
#include "openflow_switch_interface.h"
|
30
|
-
#include "secure_channel.h"
|
31
|
-
#include "timer.h"
|
32
|
-
#include "wrapper.h"
|
33
|
-
|
34
|
-
|
35
|
-
typedef struct {
|
36
|
-
uint64_t datapath_id;
|
37
|
-
struct {
|
38
|
-
uint32_t ip;
|
39
|
-
uint16_t port;
|
40
|
-
} controller;
|
41
|
-
} openflow_switch_config;
|
42
|
-
|
43
|
-
typedef bool ( *message_send_handler )( buffer *message, void *user_data );
|
44
|
-
|
45
|
-
typedef struct {
|
46
|
-
uint32_t transaction_id;
|
47
|
-
buffer *message;
|
48
|
-
message_send_handler send_callback;
|
49
|
-
void *user_data;
|
50
|
-
time_t created_at;
|
51
|
-
} openflow_context;
|
52
|
-
|
53
|
-
|
54
|
-
static bool openflow_switch_interface_initialized = false;
|
55
|
-
static openflow_event_handlers event_handlers;
|
56
|
-
static openflow_switch_config config;
|
57
|
-
static const int CONTEXT_LIFETIME = 5;
|
58
|
-
static hash_table *contexts = NULL;
|
59
|
-
|
60
|
-
|
61
|
-
static bool
|
62
|
-
compare_context( const void *x, const void *y ) {
|
63
|
-
const openflow_context *cx = x;
|
64
|
-
const openflow_context *cy = y;
|
65
|
-
|
66
|
-
return ( cx->transaction_id == cy->transaction_id ) ? true : false;
|
67
|
-
}
|
68
|
-
|
69
|
-
|
70
|
-
static unsigned int
|
71
|
-
hash_context( const void *key ) {
|
72
|
-
return ( unsigned int ) *( ( const uint32_t * ) key );
|
73
|
-
}
|
74
|
-
|
75
|
-
|
76
|
-
static openflow_context *
|
77
|
-
lookup_context( uint32_t transaction_id ) {
|
78
|
-
assert( contexts != NULL );
|
79
|
-
|
80
|
-
return lookup_hash_entry( contexts, &transaction_id );
|
81
|
-
}
|
82
|
-
|
83
|
-
|
84
|
-
static bool
|
85
|
-
save_context( uint32_t transaction_id, buffer *message, message_send_handler callback, void *user_data ) {
|
86
|
-
assert( contexts != NULL );
|
87
|
-
|
88
|
-
openflow_context *context = lookup_context( transaction_id );
|
89
|
-
if ( context != NULL ) {
|
90
|
-
return false;
|
91
|
-
}
|
92
|
-
|
93
|
-
context = xmalloc( sizeof( openflow_context ) );
|
94
|
-
memset( context, 0, sizeof( openflow_context ) );
|
95
|
-
context->transaction_id = transaction_id;
|
96
|
-
context->message = duplicate_buffer( message );
|
97
|
-
context->send_callback = callback;
|
98
|
-
context->user_data = user_data;
|
99
|
-
context->created_at = time( NULL );
|
100
|
-
|
101
|
-
insert_hash_entry( contexts, &context->transaction_id, context );
|
102
|
-
|
103
|
-
return true;
|
104
|
-
}
|
105
|
-
|
106
|
-
|
107
|
-
static void
|
108
|
-
delete_context( uint32_t transaction_id ) {
|
109
|
-
assert( contexts != NULL );
|
110
|
-
|
111
|
-
openflow_context *context = delete_hash_entry( contexts, &transaction_id );
|
112
|
-
if ( context == NULL ) {
|
113
|
-
return;
|
114
|
-
}
|
115
|
-
|
116
|
-
if ( context->message != NULL ) {
|
117
|
-
free_buffer( context->message );
|
118
|
-
}
|
119
|
-
if ( context->user_data != NULL ) {
|
120
|
-
xfree( context->user_data );
|
121
|
-
}
|
122
|
-
|
123
|
-
xfree( context );
|
124
|
-
}
|
125
|
-
|
126
|
-
|
127
|
-
static void
|
128
|
-
age_contexts( void *user_data ) {
|
129
|
-
UNUSED( user_data );
|
130
|
-
|
131
|
-
time_t now = time( NULL );
|
132
|
-
|
133
|
-
hash_iterator iter;
|
134
|
-
init_hash_iterator( contexts, &iter );
|
135
|
-
hash_entry *e = NULL;
|
136
|
-
while ( ( e = iterate_hash_next( &iter ) ) != NULL ) {
|
137
|
-
openflow_context *context = e->value;
|
138
|
-
if ( ( context != NULL ) && ( ( context->created_at + CONTEXT_LIFETIME ) <= now ) ) {
|
139
|
-
delete_context( context->transaction_id );
|
140
|
-
}
|
141
|
-
}
|
142
|
-
}
|
143
|
-
|
144
|
-
|
145
|
-
static void
|
146
|
-
init_context() {
|
147
|
-
assert( contexts == NULL );
|
148
|
-
|
149
|
-
contexts = create_hash_with_size( compare_context, hash_context, 128 );
|
150
|
-
}
|
151
|
-
|
152
|
-
|
153
|
-
static void
|
154
|
-
finalize_context() {
|
155
|
-
assert( contexts != NULL );
|
156
|
-
|
157
|
-
hash_iterator iter;
|
158
|
-
init_hash_iterator( contexts, &iter );
|
159
|
-
hash_entry *e = NULL;
|
160
|
-
while ( ( e = iterate_hash_next( &iter ) ) != NULL ) {
|
161
|
-
openflow_context *context = e->value;
|
162
|
-
if ( context != NULL ) {
|
163
|
-
delete_context( context->transaction_id );
|
164
|
-
}
|
165
|
-
}
|
166
|
-
delete_hash( contexts );
|
167
|
-
contexts = NULL;
|
168
|
-
}
|
169
|
-
|
170
|
-
|
171
|
-
bool
|
172
|
-
openflow_switch_interface_is_initialized() {
|
173
|
-
return openflow_switch_interface_initialized;
|
174
|
-
}
|
175
|
-
|
176
|
-
|
177
|
-
bool
|
178
|
-
switch_set_openflow_event_handlers( const openflow_event_handlers handlers ) {
|
179
|
-
assert( openflow_switch_interface_initialized );
|
180
|
-
|
181
|
-
memcpy( &event_handlers, &handlers, sizeof( event_handlers ) );
|
182
|
-
|
183
|
-
return true;
|
184
|
-
}
|
185
|
-
|
186
|
-
|
187
|
-
bool
|
188
|
-
set_controller_connected_handler( controller_connected_handler callback, void *user_data ) {
|
189
|
-
assert( callback != NULL );
|
190
|
-
assert( openflow_switch_interface_initialized );
|
191
|
-
|
192
|
-
debug( "Setting a controller connected handler ( callback = %p, user_data = %p ).", callback, user_data );
|
193
|
-
|
194
|
-
event_handlers.controller_connected_callback = callback;
|
195
|
-
event_handlers.controller_connected_user_data = user_data;
|
196
|
-
|
197
|
-
return true;
|
198
|
-
}
|
199
|
-
|
200
|
-
|
201
|
-
bool
|
202
|
-
set_controller_disconnected_handler( controller_disconnected_handler callback, void *user_data ) {
|
203
|
-
assert( callback != NULL );
|
204
|
-
assert( openflow_switch_interface_initialized );
|
205
|
-
|
206
|
-
debug( "Setting a controller disconnected handler ( callback = %p, user_data = %p ).", callback, user_data );
|
207
|
-
|
208
|
-
event_handlers.controller_disconnected_callback = callback;
|
209
|
-
event_handlers.controller_disconnected_user_data = user_data;
|
210
|
-
|
211
|
-
return true;
|
212
|
-
}
|
213
|
-
|
214
|
-
|
215
|
-
bool
|
216
|
-
set_hello_handler( hello_handler callback, void *user_data ) {
|
217
|
-
assert( callback != NULL );
|
218
|
-
assert( openflow_switch_interface_initialized );
|
219
|
-
|
220
|
-
debug( "Setting a hello handler ( callback = %p, user_data = %p ).", callback, user_data );
|
221
|
-
|
222
|
-
event_handlers.hello_callback = callback;
|
223
|
-
event_handlers.hello_user_data = user_data;
|
224
|
-
|
225
|
-
return true;
|
226
|
-
}
|
227
|
-
|
228
|
-
|
229
|
-
bool
|
230
|
-
switch_set_error_handler( error_handler callback, void *user_data ) {
|
231
|
-
assert( callback != NULL );
|
232
|
-
assert( openflow_switch_interface_initialized );
|
233
|
-
|
234
|
-
debug( "Setting an error handler ( callback = %p, user_data = %p ).", callback, user_data );
|
235
|
-
|
236
|
-
event_handlers.error_callback = callback;
|
237
|
-
event_handlers.error_user_data = user_data;
|
238
|
-
|
239
|
-
return true;
|
240
|
-
}
|
241
|
-
|
242
|
-
|
243
|
-
bool
|
244
|
-
set_echo_request_handler( echo_request_handler callback, void *user_data ) {
|
245
|
-
assert( callback != NULL );
|
246
|
-
assert( openflow_switch_interface_initialized );
|
247
|
-
|
248
|
-
debug( "Setting an echo request handler ( callback = %p, user_data = %p ).", callback, user_data );
|
249
|
-
|
250
|
-
event_handlers.echo_request_callback = callback;
|
251
|
-
event_handlers.echo_request_user_data = user_data;
|
252
|
-
|
253
|
-
return true;
|
254
|
-
}
|
255
|
-
|
256
|
-
|
257
|
-
bool
|
258
|
-
switch_set_echo_reply_handler( echo_reply_handler callback, void *user_data ) {
|
259
|
-
assert( callback != NULL );
|
260
|
-
assert( openflow_switch_interface_initialized );
|
261
|
-
|
262
|
-
debug( "Setting an echo reply handler ( callback = %p, user_data = %p ).", callback, user_data );
|
263
|
-
|
264
|
-
event_handlers.echo_reply_callback = callback;
|
265
|
-
event_handlers.echo_reply_user_data = user_data;
|
266
|
-
|
267
|
-
return true;
|
268
|
-
}
|
269
|
-
|
270
|
-
|
271
|
-
bool
|
272
|
-
switch_set_vendor_handler( vendor_handler callback, void *user_data ) {
|
273
|
-
assert( callback != NULL );
|
274
|
-
assert( openflow_switch_interface_initialized );
|
275
|
-
|
276
|
-
debug( "Setting a vendor handler ( callback = %p, user_data = %p ).", callback, user_data );
|
277
|
-
|
278
|
-
event_handlers.vendor_callback = callback;
|
279
|
-
event_handlers.vendor_user_data = user_data;
|
280
|
-
|
281
|
-
return true;
|
282
|
-
}
|
283
|
-
|
284
|
-
|
285
|
-
bool
|
286
|
-
set_features_request_handler( features_request_handler callback, void *user_data ) {
|
287
|
-
assert( callback != NULL );
|
288
|
-
assert( openflow_switch_interface_initialized );
|
289
|
-
|
290
|
-
debug( "Setting a features request handler ( callback = %p, user_data = %p ).", callback, user_data );
|
291
|
-
|
292
|
-
event_handlers.features_request_callback = callback;
|
293
|
-
event_handlers.features_request_user_data = user_data;
|
294
|
-
|
295
|
-
return true;
|
296
|
-
}
|
297
|
-
|
298
|
-
|
299
|
-
bool
|
300
|
-
set_get_config_request_handler( get_config_request_handler callback, void *user_data ) {
|
301
|
-
assert( callback != NULL );
|
302
|
-
assert( openflow_switch_interface_initialized );
|
303
|
-
|
304
|
-
debug( "Setting a get config request handler ( callback = %p, user_data = %p ).", callback, user_data );
|
305
|
-
|
306
|
-
event_handlers.get_config_request_callback = callback;
|
307
|
-
event_handlers.get_config_request_user_data = user_data;
|
308
|
-
|
309
|
-
return true;
|
310
|
-
}
|
311
|
-
|
312
|
-
|
313
|
-
bool
|
314
|
-
set_set_config_handler( set_config_handler callback, void *user_data ) {
|
315
|
-
assert( callback != NULL );
|
316
|
-
assert( openflow_switch_interface_initialized );
|
317
|
-
|
318
|
-
debug( "Setting a set config handler ( callback = %p, user_data = %p ).", callback, user_data );
|
319
|
-
|
320
|
-
event_handlers.set_config_callback = callback;
|
321
|
-
event_handlers.set_config_user_data = user_data;
|
322
|
-
|
323
|
-
return true;
|
324
|
-
}
|
325
|
-
|
326
|
-
|
327
|
-
bool
|
328
|
-
set_packet_out_handler( packet_out_handler callback, void *user_data ) {
|
329
|
-
assert( callback != NULL );
|
330
|
-
assert( openflow_switch_interface_initialized );
|
331
|
-
|
332
|
-
debug( "Setting a packet out handler ( callback = %p, user_data = %p ).", callback, user_data );
|
333
|
-
|
334
|
-
event_handlers.packet_out_callback = callback;
|
335
|
-
event_handlers.packet_out_user_data = user_data;
|
336
|
-
|
337
|
-
return true;
|
338
|
-
}
|
339
|
-
|
340
|
-
|
341
|
-
bool
|
342
|
-
set_flow_mod_handler( flow_mod_handler callback, void *user_data ) {
|
343
|
-
assert( callback != NULL );
|
344
|
-
assert( openflow_switch_interface_initialized );
|
345
|
-
|
346
|
-
debug( "Setting a flow mod handler ( callback = %p, user_data = %p ).", callback, user_data );
|
347
|
-
|
348
|
-
event_handlers.flow_mod_callback = callback;
|
349
|
-
event_handlers.flow_mod_user_data = user_data;
|
350
|
-
|
351
|
-
return true;
|
352
|
-
}
|
353
|
-
|
354
|
-
|
355
|
-
bool
|
356
|
-
set_port_mod_handler( port_mod_handler callback, void *user_data ) {
|
357
|
-
assert( callback != NULL );
|
358
|
-
assert( openflow_switch_interface_initialized );
|
359
|
-
|
360
|
-
debug( "Setting a port mod handler ( callback = %p, user_data = %p ).", callback, user_data );
|
361
|
-
|
362
|
-
event_handlers.port_mod_callback = callback;
|
363
|
-
event_handlers.port_mod_user_data = user_data;
|
364
|
-
|
365
|
-
return true;
|
366
|
-
}
|
367
|
-
|
368
|
-
|
369
|
-
bool
|
370
|
-
set_stats_request_handler( stats_request_handler callback, void *user_data ) {
|
371
|
-
assert( callback != NULL );
|
372
|
-
assert( openflow_switch_interface_initialized );
|
373
|
-
|
374
|
-
debug( "Setting a stats request handler ( callback = %p, user_data = %p ).", callback, user_data );
|
375
|
-
|
376
|
-
event_handlers.stats_request_callback = callback;
|
377
|
-
event_handlers.stats_request_user_data = user_data;
|
378
|
-
|
379
|
-
return true;
|
380
|
-
}
|
381
|
-
|
382
|
-
|
383
|
-
bool
|
384
|
-
set_barrier_request_handler( barrier_request_handler callback, void *user_data ) {
|
385
|
-
assert( callback != NULL );
|
386
|
-
assert( openflow_switch_interface_initialized );
|
387
|
-
|
388
|
-
debug( "Setting a barrier request handler ( callback = %p, user_data = %p ).", callback, user_data );
|
389
|
-
|
390
|
-
event_handlers.barrier_request_callback = callback;
|
391
|
-
event_handlers.barrier_request_user_data = user_data;
|
392
|
-
|
393
|
-
return true;
|
394
|
-
}
|
395
|
-
|
396
|
-
|
397
|
-
bool
|
398
|
-
set_queue_get_config_request_handler( queue_get_config_request_handler callback, void *user_data ) {
|
399
|
-
assert( callback != NULL );
|
400
|
-
assert( openflow_switch_interface_initialized );
|
401
|
-
|
402
|
-
debug( "Setting a queue get config request handler ( callback = %p, user_data = %p ).", callback, user_data );
|
403
|
-
|
404
|
-
event_handlers.queue_get_config_request_callback = callback;
|
405
|
-
event_handlers.queue_get_config_request_user_data = user_data;
|
406
|
-
|
407
|
-
return true;
|
408
|
-
}
|
409
|
-
|
410
|
-
|
411
|
-
static bool
|
412
|
-
empty( const buffer *data ) {
|
413
|
-
if ( ( data == NULL ) || ( ( data != NULL ) && ( data->length == 0 ) ) ) {
|
414
|
-
return true;
|
415
|
-
}
|
416
|
-
|
417
|
-
return false;
|
418
|
-
}
|
419
|
-
|
420
|
-
|
421
|
-
static void
|
422
|
-
handle_hello( buffer *data ) {
|
423
|
-
assert( empty( data ) == false );
|
424
|
-
|
425
|
-
struct ofp_header *hello = data->data;
|
426
|
-
|
427
|
-
uint32_t transaction_id = ntohl( hello->xid );
|
428
|
-
uint8_t version = hello->version;
|
429
|
-
|
430
|
-
debug( "A hello message is received ( transaction_id = %#x, version = %#x ).", transaction_id, version );
|
431
|
-
|
432
|
-
if ( event_handlers.hello_callback == NULL ) {
|
433
|
-
debug( "Callback function for hello events is not set." );
|
434
|
-
return;
|
435
|
-
}
|
436
|
-
|
437
|
-
debug( "Calling hello handler ( callback = %p, user_data = %p ).",
|
438
|
-
event_handlers.hello_callback, event_handlers.hello_user_data );
|
439
|
-
|
440
|
-
event_handlers.hello_callback( transaction_id,
|
441
|
-
version,
|
442
|
-
event_handlers.hello_user_data );
|
443
|
-
}
|
444
|
-
|
445
|
-
|
446
|
-
static void
|
447
|
-
handle_error( buffer *data ) {
|
448
|
-
assert( empty( data ) == false );
|
449
|
-
|
450
|
-
struct ofp_error_msg *error_msg = ( struct ofp_error_msg * ) data->data;
|
451
|
-
|
452
|
-
uint32_t transaction_id = ntohl( error_msg->header.xid );
|
453
|
-
uint16_t type = ntohs( error_msg->type );
|
454
|
-
uint16_t code = ntohs( error_msg->code );
|
455
|
-
|
456
|
-
buffer *body = duplicate_buffer( data );
|
457
|
-
remove_front_buffer( body, offsetof( struct ofp_error_msg, data ) );
|
458
|
-
|
459
|
-
debug( "An error message is received ( transaction_id = %#x, type = %#x, code = %#x, data length = %zu ).",
|
460
|
-
transaction_id, type, code, body->length );
|
461
|
-
|
462
|
-
if ( event_handlers.error_callback == NULL ) {
|
463
|
-
debug( "Callback function for error events is not set." );
|
464
|
-
free_buffer( body );
|
465
|
-
return;
|
466
|
-
}
|
467
|
-
|
468
|
-
debug( "Calling error handler ( callback = %p, user_data = %p ).",
|
469
|
-
event_handlers.error_callback, event_handlers.error_user_data );
|
470
|
-
|
471
|
-
event_handlers.error_callback( transaction_id,
|
472
|
-
type,
|
473
|
-
code,
|
474
|
-
body,
|
475
|
-
event_handlers.error_user_data );
|
476
|
-
|
477
|
-
free_buffer( body );
|
478
|
-
}
|
479
|
-
|
480
|
-
|
481
|
-
static void
|
482
|
-
handle_echo_request( buffer *data ) {
|
483
|
-
assert( empty( data ) == false );
|
484
|
-
|
485
|
-
struct ofp_header *header = data->data;
|
486
|
-
uint32_t transaction_id = htonl( header->xid );
|
487
|
-
uint16_t length = htons( header->length );
|
488
|
-
|
489
|
-
debug( "An echo request is received ( transaction_id = %#x, len = %u ).", transaction_id, length );
|
490
|
-
|
491
|
-
if ( event_handlers.echo_request_callback == NULL ) {
|
492
|
-
debug( "Callback function for echo request events is not set." );
|
493
|
-
return;
|
494
|
-
}
|
495
|
-
|
496
|
-
buffer *body = NULL;
|
497
|
-
if ( ( length - sizeof( struct ofp_header ) ) > 0 ) {
|
498
|
-
body = duplicate_buffer( data );
|
499
|
-
remove_front_buffer( body, sizeof( struct ofp_header ) );
|
500
|
-
}
|
501
|
-
|
502
|
-
debug( "Calling echo request handler ( callback = %p, body = %p, user_data = %p ).",
|
503
|
-
event_handlers.echo_request_callback,
|
504
|
-
body,
|
505
|
-
event_handlers.echo_request_user_data );
|
506
|
-
|
507
|
-
event_handlers.echo_request_callback( transaction_id, body, event_handlers.echo_request_user_data );
|
508
|
-
|
509
|
-
if ( body != NULL ) {
|
510
|
-
free_buffer( body );
|
511
|
-
}
|
512
|
-
}
|
513
|
-
|
514
|
-
|
515
|
-
static void
|
516
|
-
handle_echo_reply( buffer *data ) {
|
517
|
-
assert( empty( data ) == false );
|
518
|
-
|
519
|
-
struct ofp_header *header = data->data;
|
520
|
-
uint32_t transaction_id = htonl( header->xid );
|
521
|
-
uint16_t length = htons( header->length );
|
522
|
-
|
523
|
-
debug( "An echo reply is received ( transaction_id = %#x, len = %u ).", transaction_id, length );
|
524
|
-
|
525
|
-
if ( event_handlers.echo_reply_callback == NULL ) {
|
526
|
-
debug( "Callback function for echo reply events is not set." );
|
527
|
-
return;
|
528
|
-
}
|
529
|
-
|
530
|
-
buffer *body = NULL;
|
531
|
-
if ( ( length - sizeof( struct ofp_header ) ) > 0 ) {
|
532
|
-
body = duplicate_buffer( data );
|
533
|
-
remove_front_buffer( body, sizeof( struct ofp_header ) );
|
534
|
-
}
|
535
|
-
|
536
|
-
debug( "Calling echo reply handler ( callback = %p, body = %p, user_data = %p ).",
|
537
|
-
event_handlers.echo_reply_callback,
|
538
|
-
body,
|
539
|
-
event_handlers.echo_reply_user_data );
|
540
|
-
|
541
|
-
event_handlers.echo_reply_callback( transaction_id, body, event_handlers.echo_reply_user_data );
|
542
|
-
|
543
|
-
if ( body != NULL ) {
|
544
|
-
free_buffer( body );
|
545
|
-
}
|
546
|
-
}
|
547
|
-
|
548
|
-
|
549
|
-
static void
|
550
|
-
handle_vendor( buffer *data ) {
|
551
|
-
assert( empty( data ) == false );
|
552
|
-
|
553
|
-
struct ofp_vendor_header *vendor_header = ( struct ofp_vendor_header * ) data->data;
|
554
|
-
|
555
|
-
uint32_t transaction_id = ntohl( vendor_header->header.xid );
|
556
|
-
uint32_t vendor = ntohl( vendor_header->vendor );
|
557
|
-
|
558
|
-
uint16_t body_length = ( uint16_t ) ( ntohs( vendor_header->header.length )
|
559
|
-
- sizeof( struct ofp_vendor_header ) );
|
560
|
-
|
561
|
-
debug( "A vendor message is received ( transaction_id = %#x, vendor = %#x, body length = %u ).",
|
562
|
-
transaction_id, vendor, body_length );
|
563
|
-
|
564
|
-
if ( event_handlers.vendor_callback == NULL ) {
|
565
|
-
debug( "Callback function for vendor events is not set." );
|
566
|
-
return;
|
567
|
-
}
|
568
|
-
|
569
|
-
buffer *body = NULL;
|
570
|
-
if ( body_length > 0 ) {
|
571
|
-
body = duplicate_buffer( data );
|
572
|
-
remove_front_buffer( body, sizeof( struct ofp_vendor_header ) );
|
573
|
-
}
|
574
|
-
|
575
|
-
debug( "Calling vendor handler ( callback = %p, user_data = %p ).",
|
576
|
-
event_handlers.vendor_callback, event_handlers.vendor_user_data );
|
577
|
-
|
578
|
-
event_handlers.vendor_callback( transaction_id,
|
579
|
-
vendor,
|
580
|
-
body,
|
581
|
-
event_handlers.vendor_user_data );
|
582
|
-
|
583
|
-
if ( body != NULL ) {
|
584
|
-
free_buffer( body );
|
585
|
-
}
|
586
|
-
}
|
587
|
-
|
588
|
-
|
589
|
-
static void
|
590
|
-
handle_features_request( buffer *data ) {
|
591
|
-
assert( empty( data ) == false );
|
592
|
-
|
593
|
-
struct ofp_header *header = data->data;
|
594
|
-
|
595
|
-
uint32_t transaction_id = ntohl( header->xid );
|
596
|
-
|
597
|
-
debug( "A features request is received ( transaction_id = %#x ).", transaction_id );
|
598
|
-
|
599
|
-
if ( event_handlers.features_request_callback == NULL ) {
|
600
|
-
debug( "Callback function for features request events is not set." );
|
601
|
-
return;
|
602
|
-
}
|
603
|
-
|
604
|
-
debug( "Calling features request handler ( callback = %p, user_data = %p ).",
|
605
|
-
event_handlers.features_request_callback,
|
606
|
-
event_handlers.features_request_user_data );
|
607
|
-
|
608
|
-
event_handlers.features_request_callback( transaction_id,
|
609
|
-
event_handlers.features_request_user_data );
|
610
|
-
}
|
611
|
-
|
612
|
-
|
613
|
-
static void
|
614
|
-
handle_get_config_request( buffer *data ) {
|
615
|
-
assert( empty( data ) == false );
|
616
|
-
|
617
|
-
struct ofp_header *header = data->data;
|
618
|
-
|
619
|
-
uint32_t transaction_id = ntohl( header->xid );
|
620
|
-
|
621
|
-
debug( "A get config request is received ( transaction_id = %#x ).", transaction_id );
|
622
|
-
|
623
|
-
if ( event_handlers.get_config_request_callback == NULL ) {
|
624
|
-
debug( "Callback function for get config request events is not set." );
|
625
|
-
return;
|
626
|
-
}
|
627
|
-
|
628
|
-
debug( "Calling get config request handler ( callback = %p, user_data = %p ).",
|
629
|
-
event_handlers.get_config_request_callback,
|
630
|
-
event_handlers.get_config_request_user_data );
|
631
|
-
|
632
|
-
event_handlers.get_config_request_callback( transaction_id,
|
633
|
-
event_handlers.get_config_request_user_data );
|
634
|
-
}
|
635
|
-
|
636
|
-
|
637
|
-
static void
|
638
|
-
handle_set_config( buffer *data ) {
|
639
|
-
assert( empty( data ) == false );
|
640
|
-
|
641
|
-
struct ofp_switch_config *config = data->data;
|
642
|
-
|
643
|
-
uint32_t transaction_id = ntohl( config->header.xid );
|
644
|
-
uint16_t flags = ntohs( config->flags );
|
645
|
-
uint16_t miss_send_len = ntohs( config->miss_send_len );
|
646
|
-
|
647
|
-
debug( "A set config is received ( transaction_id = %#x, flags = %#x, miss_send_len = %u ).",
|
648
|
-
transaction_id, flags, miss_send_len );
|
649
|
-
|
650
|
-
if ( event_handlers.set_config_callback == NULL ) {
|
651
|
-
debug( "Callback function for set config events is not set." );
|
652
|
-
return;
|
653
|
-
}
|
654
|
-
|
655
|
-
debug( "Calling set config handler ( callback = %p, user_data = %p ).",
|
656
|
-
event_handlers.set_config_callback,
|
657
|
-
event_handlers.set_config_user_data );
|
658
|
-
|
659
|
-
event_handlers.set_config_callback( transaction_id, flags, miss_send_len,
|
660
|
-
event_handlers.set_config_user_data );
|
661
|
-
}
|
662
|
-
|
663
|
-
|
664
|
-
static void
|
665
|
-
handle_packet_out( buffer *data ) {
|
666
|
-
assert( empty( data ) == false );
|
667
|
-
|
668
|
-
struct ofp_packet_out *packet_out = data->data;
|
669
|
-
|
670
|
-
uint32_t transaction_id = ntohl( packet_out->header.xid );
|
671
|
-
uint32_t buffer_id = ntohl( packet_out->buffer_id );
|
672
|
-
uint16_t in_port = ntohs( packet_out->in_port );
|
673
|
-
size_t actions_len = ntohs( packet_out->actions_len );
|
674
|
-
openflow_actions *actions = NULL;
|
675
|
-
if ( actions_len > 0 ) {
|
676
|
-
actions = create_actions();
|
677
|
-
void *actions_p = packet_out->actions;
|
678
|
-
while ( actions_len > 0 ) {
|
679
|
-
struct ofp_action_header *ah = actions_p;
|
680
|
-
ntoh_action( ah, ah );
|
681
|
-
actions_len -= ah->len;
|
682
|
-
actions_p = ( char * ) actions_p + ah->len;
|
683
|
-
|
684
|
-
void *action = xmalloc( ah->len );
|
685
|
-
memcpy( action, ah, ah->len );
|
686
|
-
append_to_tail( &actions->list, ( void * ) action );
|
687
|
-
actions->n_actions++;
|
688
|
-
}
|
689
|
-
}
|
690
|
-
|
691
|
-
buffer *frame = NULL;
|
692
|
-
actions_len = ntohs( packet_out->actions_len );
|
693
|
-
size_t frame_length = ntohs( packet_out->header.length ) - offsetof( struct ofp_packet_out, actions ) - actions_len;
|
694
|
-
if ( frame_length > 0 ) {
|
695
|
-
frame = alloc_buffer_with_length( frame_length );
|
696
|
-
void *p = append_back_buffer( frame, frame_length );
|
697
|
-
size_t offset = offsetof( struct ofp_packet_out, actions ) + actions_len;
|
698
|
-
memcpy( p, ( char * ) packet_out + offset, frame_length );
|
699
|
-
}
|
700
|
-
|
701
|
-
debug( "A packet-out is received ( transaction_id = %#x, buffer_id = %#x, in_port = %u, "
|
702
|
-
"actions_len = %zu, frame_length = %zu ).",
|
703
|
-
transaction_id, buffer_id, in_port, actions_len, frame_length );
|
704
|
-
|
705
|
-
if ( event_handlers.packet_out_callback == NULL ) {
|
706
|
-
debug( "Callback function for packet-out events is not set." );
|
707
|
-
return;
|
708
|
-
}
|
709
|
-
|
710
|
-
debug( "Calling packet-outhandler ( callback = %p, user_data = %p ).",
|
711
|
-
event_handlers.packet_out_callback,
|
712
|
-
event_handlers.packet_out_user_data );
|
713
|
-
|
714
|
-
event_handlers.packet_out_callback( transaction_id, buffer_id, in_port, actions, frame,
|
715
|
-
event_handlers.packet_out_user_data );
|
716
|
-
|
717
|
-
if ( actions != NULL ) {
|
718
|
-
delete_actions( actions );
|
719
|
-
}
|
720
|
-
if ( frame != NULL ) {
|
721
|
-
free_buffer( frame );
|
722
|
-
}
|
723
|
-
}
|
724
|
-
|
725
|
-
|
726
|
-
static void
|
727
|
-
handle_flow_mod( buffer *data ) {
|
728
|
-
assert( empty( data ) == false );
|
729
|
-
|
730
|
-
struct ofp_flow_mod *flow_mod = data->data;
|
731
|
-
|
732
|
-
uint32_t transaction_id = ntohl( flow_mod->header.xid );
|
733
|
-
struct ofp_match match;
|
734
|
-
ntoh_match( &match, &flow_mod->match );
|
735
|
-
uint64_t cookie = ntohll( flow_mod->cookie );
|
736
|
-
uint16_t command = ntohs( flow_mod->command );
|
737
|
-
uint16_t idle_timeout = ntohs( flow_mod->idle_timeout );
|
738
|
-
uint16_t hard_timeout = ntohs( flow_mod->hard_timeout );
|
739
|
-
uint16_t priority = ntohs( flow_mod->priority );
|
740
|
-
uint32_t buffer_id = ntohl( flow_mod->buffer_id );
|
741
|
-
uint16_t out_port = ntohs( flow_mod->out_port );
|
742
|
-
uint16_t flags = ntohs( flow_mod->flags );
|
743
|
-
|
744
|
-
size_t actions_length = ntohs( flow_mod->header.length ) - offsetof( struct ofp_flow_mod, actions );
|
745
|
-
openflow_actions *actions = NULL;
|
746
|
-
if ( actions_length > 0 ) {
|
747
|
-
actions = create_actions();
|
748
|
-
void *actions_p = flow_mod->actions;
|
749
|
-
while ( actions_length > 0 ) {
|
750
|
-
struct ofp_action_header *ah = actions_p;
|
751
|
-
ntoh_action( ah, ah );
|
752
|
-
actions_length -= ah->len;
|
753
|
-
actions_p = ( char * ) actions_p + ah->len;
|
754
|
-
|
755
|
-
void *action = xmalloc( ah->len );
|
756
|
-
memcpy( action, ah, ah->len );
|
757
|
-
append_to_tail( &actions->list, ( void * ) action );
|
758
|
-
actions->n_actions++;
|
759
|
-
}
|
760
|
-
}
|
761
|
-
|
762
|
-
if ( get_logging_level() >= LOG_DEBUG ) {
|
763
|
-
char match_str[ 256 ];
|
764
|
-
match_to_string( &match, match_str, sizeof( match_str ) );
|
765
|
-
debug( "A flow modification is received ( transaction_id = %#x, match = [%s], cookie = %#" PRIx64 ", "
|
766
|
-
"command = %#x, idle_timeout = %u, hard_timeout = %u, priority = %u, buffer_id = %#x, "
|
767
|
-
"out_port = %u, flags = %#x ).",
|
768
|
-
transaction_id, match_str, cookie, command, idle_timeout, hard_timeout, priority, buffer_id,
|
769
|
-
out_port, flags );
|
770
|
-
}
|
771
|
-
|
772
|
-
if ( event_handlers.flow_mod_callback == NULL ) {
|
773
|
-
debug( "Callback function for flow modification events is not set." );
|
774
|
-
return;
|
775
|
-
}
|
776
|
-
|
777
|
-
debug( "Calling flow modification handler ( callback = %p, user_data = %p ).",
|
778
|
-
event_handlers.flow_mod_callback,
|
779
|
-
event_handlers.flow_mod_user_data );
|
780
|
-
|
781
|
-
event_handlers.flow_mod_callback( transaction_id, match, cookie, command, idle_timeout, hard_timeout,
|
782
|
-
priority, buffer_id, out_port, flags, actions,
|
783
|
-
event_handlers.flow_mod_user_data );
|
784
|
-
|
785
|
-
if ( actions != NULL ) {
|
786
|
-
delete_actions( actions );
|
787
|
-
}
|
788
|
-
}
|
789
|
-
|
790
|
-
|
791
|
-
static void
|
792
|
-
handle_port_mod( buffer *data ) {
|
793
|
-
assert( empty( data ) == false );
|
794
|
-
|
795
|
-
struct ofp_port_mod *port_mod = data->data;
|
796
|
-
|
797
|
-
uint32_t transaction_id = ntohl( port_mod->header.xid );
|
798
|
-
uint16_t port_no = ntohs( port_mod->port_no );
|
799
|
-
uint8_t hw_addr[ OFP_ETH_ALEN ];
|
800
|
-
memcpy( hw_addr, port_mod->hw_addr, OFP_ETH_ALEN );
|
801
|
-
uint32_t config = ntohl( port_mod->config );
|
802
|
-
uint32_t mask = ntohl( port_mod->mask );
|
803
|
-
uint32_t advertise = ntohl( port_mod->advertise );
|
804
|
-
|
805
|
-
debug( "A port modification is received ( transaction_id = %#x, port_no = %u, "
|
806
|
-
"hw_addr = %02x:%02x:%02x:%02x:%02x:%02x, config = %#x, mask = %#x, advertise = %#x ).",
|
807
|
-
transaction_id, port_no,
|
808
|
-
hw_addr[ 0 ], hw_addr[ 1 ], hw_addr[ 2 ], hw_addr[ 3 ], hw_addr[ 4 ], hw_addr[ 5 ],
|
809
|
-
config, mask, advertise );
|
810
|
-
|
811
|
-
if ( event_handlers.port_mod_callback == NULL ) {
|
812
|
-
debug( "Callback function for port modification events is not set." );
|
813
|
-
return;
|
814
|
-
}
|
815
|
-
|
816
|
-
debug( "Calling port modification handler ( callback = %p, user_data = %p ).",
|
817
|
-
event_handlers.port_mod_callback,
|
818
|
-
event_handlers.port_mod_user_data );
|
819
|
-
|
820
|
-
event_handlers.port_mod_callback( transaction_id, port_no, hw_addr, config, mask, advertise,
|
821
|
-
event_handlers.port_mod_user_data );
|
822
|
-
|
823
|
-
}
|
824
|
-
|
825
|
-
|
826
|
-
static void
|
827
|
-
handle_stats_request( buffer *data ) {
|
828
|
-
assert( empty( data ) == false );
|
829
|
-
|
830
|
-
struct ofp_stats_request *stats_request = data->data;
|
831
|
-
|
832
|
-
uint32_t transaction_id = ntohl( stats_request->header.xid );
|
833
|
-
uint16_t type = ntohs( stats_request->type );
|
834
|
-
uint16_t flags = ntohs( stats_request->flags );
|
835
|
-
|
836
|
-
size_t body_length = ntohs( stats_request->header.length ) - offsetof( struct ofp_stats_request, body );
|
837
|
-
buffer *body = NULL;
|
838
|
-
if ( body_length > 0 ) {
|
839
|
-
body = alloc_buffer_with_length( body_length );
|
840
|
-
void *p = append_back_buffer( body, body_length );
|
841
|
-
memcpy( p, stats_request->body, body_length );
|
842
|
-
|
843
|
-
switch ( type ) {
|
844
|
-
case OFPST_FLOW:
|
845
|
-
{
|
846
|
-
struct ofp_flow_stats_request *flow = p;
|
847
|
-
ntoh_match( &flow->match, &flow->match );
|
848
|
-
flow->out_port = ntohs( flow->out_port );
|
849
|
-
}
|
850
|
-
break;
|
851
|
-
|
852
|
-
case OFPST_AGGREGATE:
|
853
|
-
{
|
854
|
-
struct ofp_aggregate_stats_request *aggregate = p;
|
855
|
-
ntoh_match( &aggregate->match, &aggregate->match );
|
856
|
-
aggregate->out_port = ntohs( aggregate->out_port );
|
857
|
-
}
|
858
|
-
break;
|
859
|
-
|
860
|
-
case OFPST_PORT:
|
861
|
-
{
|
862
|
-
struct ofp_port_stats_request *port = p;
|
863
|
-
port->port_no = ntohs( port->port_no );
|
864
|
-
}
|
865
|
-
break;
|
866
|
-
|
867
|
-
case OFPST_VENDOR:
|
868
|
-
{
|
869
|
-
uint32_t *vendor_id = p;
|
870
|
-
*vendor_id = ntohl( *vendor_id );
|
871
|
-
}
|
872
|
-
break;
|
873
|
-
|
874
|
-
default:
|
875
|
-
break;
|
876
|
-
}
|
877
|
-
}
|
878
|
-
|
879
|
-
debug( "A stats request is received ( transaction_id = %#x, type = %#x, flags = %#x ).",
|
880
|
-
transaction_id, type, flags );
|
881
|
-
|
882
|
-
if ( event_handlers.stats_request_callback == NULL ) {
|
883
|
-
debug( "Callback function for stats request events is not set." );
|
884
|
-
return;
|
885
|
-
}
|
886
|
-
|
887
|
-
debug( "Calling stats request handler ( callback = %p, user_data = %p ).",
|
888
|
-
event_handlers.stats_request_callback,
|
889
|
-
event_handlers.stats_request_user_data );
|
890
|
-
|
891
|
-
event_handlers.stats_request_callback( transaction_id, type, flags, body,
|
892
|
-
event_handlers.stats_request_user_data );
|
893
|
-
|
894
|
-
if ( body_length > 0 && body != NULL ) {
|
895
|
-
free_buffer( body );
|
896
|
-
}
|
897
|
-
}
|
898
|
-
|
899
|
-
|
900
|
-
static void
|
901
|
-
handle_barrier_request( buffer *data ) {
|
902
|
-
assert( empty( data ) == false );
|
903
|
-
|
904
|
-
struct ofp_header *header = data->data;
|
905
|
-
|
906
|
-
uint32_t transaction_id = ntohl( header->xid );
|
907
|
-
|
908
|
-
debug( "A barrier request is received ( transaction_id = %#x ).", transaction_id );
|
909
|
-
|
910
|
-
if ( event_handlers.barrier_request_callback == NULL ) {
|
911
|
-
debug( "Callback function for barrier request events is not set." );
|
912
|
-
return;
|
913
|
-
}
|
914
|
-
|
915
|
-
debug( "Calling barrier request handler ( callback = %p, user_data = %p ).",
|
916
|
-
event_handlers.barrier_request_callback,
|
917
|
-
event_handlers.barrier_request_user_data );
|
918
|
-
|
919
|
-
event_handlers.barrier_request_callback( transaction_id,
|
920
|
-
event_handlers.barrier_request_user_data );
|
921
|
-
}
|
922
|
-
|
923
|
-
|
924
|
-
static void
|
925
|
-
handle_queue_get_config_request( buffer *data ) {
|
926
|
-
assert( empty( data ) == false );
|
927
|
-
|
928
|
-
struct ofp_queue_get_config_request *queue_get_config_request = data->data;
|
929
|
-
|
930
|
-
uint32_t transaction_id = ntohl( queue_get_config_request->header.xid );
|
931
|
-
uint16_t port = ntohs( queue_get_config_request->port );
|
932
|
-
|
933
|
-
debug( "A queue get config request is received ( transaction_id = %#x, port = %u ).",
|
934
|
-
transaction_id, port );
|
935
|
-
|
936
|
-
if ( event_handlers.queue_get_config_request_callback == NULL ) {
|
937
|
-
debug( "Callback function for queue get config request events is not set." );
|
938
|
-
return;
|
939
|
-
}
|
940
|
-
|
941
|
-
debug( "Calling queue get config request handler ( callback = %p, user_data = %p ).",
|
942
|
-
event_handlers.queue_get_config_request_callback,
|
943
|
-
event_handlers.queue_get_config_request_user_data );
|
944
|
-
|
945
|
-
event_handlers.queue_get_config_request_callback( transaction_id, port,
|
946
|
-
event_handlers.queue_get_config_request_user_data );
|
947
|
-
}
|
948
|
-
|
949
|
-
|
950
|
-
static void
|
951
|
-
handle_controller_connected() {
|
952
|
-
if ( event_handlers.controller_connected_callback == NULL ) {
|
953
|
-
debug( "Callback function for controller connected events is not set." );
|
954
|
-
return;
|
955
|
-
}
|
956
|
-
|
957
|
-
event_handlers.controller_connected_callback( event_handlers.controller_connected_user_data );
|
958
|
-
}
|
959
|
-
|
960
|
-
|
961
|
-
static void
|
962
|
-
handle_controller_disconnected() {
|
963
|
-
if ( event_handlers.controller_disconnected_callback == NULL ) {
|
964
|
-
debug( "Callback function for controller disconnected events is not set." );
|
965
|
-
return;
|
966
|
-
}
|
967
|
-
|
968
|
-
event_handlers.controller_disconnected_callback( event_handlers.controller_disconnected_user_data );
|
969
|
-
}
|
970
|
-
|
971
|
-
|
972
|
-
static bool
|
973
|
-
handle_openflow_message( buffer *message ) {
|
974
|
-
debug( "An OpenFlow message is received from remote." );
|
975
|
-
|
976
|
-
assert( message != NULL );
|
977
|
-
assert( message->length >= sizeof( struct ofp_header ) );
|
978
|
-
|
979
|
-
int ret = validate_openflow_message( message );
|
980
|
-
if ( ret < 0 ) {
|
981
|
-
error( "Failed to validate an OpenFlow message ( code = %d, length = %zu ).", ret, message->length );
|
982
|
-
return false;
|
983
|
-
}
|
984
|
-
|
985
|
-
ret = true;
|
986
|
-
struct ofp_header *header = ( struct ofp_header * ) message->data;
|
987
|
-
|
988
|
-
switch ( header->type ) {
|
989
|
-
case OFPT_HELLO:
|
990
|
-
handle_hello( message );
|
991
|
-
break;
|
992
|
-
case OFPT_ERROR:
|
993
|
-
handle_error( message );
|
994
|
-
break;
|
995
|
-
case OFPT_ECHO_REQUEST:
|
996
|
-
handle_echo_request( message );
|
997
|
-
break;
|
998
|
-
case OFPT_ECHO_REPLY:
|
999
|
-
handle_echo_reply( message );
|
1000
|
-
break;
|
1001
|
-
case OFPT_VENDOR:
|
1002
|
-
handle_vendor( message);
|
1003
|
-
break;
|
1004
|
-
case OFPT_FEATURES_REQUEST:
|
1005
|
-
handle_features_request( message );
|
1006
|
-
break;
|
1007
|
-
case OFPT_GET_CONFIG_REQUEST:
|
1008
|
-
handle_get_config_request( message );
|
1009
|
-
break;
|
1010
|
-
case OFPT_SET_CONFIG:
|
1011
|
-
handle_set_config( message );
|
1012
|
-
break;
|
1013
|
-
case OFPT_PACKET_OUT:
|
1014
|
-
handle_packet_out( message );
|
1015
|
-
break;
|
1016
|
-
case OFPT_FLOW_MOD:
|
1017
|
-
handle_flow_mod( message );
|
1018
|
-
break;
|
1019
|
-
case OFPT_PORT_MOD:
|
1020
|
-
handle_port_mod( message );
|
1021
|
-
break;
|
1022
|
-
case OFPT_STATS_REQUEST:
|
1023
|
-
handle_stats_request( message );
|
1024
|
-
break;
|
1025
|
-
case OFPT_BARRIER_REQUEST:
|
1026
|
-
handle_barrier_request( message );
|
1027
|
-
break;
|
1028
|
-
case OFPT_QUEUE_GET_CONFIG_REQUEST:
|
1029
|
-
handle_queue_get_config_request( message );
|
1030
|
-
break;
|
1031
|
-
default:
|
1032
|
-
error( "Unhandled OpenFlow message ( type = %#x ).", header->type );
|
1033
|
-
ret = false;
|
1034
|
-
break;
|
1035
|
-
}
|
1036
|
-
|
1037
|
-
return ret;
|
1038
|
-
}
|
1039
|
-
|
1040
|
-
|
1041
|
-
static bool
|
1042
|
-
send_openflow_message_to_secure_channel( buffer *message, void *user_data ) {
|
1043
|
-
assert( user_data == NULL );
|
1044
|
-
|
1045
|
-
return send_message_to_secure_channel( message );
|
1046
|
-
}
|
1047
|
-
|
1048
|
-
|
1049
|
-
static bool
|
1050
|
-
send_openflow_message_to_local( buffer *message, void *user_data ) {
|
1051
|
-
char *service_name = user_data;
|
1052
|
-
size_t service_name_length = strlen( service_name ) + 1;
|
1053
|
-
size_t service_header_length = sizeof( openflow_service_header_t ) + service_name_length;
|
1054
|
-
openflow_service_header_t *service_header = append_front_buffer( message, service_header_length );
|
1055
|
-
service_header->service_name_length = htons( ( uint16_t ) service_name_length );
|
1056
|
-
memcpy( ( char * ) service_header + sizeof( openflow_service_header_t ), service_name, service_name_length );
|
1057
|
-
|
1058
|
-
return send_message( service_name, MESSENGER_OPENFLOW_MESSAGE, message->data, message->length );
|
1059
|
-
}
|
1060
|
-
|
1061
|
-
|
1062
|
-
bool
|
1063
|
-
switch_send_openflow_message( buffer *message ) {
|
1064
|
-
assert( message != NULL );
|
1065
|
-
assert( message->length >= sizeof( struct ofp_header ) );
|
1066
|
-
|
1067
|
-
struct ofp_header *header = message->data;
|
1068
|
-
uint32_t transaction_id = ntohl( header->xid );
|
1069
|
-
openflow_context *context = lookup_context( transaction_id );
|
1070
|
-
if ( context != NULL ) {
|
1071
|
-
assert( context->send_callback != NULL );
|
1072
|
-
return context->send_callback( message, context->user_data );
|
1073
|
-
}
|
1074
|
-
|
1075
|
-
return send_openflow_message_to_secure_channel( message, NULL );
|
1076
|
-
}
|
1077
|
-
|
1078
|
-
|
1079
|
-
bool
|
1080
|
-
handle_secure_channel_message( buffer *message ) {
|
1081
|
-
debug( "An OpenFlow message is received from remote." );
|
1082
|
-
|
1083
|
-
assert( message != NULL );
|
1084
|
-
assert( message->length >= sizeof( struct ofp_header ) );
|
1085
|
-
|
1086
|
-
struct ofp_header *header = message->data;
|
1087
|
-
|
1088
|
-
save_context( ntohl( header->xid ), message, send_openflow_message_to_secure_channel, NULL );
|
1089
|
-
|
1090
|
-
return handle_openflow_message( message );
|
1091
|
-
}
|
1092
|
-
|
1093
|
-
|
1094
|
-
static void
|
1095
|
-
handle_local_message( uint16_t tag, void *data, size_t length ) {
|
1096
|
-
assert( data != NULL );
|
1097
|
-
assert( length >= sizeof( openflow_service_header_t ) );
|
1098
|
-
|
1099
|
-
debug( "A message is received from remote ( tag = %#x, data = %p, length = %zu ).", tag, data, length );
|
1100
|
-
|
1101
|
-
switch ( tag ) {
|
1102
|
-
case MESSENGER_OPENFLOW_MESSAGE:
|
1103
|
-
{
|
1104
|
-
openflow_service_header_t *header = data;
|
1105
|
-
uint16_t service_name_length = ntohs( header->service_name_length );
|
1106
|
-
size_t ofp_offset = sizeof( openflow_service_header_t ) + service_name_length;
|
1107
|
-
size_t ofp_length = length - ofp_offset;
|
1108
|
-
buffer *message = alloc_buffer_with_length( ofp_length );
|
1109
|
-
char *p = append_back_buffer( message, ofp_length );
|
1110
|
-
memcpy( p, ( char * ) data + ofp_offset, ofp_length );
|
1111
|
-
char *service_name = strndup( ( char * ) data + sizeof( openflow_service_header_t ), service_name_length );
|
1112
|
-
|
1113
|
-
save_context( ntohl( ( ( struct ofp_header * ) p )->xid ), message, send_openflow_message_to_local,
|
1114
|
-
service_name );
|
1115
|
-
|
1116
|
-
handle_openflow_message( message );
|
1117
|
-
}
|
1118
|
-
break;
|
1119
|
-
default:
|
1120
|
-
break;
|
1121
|
-
}
|
1122
|
-
}
|
1123
|
-
|
1124
|
-
|
1125
|
-
bool
|
1126
|
-
init_openflow_switch_interface( const uint64_t datapath_id, uint32_t controller_ip, uint16_t controller_port ) {
|
1127
|
-
debug( "Initializing OpenFlow Switch Interface ( datapath_id = %#" PRIx64 ", controller_ip = %#x, controller_port = %u ).",
|
1128
|
-
datapath_id, controller_ip, controller_port );
|
1129
|
-
|
1130
|
-
if ( openflow_switch_interface_is_initialized() ) {
|
1131
|
-
error( "OpenFlow Switch Interface is already initialized." );
|
1132
|
-
return false;
|
1133
|
-
}
|
1134
|
-
|
1135
|
-
bool ret = init_secure_channel( controller_ip, controller_port,
|
1136
|
-
handle_controller_connected, handle_controller_disconnected );
|
1137
|
-
if ( ret == false ) {
|
1138
|
-
error( "Failed to initialize a secure chanel." );
|
1139
|
-
return false;
|
1140
|
-
}
|
1141
|
-
|
1142
|
-
|
1143
|
-
memset( &event_handlers, 0, sizeof( openflow_event_handlers ) );
|
1144
|
-
memset( &config, 0, sizeof( openflow_switch_config ) );
|
1145
|
-
|
1146
|
-
config.datapath_id = datapath_id;
|
1147
|
-
config.controller.ip = controller_ip;
|
1148
|
-
config.controller.port = controller_port;
|
1149
|
-
|
1150
|
-
init_context();
|
1151
|
-
|
1152
|
-
add_periodic_event_callback( 5, age_contexts, NULL );
|
1153
|
-
add_message_received_callback( get_chibach_name(), handle_local_message );
|
1154
|
-
|
1155
|
-
openflow_switch_interface_initialized = true;
|
1156
|
-
|
1157
|
-
return true;
|
1158
|
-
}
|
1159
|
-
|
1160
|
-
|
1161
|
-
bool
|
1162
|
-
finalize_openflow_switch_interface() {
|
1163
|
-
if ( !openflow_switch_interface_is_initialized() ) {
|
1164
|
-
error( "OpenFlow Switch Interface is not initialized." );
|
1165
|
-
return false;
|
1166
|
-
}
|
1167
|
-
|
1168
|
-
finalize_secure_channel();
|
1169
|
-
|
1170
|
-
delete_timer_event( age_contexts, NULL );
|
1171
|
-
finalize_context();
|
1172
|
-
|
1173
|
-
openflow_switch_interface_initialized = false;
|
1174
|
-
|
1175
|
-
return true;
|
1176
|
-
}
|
1177
|
-
|
1178
|
-
|
1179
|
-
static const buffer *
|
1180
|
-
get_openflow_message( uint32_t transaction_id ) {
|
1181
|
-
openflow_context *context = lookup_context( transaction_id );
|
1182
|
-
if ( context == NULL ) {
|
1183
|
-
return NULL;
|
1184
|
-
}
|
1185
|
-
|
1186
|
-
return context->message;
|
1187
|
-
}
|
1188
|
-
|
1189
|
-
|
1190
|
-
bool
|
1191
|
-
send_error_message( uint32_t transaction_id, uint16_t type, uint16_t code ) {
|
1192
|
-
buffer *data = NULL;
|
1193
|
-
switch ( type ) {
|
1194
|
-
case OFPET_HELLO_FAILED:
|
1195
|
-
{
|
1196
|
-
switch ( code ) {
|
1197
|
-
case OFPHFC_INCOMPATIBLE:
|
1198
|
-
{
|
1199
|
-
const char *description = "Incompatible OpenFlow version.";
|
1200
|
-
size_t length = strlen( description ) + 1;
|
1201
|
-
data = alloc_buffer_with_length ( length );
|
1202
|
-
void *p = append_back_buffer( data, length );
|
1203
|
-
strncpy( p, description, length );
|
1204
|
-
}
|
1205
|
-
break;
|
1206
|
-
case OFPHFC_EPERM:
|
1207
|
-
{
|
1208
|
-
const char *description = "Permissions error.";
|
1209
|
-
size_t length = strlen( description ) + 1;
|
1210
|
-
data = alloc_buffer_with_length ( length );
|
1211
|
-
void *p = append_back_buffer( data, length );
|
1212
|
-
strncpy( p, description, length );
|
1213
|
-
}
|
1214
|
-
break;
|
1215
|
-
default:
|
1216
|
-
error( "Undefined error code ( type = %#x, code = %#x ).", type, code );
|
1217
|
-
return false;
|
1218
|
-
}
|
1219
|
-
}
|
1220
|
-
break;
|
1221
|
-
|
1222
|
-
case OFPET_BAD_REQUEST:
|
1223
|
-
{
|
1224
|
-
switch ( code ) {
|
1225
|
-
case OFPBRC_BAD_VERSION:
|
1226
|
-
case OFPBRC_BAD_TYPE:
|
1227
|
-
case OFPBRC_BAD_STAT:
|
1228
|
-
case OFPBRC_BAD_VENDOR:
|
1229
|
-
case OFPBRC_BAD_SUBTYPE:
|
1230
|
-
case OFPBRC_EPERM:
|
1231
|
-
case OFPBRC_BAD_LEN:
|
1232
|
-
case OFPBRC_BUFFER_EMPTY:
|
1233
|
-
case OFPBRC_BUFFER_UNKNOWN:
|
1234
|
-
{
|
1235
|
-
const buffer *original_message = get_openflow_message( transaction_id );
|
1236
|
-
if ( original_message != NULL ) {
|
1237
|
-
data = duplicate_buffer( original_message );
|
1238
|
-
if ( data->length > 64 ) {
|
1239
|
-
data->length = 64;
|
1240
|
-
}
|
1241
|
-
}
|
1242
|
-
}
|
1243
|
-
break;
|
1244
|
-
default:
|
1245
|
-
error( "Undefined error code ( type = %#x, code = %#x ).", type, code );
|
1246
|
-
return false;
|
1247
|
-
}
|
1248
|
-
}
|
1249
|
-
break;
|
1250
|
-
|
1251
|
-
case OFPET_BAD_ACTION:
|
1252
|
-
{
|
1253
|
-
switch ( code ) {
|
1254
|
-
case OFPBAC_BAD_TYPE:
|
1255
|
-
case OFPBAC_BAD_LEN:
|
1256
|
-
case OFPBAC_BAD_VENDOR:
|
1257
|
-
case OFPBAC_BAD_VENDOR_TYPE:
|
1258
|
-
case OFPBAC_BAD_OUT_PORT:
|
1259
|
-
case OFPBAC_BAD_ARGUMENT:
|
1260
|
-
case OFPBAC_EPERM:
|
1261
|
-
case OFPBAC_TOO_MANY:
|
1262
|
-
case OFPBAC_BAD_QUEUE:
|
1263
|
-
{
|
1264
|
-
const buffer *original_message = get_openflow_message( transaction_id );
|
1265
|
-
if ( original_message != NULL ) {
|
1266
|
-
data = duplicate_buffer( original_message );
|
1267
|
-
if ( data->length > 64 ) {
|
1268
|
-
data->length = 64;
|
1269
|
-
}
|
1270
|
-
}
|
1271
|
-
}
|
1272
|
-
break;
|
1273
|
-
default:
|
1274
|
-
error( "Undefined error code ( type = %#x, code = %#x ).", type, code );
|
1275
|
-
return false;
|
1276
|
-
}
|
1277
|
-
|
1278
|
-
}
|
1279
|
-
break;
|
1280
|
-
|
1281
|
-
case OFPET_FLOW_MOD_FAILED:
|
1282
|
-
{
|
1283
|
-
switch ( code ) {
|
1284
|
-
case OFPFMFC_ALL_TABLES_FULL:
|
1285
|
-
case OFPFMFC_OVERLAP:
|
1286
|
-
case OFPFMFC_EPERM:
|
1287
|
-
case OFPFMFC_BAD_EMERG_TIMEOUT:
|
1288
|
-
case OFPFMFC_BAD_COMMAND:
|
1289
|
-
case OFPFMFC_UNSUPPORTED:
|
1290
|
-
{
|
1291
|
-
const buffer *original_message = get_openflow_message( transaction_id );
|
1292
|
-
if ( original_message != NULL ) {
|
1293
|
-
data = duplicate_buffer( original_message );
|
1294
|
-
if ( data->length > 64 ) {
|
1295
|
-
data->length = 64;
|
1296
|
-
}
|
1297
|
-
}
|
1298
|
-
}
|
1299
|
-
break;
|
1300
|
-
default:
|
1301
|
-
error( "Undefined error code ( type = %#x, code = %#x ).", type, code );
|
1302
|
-
return false;
|
1303
|
-
}
|
1304
|
-
}
|
1305
|
-
break;
|
1306
|
-
|
1307
|
-
case OFPET_PORT_MOD_FAILED:
|
1308
|
-
{
|
1309
|
-
switch ( code ) {
|
1310
|
-
case OFPPMFC_BAD_PORT:
|
1311
|
-
case OFPPMFC_BAD_HW_ADDR:
|
1312
|
-
{
|
1313
|
-
const buffer *original_message = get_openflow_message( transaction_id );
|
1314
|
-
if ( original_message != NULL ) {
|
1315
|
-
data = duplicate_buffer( original_message );
|
1316
|
-
if ( data->length > 64 ) {
|
1317
|
-
data->length = 64;
|
1318
|
-
}
|
1319
|
-
}
|
1320
|
-
}
|
1321
|
-
break;
|
1322
|
-
default:
|
1323
|
-
error( "Undefined error code ( type = %#x, code = %#x ).", type, code );
|
1324
|
-
return false;
|
1325
|
-
}
|
1326
|
-
}
|
1327
|
-
break;
|
1328
|
-
|
1329
|
-
case OFPET_QUEUE_OP_FAILED:
|
1330
|
-
{
|
1331
|
-
switch ( code ) {
|
1332
|
-
case OFPQOFC_BAD_PORT:
|
1333
|
-
case OFPQOFC_BAD_QUEUE:
|
1334
|
-
case OFPQOFC_EPERM:
|
1335
|
-
{
|
1336
|
-
const buffer *original_message = get_openflow_message( transaction_id );
|
1337
|
-
if ( original_message != NULL ) {
|
1338
|
-
data = duplicate_buffer( original_message );
|
1339
|
-
if ( data->length > 64 ) {
|
1340
|
-
data->length = 64;
|
1341
|
-
}
|
1342
|
-
}
|
1343
|
-
}
|
1344
|
-
break;
|
1345
|
-
default:
|
1346
|
-
error( "Undefined error code ( type = %#x, code = %#x ).", type, code );
|
1347
|
-
return false;
|
1348
|
-
}
|
1349
|
-
}
|
1350
|
-
break;
|
1351
|
-
|
1352
|
-
default:
|
1353
|
-
error( "Undefined error type ( type = %#x, code = %#x ).", type, code );
|
1354
|
-
return false;
|
1355
|
-
}
|
1356
|
-
|
1357
|
-
buffer *err = create_error( transaction_id, type, code, data );
|
1358
|
-
bool ret = switch_send_openflow_message( err );
|
1359
|
-
if ( !ret ) {
|
1360
|
-
error( "Failed to send an error message ( transaction_id = %#x, type = %#x, code = %#x ).",
|
1361
|
-
transaction_id, type, code );
|
1362
|
-
}
|
1363
|
-
|
1364
|
-
free_buffer( err );
|
1365
|
-
if ( data != NULL ) {
|
1366
|
-
free_buffer( data );
|
1367
|
-
}
|
1368
|
-
|
1369
|
-
return ret;
|
1370
|
-
}
|
1371
|
-
|
1372
|
-
|
1373
|
-
/*
|
1374
|
-
* Local variables:
|
1375
|
-
* c-basic-offset: 2
|
1376
|
-
* indent-tabs-mode: nil
|
1377
|
-
* End:
|
1378
|
-
*/
|