trema 0.2.2.1 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitmodules +3 -0
- data/.travis.yml +13 -0
- data/.yardopts +4 -0
- data/Gemfile +2 -3
- data/README.md +43 -97
- data/Rakefile +60 -4
- data/Rantfile +11 -10
- data/cruise.rb +4 -6
- data/features/example.packetin_filter_config.feature +10 -10
- data/features/example.switch_monitor.feature +14 -2
- data/features/step_definitions/kill_steps.rb +2 -2
- data/features/step_definitions/{off_steps.rb → killall_steps.rb} +2 -2
- data/features/step_definitions/misc_steps.rb +1 -1
- data/features/step_definitions/up_steps.rb +30 -0
- data/features/trema.feature +1 -0
- data/features/trema.run.feature +1 -0
- data/locale/README.ja.md +19 -0
- data/locale/ja/yard.po +3762 -0
- data/locale/yard.pot +3740 -0
- data/ruby/extconf.rb +4 -1
- data/ruby/trema/action-common.c +3 -17
- data/ruby/trema/action-common.h +3 -7
- data/ruby/trema/action.rb +33 -0
- data/ruby/trema/app.rb +1 -1
- data/ruby/trema/barrier-request.c +1 -0
- data/ruby/trema/command/run.rb +13 -9
- data/ruby/trema/command/usage.rb +1 -0
- data/ruby/trema/command/version.rb +1 -1
- data/ruby/trema/controller.c +133 -50
- data/ruby/trema/controller.rb +2 -2
- data/ruby/trema/desc-stats-reply.rb +77 -0
- data/ruby/trema/dsl/configuration.rb +3 -14
- data/ruby/trema/dsl/rswitch.rb +47 -0
- data/ruby/trema/dsl/runner.rb +4 -1
- data/ruby/trema/dsl/syntax.rb +11 -8
- data/ruby/trema/echo-reply.c +59 -45
- data/ruby/trema/echo-reply.h +1 -3
- data/ruby/trema/echo-request.c +49 -71
- data/ruby/trema/echo-request.h +0 -2
- data/ruby/trema/echo.c +99 -0
- data/ruby/trema/{action-enqueue.h → echo.h} +6 -7
- data/ruby/trema/enqueue.rb +87 -0
- data/ruby/trema/error.c +109 -104
- data/ruby/trema/error.h +0 -2
- data/ruby/trema/features-reply.c +89 -35
- data/ruby/trema/features-reply.h +0 -6
- data/ruby/trema/features-request.c +63 -37
- data/ruby/trema/features-request.h +0 -2
- data/ruby/trema/flow-mod.c +149 -0
- data/ruby/trema/{action-output.h → flow-mod.h} +6 -6
- data/ruby/trema/get-config-request.c +1 -0
- data/ruby/trema/hardware-switch.rb +88 -0
- data/ruby/trema/hello.c +55 -31
- data/ruby/trema/hello.h +0 -2
- data/ruby/trema/ip.rb +12 -2
- data/ruby/trema/logger.rb +29 -0
- data/ruby/trema/mac.rb +57 -36
- data/ruby/trema/match.c +7 -9
- data/ruby/trema/monkey-patch/integer/ranges.rb +0 -2
- data/ruby/trema/network-component.rb +1 -1
- data/ruby/trema/open-vswitch.rb +2 -2
- data/ruby/trema/openflow-switch.rb +3 -54
- data/ruby/trema/{packet_in.c → packet-in.c} +262 -175
- data/ruby/trema/{packet_in.h → packet-in.h} +0 -2
- data/ruby/trema/packet-queue.rb +4 -3
- data/ruby/trema/port-mod.c +8 -9
- data/ruby/trema/port-status-add.rb +60 -0
- data/ruby/trema/port-status-delete.rb +60 -0
- data/ruby/trema/port-status-modify.rb +60 -0
- data/ruby/trema/port-status.c +48 -15
- data/ruby/trema/port-status.h +6 -8
- data/ruby/trema/port.c +63 -8
- data/ruby/trema/queue-get-config-request.c +1 -0
- data/ruby/trema/ruby-switch.rb +62 -0
- data/ruby/trema/send-out-port.rb +97 -0
- data/ruby/trema/set-config.c +1 -0
- data/ruby/trema/set-eth-addr.rb +45 -0
- data/ruby/trema/set-eth-dst-addr.rb +54 -0
- data/ruby/trema/set-eth-src-addr.rb +54 -0
- data/ruby/trema/set-ip-addr.rb +47 -0
- data/ruby/trema/set-ip-dst-addr.rb +53 -0
- data/ruby/trema/set-ip-src-addr.rb +52 -0
- data/ruby/trema/set-ip-tos.rb +63 -0
- data/ruby/trema/set-transport-dst-port.rb +53 -0
- data/ruby/trema/set-transport-port.rb +52 -0
- data/ruby/trema/set-transport-src-port.rb +54 -0
- data/ruby/trema/set-vlan-priority.rb +65 -0
- data/ruby/trema/set-vlan-vid.rb +64 -0
- data/ruby/trema/shell/down.rb +1 -1
- data/ruby/trema/shell/link.rb +4 -4
- data/ruby/trema/shell/run.rb +8 -6
- data/ruby/trema/shell/up.rb +3 -3
- data/ruby/trema/stats-reply.c +27 -2
- data/ruby/trema/stats-request.c +64 -23
- data/ruby/trema/strip-vlan-header.rb +41 -0
- data/ruby/trema/switch.c +196 -0
- data/ruby/trema/{action-vendor.h → switch.h} +5 -7
- data/ruby/trema/switch.rb +28 -9
- data/ruby/trema/trema-ruby-utils.c +66 -0
- data/ruby/trema/{action-set-dl-src.h → trema-ruby-utils.h} +9 -11
- data/ruby/trema/trema.c +61 -61
- data/ruby/trema/vendor-action.rb +73 -0
- data/ruby/trema/vendor.c +121 -52
- data/ruby/trema/vendor.h +6 -10
- data/ruby/trema/version.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/support/action.rb +52 -0
- data/spec/support/mandatory-option.rb +56 -0
- data/spec/support/openflow-message.rb +91 -7
- data/spec/support/port-status.rb +38 -0
- data/spec/trema/controller_spec.rb +0 -26
- data/spec/trema/dsl/configuration_spec.rb +3 -3
- data/spec/trema/dsl/runner_spec.rb +12 -32
- data/spec/trema/dsl/syntax_spec.rb +2 -11
- data/spec/trema/echo-reply_spec.rb +49 -14
- data/spec/trema/echo-request_spec.rb +86 -34
- data/spec/trema/enqueue_spec.rb +76 -0
- data/spec/trema/error_spec.rb +43 -58
- data/spec/trema/features-reply_spec.rb +58 -24
- data/spec/trema/features-request_spec.rb +54 -28
- data/spec/trema/flow-mod_spec.rb +99 -0
- data/spec/trema/{openflow-switch_spec.rb → hardware-switch_spec.rb} +3 -3
- data/spec/trema/hello_spec.rb +28 -14
- data/spec/trema/ip_spec.rb +54 -0
- data/spec/trema/mac_spec.rb +49 -64
- data/spec/trema/match_spec.rb +1 -1
- data/spec/trema/open-vswitch_spec.rb +7 -7
- data/spec/trema/packet-in_spec.rb +73 -16
- data/spec/trema/port-status-add_spec.rb +32 -0
- data/spec/trema/port-status-delete_spec.rb +32 -0
- data/spec/trema/port-status-modify_spec.rb +71 -0
- data/spec/trema/port-status_spec.rb +5 -76
- data/spec/trema/{action-output_spec.rb → send-out-port_spec.rb} +20 -47
- data/spec/trema/set-eth-dst-addr_spec.rb +75 -0
- data/spec/trema/set-eth-src-addr_spec.rb +72 -0
- data/spec/trema/set-ip-dst-addr_spec.rb +58 -0
- data/spec/trema/set-ip-src-addr_spec.rb +58 -0
- data/spec/trema/set-ip-tos_spec.rb +65 -0
- data/spec/trema/set-transport-dst-port_spec.rb +65 -0
- data/spec/trema/set-transport-src-port_spec.rb +65 -0
- data/spec/trema/set-vlan-priority_spec.rb +65 -0
- data/spec/trema/set-vlan-vid_spec.rb +65 -0
- data/spec/trema/shell/vhost_spec.rb +4 -1
- data/spec/trema/shell/vswitch_spec.rb +11 -11
- data/spec/trema/stats-reply_spec.rb +59 -13
- data/spec/trema/stats-request_spec.rb +6 -0
- data/spec/trema/{action-strip-vlan_spec.rb → strip-vlan-header_spec.rb} +3 -17
- data/spec/trema/switch-daemon_spec.rb +39 -0
- data/spec/trema/vendor-action_spec.rb +81 -0
- data/spec/trema/vendor_spec.rb +76 -0
- data/spec/trema_spec.rb +56 -0
- data/src/examples/dumper/dumper.c +0 -8
- data/src/examples/dumper/dumper.rb +52 -52
- data/src/examples/hello_trema/hello_trema.c +0 -2
- data/src/examples/learning_switch/learning-switch.rb +3 -3
- data/src/examples/multi_learning_switch/multi-learning-switch.rb +3 -3
- data/src/examples/openflow_message/features-request.rb +3 -3
- data/src/examples/packetin_filter_config/utils.c +4 -4
- data/src/examples/repeater_hub/repeater-hub.rb +3 -3
- data/src/examples/switch_info/switch_info.rb +2 -2
- data/src/examples/switch_monitor/switch_monitor.c +1 -1
- data/src/examples/traffic_monitor/traffic-monitor.rb +3 -3
- data/src/lib/arp.h +4 -1
- data/src/lib/chibach.c +391 -0
- data/src/lib/chibach.h +71 -0
- data/src/lib/chibach_private.c +170 -0
- data/src/lib/chibach_private.h +52 -0
- data/src/lib/ether.c +2 -1
- data/src/lib/ether.h +0 -1
- data/src/lib/ipv4.h +13 -14
- data/{ruby/trema/action-set-nw-src.h → src/lib/ipv6.h} +13 -9
- data/src/lib/log.c +161 -58
- data/src/lib/log.h +11 -16
- data/src/lib/messenger.c +36 -1
- data/src/lib/messenger.h +1 -0
- data/src/lib/openflow_application_interface.c +128 -28
- data/src/lib/openflow_application_interface.h +31 -6
- data/src/lib/openflow_message.c +2 -1
- data/src/lib/openflow_service_interface.h +1 -0
- data/src/lib/openflow_switch_interface.c +1380 -0
- data/src/lib/openflow_switch_interface.h +264 -0
- data/src/lib/packet_info.c +94 -11
- data/src/lib/packet_info.h +22 -3
- data/src/lib/packet_parser.c +38 -2
- data/src/lib/secure_channel.c +498 -0
- data/{ruby/trema/vendor-request.h → src/lib/secure_channel.h} +11 -10
- data/src/lib/tcp.h +0 -3
- data/src/lib/trema.c +38 -5
- data/{ruby/trema/action-set-nw-dst.h → src/lib/trema.hpp} +17 -8
- data/src/lib/trema_wrapper.c +5 -0
- data/src/lib/trema_wrapper.h +4 -0
- data/src/lib/utility.c +93 -4
- data/src/lib/utility.h +1 -0
- data/src/lib/wrapper.c +30 -7
- data/src/lib/wrapper.h +2 -0
- data/src/switch_manager/ofpmsg_recv.c +44 -30
- data/src/switch_manager/ofpmsg_send.c +40 -1
- data/src/switch_manager/ofpmsg_send.h +2 -0
- data/src/switch_manager/switch.c +153 -8
- data/src/switch_manager/switch.h +1 -0
- data/src/switch_manager/switchinfo.h +5 -0
- data/src/tremashark/README +2 -2
- data/src/tremashark/plugin/packet-trema/packet-trema.c +1 -0
- data/trema +1 -1
- data/unittests/lib/log_test.c +158 -34
- data/unittests/lib/openflow_application_interface_test.c +252 -69
- data/unittests/lib/openflow_message_test.c +3 -1
- data/unittests/lib/packet_parser_test.c +60 -15
- 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/trema_test.c +2 -0
- data/unittests/lib/utility_test.c +65 -2
- data/unittests/lib/wrapper_test.c +29 -0
- data/vendor/{README → README.md} +2 -12
- data/vendor/packet-openflow.diff +13 -0
- metadata +86 -53
- data/GPL2 +0 -339
- data/ruby/trema/action-enqueue.c +0 -161
- data/ruby/trema/action-output.c +0 -169
- data/ruby/trema/action-set-dl-dst.c +0 -131
- data/ruby/trema/action-set-dl-dst.h +0 -44
- data/ruby/trema/action-set-dl-src.c +0 -131
- data/ruby/trema/action-set-nw-dst.c +0 -135
- data/ruby/trema/action-set-nw-src.c +0 -140
- data/ruby/trema/action-set-nw-tos.c +0 -124
- data/ruby/trema/action-set-nw-tos.h +0 -42
- data/ruby/trema/action-set-tp-dst.c +0 -122
- data/ruby/trema/action-set-tp-dst.h +0 -42
- data/ruby/trema/action-set-tp-src.c +0 -124
- data/ruby/trema/action-set-tp-src.h +0 -42
- data/ruby/trema/action-set-vlan-pcp.c +0 -128
- data/ruby/trema/action-set-vlan-pcp.h +0 -42
- data/ruby/trema/action-set-vlan-vid.c +0 -125
- data/ruby/trema/action-set-vlan-vid.h +0 -42
- data/ruby/trema/action-strip-vlan.c +0 -81
- data/ruby/trema/action-strip-vlan.h +0 -42
- data/ruby/trema/action-vendor.c +0 -121
- data/ruby/trema/vendor-request.c +0 -193
- data/spec/trema/action-enqueue_spec.rb +0 -100
- data/spec/trema/action-set-dl-dst_spec.rb +0 -95
- data/spec/trema/action-set-dl-src_spec.rb +0 -92
- data/spec/trema/action-set-nw-dst_spec.rb +0 -96
- data/spec/trema/action-set-nw-src_spec.rb +0 -97
- data/spec/trema/action-set-nw-tos_spec.rb +0 -88
- data/spec/trema/action-set-tp-dst_spec.rb +0 -88
- data/spec/trema/action-set-tp-src_spec.rb +0 -88
- data/spec/trema/action-set-vlan-pcp_spec.rb +0 -91
- data/spec/trema/action-set-vlan-vid_spec.rb +0 -91
- data/spec/trema/action-vendor_spec.rb +0 -90
- data/spec/trema/vendor-request_spec.rb +0 -79
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* An OpenFlow switch interface library.
|
|
3
|
+
*
|
|
4
|
+
* Author: Yasunobu Chiba
|
|
5
|
+
*
|
|
6
|
+
* Copyright (C) 2008-2012 NEC Corporation
|
|
7
|
+
*
|
|
8
|
+
* This program is free software; you can redistribute it and/or modify
|
|
9
|
+
* it under the terms of the GNU General Public License, version 2, as
|
|
10
|
+
* published by the Free Software Foundation.
|
|
11
|
+
*
|
|
12
|
+
* This program is distributed in the hope that it will be useful,
|
|
13
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
+
* GNU General Public License for more details.
|
|
16
|
+
*
|
|
17
|
+
* You should have received a copy of the GNU General Public License along
|
|
18
|
+
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
19
|
+
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
#ifndef OPENFLOW_SWITCH_INTERFACE_H
|
|
24
|
+
#define OPENFLOW_SWITCH_INTERFACE_H
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
#include "bool.h"
|
|
28
|
+
#include "buffer.h"
|
|
29
|
+
#include "openflow.h"
|
|
30
|
+
#include "openflow_message.h"
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
/********************************************************************************
|
|
34
|
+
* Functions for initializing/finalizing the OpenFlow switch interface.
|
|
35
|
+
********************************************************************************/
|
|
36
|
+
|
|
37
|
+
bool init_openflow_switch_interface( const uint64_t datapath_id, uint32_t controller_ip, uint16_t controller_port );
|
|
38
|
+
bool finalize_openflow_switch_interface( void );
|
|
39
|
+
bool openflow_switch_interface_is_initialized( void );
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
/********************************************************************************
|
|
43
|
+
* Event handler definitions.
|
|
44
|
+
********************************************************************************/
|
|
45
|
+
|
|
46
|
+
typedef void ( *controller_connected_handler )(
|
|
47
|
+
void *user_data
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
typedef void ( *controller_disconnected_handler )(
|
|
52
|
+
void *user_data
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
typedef void ( *hello_handler )(
|
|
57
|
+
uint32_t transaction_id,
|
|
58
|
+
uint8_t version,
|
|
59
|
+
void *user_data
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
typedef void ( *error_handler )(
|
|
64
|
+
uint32_t transaction_id,
|
|
65
|
+
uint16_t type,
|
|
66
|
+
uint16_t code,
|
|
67
|
+
const buffer *data,
|
|
68
|
+
void *user_data
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
typedef void ( *echo_request_handler )(
|
|
73
|
+
uint32_t transaction_id,
|
|
74
|
+
const buffer *body,
|
|
75
|
+
void *user_data
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
typedef void ( *echo_reply_handler )(
|
|
80
|
+
uint32_t transaction_id,
|
|
81
|
+
const buffer *body,
|
|
82
|
+
void *user_data
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
typedef void ( *vendor_handler )(
|
|
87
|
+
uint32_t transaction_id,
|
|
88
|
+
uint32_t vendor,
|
|
89
|
+
const buffer *data,
|
|
90
|
+
void *user_data
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
typedef void ( *features_request_handler )(
|
|
95
|
+
uint32_t transaction_id,
|
|
96
|
+
void *user_data
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
typedef void ( *get_config_request_handler )(
|
|
101
|
+
uint32_t transaction_id,
|
|
102
|
+
void *user_data
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
typedef void ( *set_config_handler )(
|
|
107
|
+
uint32_t transaction_id,
|
|
108
|
+
uint16_t flags,
|
|
109
|
+
uint16_t miss_send_len,
|
|
110
|
+
void *user_data
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
typedef void ( *packet_out_handler )(
|
|
115
|
+
uint32_t transaction_id,
|
|
116
|
+
uint32_t buffer_id,
|
|
117
|
+
uint16_t in_port,
|
|
118
|
+
const openflow_actions *actions,
|
|
119
|
+
const buffer *data,
|
|
120
|
+
void *user_data
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
typedef void ( *flow_mod_handler )(
|
|
125
|
+
uint32_t transaction_id,
|
|
126
|
+
struct ofp_match match,
|
|
127
|
+
uint64_t cookie,
|
|
128
|
+
uint16_t command,
|
|
129
|
+
uint16_t idle_timeout,
|
|
130
|
+
uint16_t hard_timeout,
|
|
131
|
+
uint16_t priority,
|
|
132
|
+
uint32_t buffer_id,
|
|
133
|
+
uint16_t out_port,
|
|
134
|
+
uint16_t flags,
|
|
135
|
+
const openflow_actions *actions,
|
|
136
|
+
void *user_data
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
typedef void ( *port_mod_handler )(
|
|
141
|
+
uint32_t transaction_id,
|
|
142
|
+
uint16_t port_no,
|
|
143
|
+
uint8_t hw_addr[ OFP_ETH_ALEN ],
|
|
144
|
+
uint32_t config,
|
|
145
|
+
uint32_t mask,
|
|
146
|
+
uint32_t advertise,
|
|
147
|
+
void *user_data
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
typedef void ( *stats_request_handler )(
|
|
152
|
+
uint32_t transaction_id,
|
|
153
|
+
uint16_t type,
|
|
154
|
+
uint16_t flags,
|
|
155
|
+
const buffer *body,
|
|
156
|
+
void *user_data
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
typedef void ( *barrier_request_handler )(
|
|
161
|
+
uint32_t transaction_id,
|
|
162
|
+
void *user_data
|
|
163
|
+
);
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
typedef void ( *queue_get_config_request_handler )(
|
|
167
|
+
uint32_t transaction_id,
|
|
168
|
+
uint16_t port,
|
|
169
|
+
void *user_data
|
|
170
|
+
);
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
typedef struct {
|
|
174
|
+
controller_connected_handler controller_connected_callback;
|
|
175
|
+
void *controller_connected_user_data;
|
|
176
|
+
|
|
177
|
+
controller_disconnected_handler controller_disconnected_callback;
|
|
178
|
+
void *controller_disconnected_user_data;
|
|
179
|
+
|
|
180
|
+
hello_handler hello_callback;
|
|
181
|
+
void *hello_user_data;
|
|
182
|
+
|
|
183
|
+
error_handler error_callback;
|
|
184
|
+
void *error_user_data;
|
|
185
|
+
|
|
186
|
+
echo_request_handler echo_request_callback;
|
|
187
|
+
void *echo_request_user_data;
|
|
188
|
+
|
|
189
|
+
echo_reply_handler echo_reply_callback;
|
|
190
|
+
void *echo_reply_user_data;
|
|
191
|
+
|
|
192
|
+
vendor_handler vendor_callback;
|
|
193
|
+
void *vendor_user_data;
|
|
194
|
+
|
|
195
|
+
features_request_handler features_request_callback;
|
|
196
|
+
void *features_request_user_data;
|
|
197
|
+
|
|
198
|
+
get_config_request_handler get_config_request_callback;
|
|
199
|
+
void *get_config_request_user_data;
|
|
200
|
+
|
|
201
|
+
set_config_handler set_config_callback;
|
|
202
|
+
void *set_config_user_data;
|
|
203
|
+
|
|
204
|
+
packet_out_handler packet_out_callback;
|
|
205
|
+
void *packet_out_user_data;
|
|
206
|
+
|
|
207
|
+
flow_mod_handler flow_mod_callback;
|
|
208
|
+
void *flow_mod_user_data;
|
|
209
|
+
|
|
210
|
+
port_mod_handler port_mod_callback;
|
|
211
|
+
void *port_mod_user_data;
|
|
212
|
+
|
|
213
|
+
stats_request_handler stats_request_callback;
|
|
214
|
+
void *stats_request_user_data;
|
|
215
|
+
|
|
216
|
+
barrier_request_handler barrier_request_callback;
|
|
217
|
+
void *barrier_request_user_data;
|
|
218
|
+
|
|
219
|
+
queue_get_config_request_handler queue_get_config_request_callback;
|
|
220
|
+
void *queue_get_config_request_user_data;
|
|
221
|
+
} openflow_event_handlers;
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
/********************************************************************************
|
|
225
|
+
* Functions for setting callback functions for OpenFlow related events.
|
|
226
|
+
********************************************************************************/
|
|
227
|
+
|
|
228
|
+
bool switch_set_openflow_event_handlers( const openflow_event_handlers handlers );
|
|
229
|
+
bool set_controller_connected_handler( controller_connected_handler callback, void *user_data );
|
|
230
|
+
bool set_controller_disconnected_handler( controller_disconnected_handler callback, void *user_data );
|
|
231
|
+
bool set_hello_handler( hello_handler callback, void *user_data );
|
|
232
|
+
bool switch_set_error_handler( error_handler callback, void *user_data );
|
|
233
|
+
bool set_echo_request_handler( echo_request_handler callback, void *user_data );
|
|
234
|
+
bool switch_set_echo_reply_handler( echo_reply_handler callback, void *user_data );
|
|
235
|
+
bool switch_set_vendor_handler( vendor_handler callback, void *user_data );
|
|
236
|
+
bool set_features_request_handler( features_request_handler callback, void *user_data );
|
|
237
|
+
bool set_get_config_request_handler( get_config_request_handler callback, void *user_data );
|
|
238
|
+
bool set_set_config_handler( set_config_handler callback, void *user_data );
|
|
239
|
+
bool set_packet_out_handler( packet_out_handler callback, void *user_data );
|
|
240
|
+
bool set_flow_mod_handler( flow_mod_handler callback, void *user_data );
|
|
241
|
+
bool set_port_mod_handler( port_mod_handler callback, void *user_data );
|
|
242
|
+
bool set_stats_request_handler( stats_request_handler callback, void *user_data );
|
|
243
|
+
bool set_barrier_request_handler( barrier_request_handler callback, void *user_data );
|
|
244
|
+
bool set_queue_get_config_request_handler( queue_get_config_request_handler callback, void *user_data );
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
/********************************************************************************
|
|
248
|
+
* Function for sending/receiving OpenFlow messages.
|
|
249
|
+
********************************************************************************/
|
|
250
|
+
|
|
251
|
+
bool switch_send_openflow_message( buffer *message );
|
|
252
|
+
bool handle_secure_channel_message( buffer *message );
|
|
253
|
+
bool send_error_message( uint32_t transaction_id, uint16_t type, uint16_t code );
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
#endif // OPENFLOW_SWITCH_INTERFACE_H
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
/*
|
|
260
|
+
* Local variables:
|
|
261
|
+
* c-basic-offset: 2
|
|
262
|
+
* indent-tabs-mode: nil
|
|
263
|
+
* End:
|
|
264
|
+
*/
|
data/src/lib/packet_info.c
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Author: Kazuya Suzuki
|
|
3
|
-
*
|
|
4
2
|
* Copyright (C) 2008-2012 NEC Corporation
|
|
5
3
|
*
|
|
6
4
|
* This program is free software; you can redistribute it and/or modify
|
|
@@ -54,14 +52,14 @@ get_packet_info( const buffer *frame ) {
|
|
|
54
52
|
die_if_NULL( frame );
|
|
55
53
|
|
|
56
54
|
packet_info info;
|
|
57
|
-
|
|
55
|
+
|
|
58
56
|
if ( frame->user_data != NULL ) {
|
|
59
57
|
info = *( packet_info * ) frame->user_data;
|
|
60
|
-
}
|
|
58
|
+
}
|
|
61
59
|
else {
|
|
62
60
|
memset( &info, 0, sizeof( info ) );
|
|
63
61
|
}
|
|
64
|
-
|
|
62
|
+
|
|
65
63
|
return info;
|
|
66
64
|
}
|
|
67
65
|
|
|
@@ -133,6 +131,13 @@ packet_type_ipv4( const buffer *frame ) {
|
|
|
133
131
|
}
|
|
134
132
|
|
|
135
133
|
|
|
134
|
+
bool
|
|
135
|
+
packet_type_ipv6( const buffer *frame ) {
|
|
136
|
+
die_if_NULL( frame );
|
|
137
|
+
return if_packet_type( frame, NW_IPV6 );
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
|
|
136
141
|
bool
|
|
137
142
|
packet_type_lldp( const buffer *frame ) {
|
|
138
143
|
die_if_NULL( frame );
|
|
@@ -161,6 +166,13 @@ packet_type_ipv4_tcp( const buffer *frame ) {
|
|
|
161
166
|
}
|
|
162
167
|
|
|
163
168
|
|
|
169
|
+
bool
|
|
170
|
+
packet_type_ipv6_tcp( const buffer *frame ) {
|
|
171
|
+
die_if_NULL( frame );
|
|
172
|
+
return if_packet_type( frame, NW_IPV6 | TP_TCP );
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
|
|
164
176
|
bool
|
|
165
177
|
packet_type_ipv4_udp( const buffer *frame ) {
|
|
166
178
|
die_if_NULL( frame );
|
|
@@ -168,6 +180,13 @@ packet_type_ipv4_udp( const buffer *frame ) {
|
|
|
168
180
|
}
|
|
169
181
|
|
|
170
182
|
|
|
183
|
+
bool
|
|
184
|
+
packet_type_ipv6_udp( const buffer *frame ) {
|
|
185
|
+
die_if_NULL( frame );
|
|
186
|
+
return if_packet_type( frame, NW_IPV6 | TP_UDP );
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
|
|
171
190
|
bool
|
|
172
191
|
packet_type_ipv4_etherip( const buffer *frame ) {
|
|
173
192
|
die_if_NULL( frame );
|
|
@@ -175,6 +194,70 @@ packet_type_ipv4_etherip( const buffer *frame ) {
|
|
|
175
194
|
}
|
|
176
195
|
|
|
177
196
|
|
|
197
|
+
static bool
|
|
198
|
+
if_arp_opcode( const buffer *frame, const uint32_t opcode ) {
|
|
199
|
+
die_if_NULL( frame );
|
|
200
|
+
packet_info packet_info = get_packet_info( frame );
|
|
201
|
+
return ( packet_info.arp_ar_op == opcode );
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
bool
|
|
206
|
+
packet_type_arp_request( const buffer *frame ) {
|
|
207
|
+
die_if_NULL( frame );
|
|
208
|
+
return ( if_packet_type( frame, NW_ARP ) &
|
|
209
|
+
if_arp_opcode( frame, ARP_OP_REQUEST ) );
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
bool
|
|
214
|
+
packet_type_arp_reply( const buffer *frame ) {
|
|
215
|
+
die_if_NULL( frame );
|
|
216
|
+
return ( if_packet_type( frame, NW_ARP ) &
|
|
217
|
+
if_arp_opcode( frame, ARP_OP_REPLY ) );
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
static bool
|
|
222
|
+
if_icmpv4_type( const buffer *frame, const uint32_t type ) {
|
|
223
|
+
die_if_NULL( frame );
|
|
224
|
+
packet_info packet_info = get_packet_info( frame );
|
|
225
|
+
return ( packet_info.icmpv4_type == type );
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
bool
|
|
230
|
+
packet_type_icmpv4_echo_reply( const buffer *frame ) {
|
|
231
|
+
die_if_NULL( frame );
|
|
232
|
+
return ( if_packet_type( frame, NW_ICMPV4 ) &
|
|
233
|
+
if_icmpv4_type( frame, ICMP_TYPE_ECHOREP ) );
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
bool
|
|
238
|
+
packet_type_icmpv4_dst_unreach( const buffer *frame ) {
|
|
239
|
+
die_if_NULL( frame );
|
|
240
|
+
return ( if_packet_type( frame, NW_ICMPV4 ) &
|
|
241
|
+
if_icmpv4_type( frame, ICMP_TYPE_UNREACH ) );
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
bool
|
|
246
|
+
packet_type_icmpv4_redirect( const buffer *frame ) {
|
|
247
|
+
die_if_NULL( frame );
|
|
248
|
+
return ( if_packet_type( frame, NW_ICMPV4 ) &
|
|
249
|
+
if_icmpv4_type( frame, ICMP_TYPE_REDIRECT ) );
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
bool
|
|
254
|
+
packet_type_icmpv4_echo_request( const buffer *frame ) {
|
|
255
|
+
die_if_NULL( frame );
|
|
256
|
+
return ( if_packet_type( frame, NW_ICMPV4 ) &
|
|
257
|
+
if_icmpv4_type( frame, ICMP_TYPE_ECHOREQ ) );
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
|
|
178
261
|
static bool
|
|
179
262
|
if_igmp_type( const buffer *frame, const uint32_t type ) {
|
|
180
263
|
die_if_NULL( frame );
|
|
@@ -183,22 +266,22 @@ if_igmp_type( const buffer *frame, const uint32_t type ) {
|
|
|
183
266
|
}
|
|
184
267
|
|
|
185
268
|
|
|
186
|
-
bool
|
|
269
|
+
bool
|
|
187
270
|
packet_type_igmp_membership_query( const buffer *frame ) {
|
|
188
271
|
die_if_NULL( frame );
|
|
189
272
|
return ( if_packet_type( frame, NW_IGMP ) &
|
|
190
273
|
if_igmp_type( frame, IGMP_TYPE_MEMBERSHIP_QUERY ) );
|
|
191
274
|
}
|
|
192
275
|
|
|
193
|
-
|
|
194
|
-
bool
|
|
276
|
+
|
|
277
|
+
bool
|
|
195
278
|
packet_type_igmp_v1_membership_report( const buffer *frame ) {
|
|
196
279
|
die_if_NULL( frame );
|
|
197
280
|
return ( if_packet_type( frame, NW_IGMP ) &
|
|
198
281
|
if_igmp_type( frame, IGMP_TYPE_V1_MEMBERSHIP_REPORT ) );
|
|
199
282
|
}
|
|
200
283
|
|
|
201
|
-
bool
|
|
284
|
+
bool
|
|
202
285
|
packet_type_igmp_v2_membership_report( const buffer *frame ) {
|
|
203
286
|
die_if_NULL( frame );
|
|
204
287
|
return ( if_packet_type( frame, NW_IGMP ) &
|
|
@@ -206,7 +289,7 @@ packet_type_igmp_v2_membership_report( const buffer *frame ) {
|
|
|
206
289
|
}
|
|
207
290
|
|
|
208
291
|
|
|
209
|
-
bool
|
|
292
|
+
bool
|
|
210
293
|
packet_type_igmp_v2_leave_group( const buffer *frame ) {
|
|
211
294
|
die_if_NULL( frame );
|
|
212
295
|
return ( if_packet_type( frame, NW_IGMP ) &
|
|
@@ -214,7 +297,7 @@ packet_type_igmp_v2_leave_group( const buffer *frame ) {
|
|
|
214
297
|
}
|
|
215
298
|
|
|
216
299
|
|
|
217
|
-
bool
|
|
300
|
+
bool
|
|
218
301
|
packet_type_igmp_v3_membership_report( const buffer *frame ) {
|
|
219
302
|
die_if_NULL( frame );
|
|
220
303
|
return ( if_packet_type( frame, NW_IGMP ) &
|
data/src/lib/packet_info.h
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* Functions for accessing commonly-used header fields values.
|
|
3
3
|
*
|
|
4
|
-
* Author: Kazuya Suzuki
|
|
5
|
-
*
|
|
6
4
|
* Copyright (C) 2008-2012 NEC Corporation
|
|
7
5
|
*
|
|
8
6
|
* This program is free software; you can redistribute it and/or modify
|
|
@@ -31,6 +29,7 @@
|
|
|
31
29
|
#include "icmp.h"
|
|
32
30
|
#include "igmp.h"
|
|
33
31
|
#include "ipv4.h"
|
|
32
|
+
#include "ipv6.h"
|
|
34
33
|
#include "tcp.h"
|
|
35
34
|
#include "udp.h"
|
|
36
35
|
#include "etherip.h"
|
|
@@ -91,7 +90,7 @@ enum {
|
|
|
91
90
|
|
|
92
91
|
typedef struct {
|
|
93
92
|
uint32_t format;
|
|
94
|
-
|
|
93
|
+
|
|
95
94
|
uint8_t eth_macda[ ETH_ADDRLEN ];
|
|
96
95
|
uint8_t eth_macsa[ ETH_ADDRLEN ];
|
|
97
96
|
uint16_t eth_type;
|
|
@@ -128,6 +127,15 @@ typedef struct {
|
|
|
128
127
|
uint32_t ipv4_saddr;
|
|
129
128
|
uint32_t ipv4_daddr;
|
|
130
129
|
|
|
130
|
+
uint8_t ipv6_version;
|
|
131
|
+
uint8_t ipv6_tc;
|
|
132
|
+
uint32_t ipv6_flowlabel;
|
|
133
|
+
uint16_t ipv6_plen;
|
|
134
|
+
uint16_t ipv6_nexthdr;
|
|
135
|
+
uint16_t ipv6_hoplimit;
|
|
136
|
+
uint8_t ipv6_saddr[ IPV6_ADDRLEN ];
|
|
137
|
+
uint8_t ipv6_daddr[ IPV6_ADDRLEN ];
|
|
138
|
+
|
|
131
139
|
uint8_t icmpv4_type;
|
|
132
140
|
uint8_t icmpv4_code;
|
|
133
141
|
uint16_t icmpv4_checksum;
|
|
@@ -184,13 +192,24 @@ bool packet_type_eth_snap( const buffer *frame );
|
|
|
184
192
|
bool packet_type_ether( const buffer *frame );
|
|
185
193
|
bool packet_type_arp( const buffer *frame );
|
|
186
194
|
bool packet_type_ipv4( const buffer *frame );
|
|
195
|
+
bool packet_type_ipv6( const buffer *frame );
|
|
187
196
|
bool packet_type_lldp( const buffer *frame );
|
|
188
197
|
bool packet_type_icmpv4( const buffer *frame );
|
|
189
198
|
bool packet_type_igmp( const buffer *frame );
|
|
190
199
|
bool packet_type_ipv4_tcp( const buffer *frame );
|
|
200
|
+
bool packet_type_ipv6_tcp( const buffer *frame );
|
|
191
201
|
bool packet_type_ipv4_udp( const buffer *frame );
|
|
202
|
+
bool packet_type_ipv6_udp( const buffer *frame );
|
|
192
203
|
bool packet_type_ipv4_etherip( const buffer *frame );
|
|
193
204
|
|
|
205
|
+
bool packet_type_arp_request( const buffer *frame );
|
|
206
|
+
bool packet_type_arp_reply( const buffer *frame );
|
|
207
|
+
|
|
208
|
+
bool packet_type_icmpv4_echo_reply( const buffer *frame );
|
|
209
|
+
bool packet_type_icmpv4_dst_unreach( const buffer *frame );
|
|
210
|
+
bool packet_type_icmpv4_redirect( const buffer *frame );
|
|
211
|
+
bool packet_type_icmpv4_echo_request( const buffer *frame );
|
|
212
|
+
|
|
194
213
|
bool packet_type_igmp_membership_query( const buffer *frame );
|
|
195
214
|
bool packet_type_igmp_v1_membership_report( const buffer *frame );
|
|
196
215
|
bool packet_type_igmp_v2_membership_report( const buffer *frame );
|