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
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Author: Nick Karanatsios <nickkaranatsios@gmail.com>
|
|
3
|
-
*
|
|
4
|
-
* Copyright (C) 2008-2012 NEC Corporation
|
|
5
|
-
*
|
|
6
|
-
* This program is free software; you can redistribute it and/or modify
|
|
7
|
-
* it under the terms of the GNU General Public License, version 2, as
|
|
8
|
-
* published by the Free Software Foundation.
|
|
9
|
-
*
|
|
10
|
-
* This program is distributed in the hope that it will be useful,
|
|
11
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
-
* GNU General Public License for more details.
|
|
14
|
-
*
|
|
15
|
-
* You should have received a copy of the GNU General Public License along
|
|
16
|
-
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
17
|
-
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
#include "trema.h"
|
|
22
|
-
#include "ruby.h"
|
|
23
|
-
#include "action-common.h"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
extern VALUE mTrema;
|
|
27
|
-
VALUE cActionSetNwDst;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
/*
|
|
31
|
-
* An action to modify the IPv4 destination address of a packet.
|
|
32
|
-
*
|
|
33
|
-
* @overload initialize(options={})
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* ActionSetNwDst.new( :nw_dst => IP.new( "192.168.1.1" )
|
|
37
|
-
*
|
|
38
|
-
* @param [Hash] options
|
|
39
|
-
* the options hash to create this action class instance with.
|
|
40
|
-
* @option options [IP] :nw_dst
|
|
41
|
-
* a destination IPv4 address encapsulated as an {IP} object.
|
|
42
|
-
*
|
|
43
|
-
* @raise [ArgumentError] if nw_dst argument is not supplied.
|
|
44
|
-
* @raise [TypeError] if nw_dst argument is not an {IP} object instance.
|
|
45
|
-
* @raise [TypeError] if options is not a Hash.
|
|
46
|
-
*
|
|
47
|
-
* @return [ActionSetNwDst]
|
|
48
|
-
* an object that encapsulates this action.
|
|
49
|
-
*/
|
|
50
|
-
static VALUE
|
|
51
|
-
action_set_nw_dst_init( int argc, VALUE *argv, VALUE self ) {
|
|
52
|
-
VALUE options;
|
|
53
|
-
|
|
54
|
-
if ( rb_scan_args( argc, argv, "10", &options ) == 1 ) {
|
|
55
|
-
Check_Type( options, T_HASH );
|
|
56
|
-
VALUE nw_dst;
|
|
57
|
-
if ( ( nw_dst = rb_hash_aref( options, ID2SYM( rb_intern( "nw_dst" ) ) ) ) != Qnil ) {
|
|
58
|
-
if ( rb_obj_is_instance_of( nw_dst, rb_eval_string( "Trema::IP" ) ) == Qfalse ) {
|
|
59
|
-
rb_raise( rb_eTypeError, "nw dst address should be an IP object" );
|
|
60
|
-
}
|
|
61
|
-
rb_iv_set( self, "@nw_dst", nw_dst );
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
rb_raise( rb_eArgError, "nw dst address is a mandatory option" );
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return self;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
/*
|
|
72
|
-
* The destination IPv4 address as an {IP} object.
|
|
73
|
-
*
|
|
74
|
-
* @return [IP] the value of nw_dst.
|
|
75
|
-
*/
|
|
76
|
-
static VALUE
|
|
77
|
-
action_get_nw_dst( VALUE self ) {
|
|
78
|
-
return rb_iv_get( self, "@nw_dst" );
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
/*
|
|
83
|
-
* Appends its action(nw_dst) to the list of actions.
|
|
84
|
-
*
|
|
85
|
-
* @return [ActionSetNwDst] self
|
|
86
|
-
*/
|
|
87
|
-
static VALUE
|
|
88
|
-
action_set_nw_dst_append( VALUE self, VALUE action_ptr ) {
|
|
89
|
-
openflow_actions *actions;
|
|
90
|
-
Data_Get_Struct( action_ptr, openflow_actions, actions );
|
|
91
|
-
append_action_set_nw_dst( actions, nw_addr_to_i( action_get_nw_dst( self ) ) );
|
|
92
|
-
return self;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
/*
|
|
97
|
-
* (see ActionEnqueue#inspect)
|
|
98
|
-
*/
|
|
99
|
-
static VALUE
|
|
100
|
-
action_set_nw_dst_inspect( VALUE self ) {
|
|
101
|
-
char str[ 64 ];
|
|
102
|
-
sprintf( str, "#<%s nw_dst=%s>", rb_obj_classname( self ), RSTRING_PTR( nw_addr_to_s( action_get_nw_dst( self ) ) ) );
|
|
103
|
-
return rb_str_new2( str );
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
/*
|
|
108
|
-
* The numeric representation of IPv4 destination address.
|
|
109
|
-
*
|
|
110
|
-
* @return [Number] the value of IPv4 destination address converted to an integer.
|
|
111
|
-
*/
|
|
112
|
-
static VALUE
|
|
113
|
-
action_set_nw_dst_to_i( VALUE self ) {
|
|
114
|
-
return rb_funcall( action_get_nw_dst( self ), rb_intern( "to_i" ), 0 );
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
void
|
|
119
|
-
Init_action_set_nw_dst() {
|
|
120
|
-
rb_require( "trema/ip" );
|
|
121
|
-
cActionSetNwDst = rb_define_class_under( mTrema, "ActionSetNwDst", rb_cObject );
|
|
122
|
-
rb_define_method( cActionSetNwDst, "initialize", action_set_nw_dst_init, -1 );
|
|
123
|
-
rb_define_method( cActionSetNwDst, "nw_dst", action_get_nw_dst, 0 );
|
|
124
|
-
rb_define_method( cActionSetNwDst, "append", action_set_nw_dst_append, 1 );
|
|
125
|
-
rb_define_method( cActionSetNwDst, "inspect", action_set_nw_dst_inspect, 0 );
|
|
126
|
-
rb_define_method( cActionSetNwDst, "to_i", action_set_nw_dst_to_i, 0 );
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
/*
|
|
131
|
-
* Local variables:
|
|
132
|
-
* c-basic-offset: 2
|
|
133
|
-
* indent-tabs-mode: nil
|
|
134
|
-
* End:
|
|
135
|
-
*/
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Author: Nick Karanatsios <nickkaranatsios@gmail.com>
|
|
3
|
-
*
|
|
4
|
-
* Copyright (C) 2008-2012 NEC Corporation
|
|
5
|
-
*
|
|
6
|
-
* This program is free software; you can redistribute it and/or modify
|
|
7
|
-
* it under the terms of the GNU General Public License, version 2, as
|
|
8
|
-
* published by the Free Software Foundation.
|
|
9
|
-
*
|
|
10
|
-
* This program is distributed in the hope that it will be useful,
|
|
11
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
-
* GNU General Public License for more details.
|
|
14
|
-
*
|
|
15
|
-
* You should have received a copy of the GNU General Public License along
|
|
16
|
-
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
17
|
-
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
#include "trema.h"
|
|
22
|
-
#include "ruby.h"
|
|
23
|
-
#include "action-common.h"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
extern VALUE mTrema;
|
|
27
|
-
VALUE cActionSetNwSrc;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
/*
|
|
31
|
-
* An action to modify the IPv4 source address of a packet.
|
|
32
|
-
*
|
|
33
|
-
* @overload initialize(options={})
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* ActionSetNwSrc.new( :nw_src => IP.new( "192.168.1.1" )
|
|
37
|
-
*
|
|
38
|
-
* @param [Hash] options
|
|
39
|
-
* the options hash to create this action class instance with.
|
|
40
|
-
*
|
|
41
|
-
* @option options [IP] :nw_src
|
|
42
|
-
* the source IPv4 address encapsulated as an {IP} object.
|
|
43
|
-
*
|
|
44
|
-
* @raise [ArgumentError] if nw_src argument is not supplied.
|
|
45
|
-
* @raise [TypeError] if nw_src argument is not an {IP} object instance.
|
|
46
|
-
* @raise [TypeError] if options is not a Hash.
|
|
47
|
-
*
|
|
48
|
-
* @return [ActionSetNwSrc]
|
|
49
|
-
* an object that encapsulates this action.
|
|
50
|
-
*/
|
|
51
|
-
static VALUE
|
|
52
|
-
action_set_nw_src_init( int argc, VALUE *argv, VALUE self ) {
|
|
53
|
-
VALUE options;
|
|
54
|
-
|
|
55
|
-
if ( rb_scan_args( argc, argv, "10", &options ) == 1 ) {
|
|
56
|
-
Check_Type( options, T_HASH );
|
|
57
|
-
VALUE nw_src;
|
|
58
|
-
if ( ( nw_src = rb_hash_aref( options, ID2SYM( rb_intern( "nw_src" ) ) ) ) != Qnil ) {
|
|
59
|
-
if ( rb_obj_is_instance_of( nw_src, rb_eval_string( "Trema::IP" ) ) == Qfalse ) {
|
|
60
|
-
rb_raise( rb_eTypeError, "nw src address should be an IP object" );
|
|
61
|
-
}
|
|
62
|
-
rb_iv_set( self, "@nw_src", nw_src );
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
rb_raise( rb_eArgError, "nw src address is a mandatory option" );
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
return self;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
/*
|
|
73
|
-
* The source IPv4 address as an {IP} object.
|
|
74
|
-
*
|
|
75
|
-
* @return [IP] the value of nw_src.
|
|
76
|
-
*/
|
|
77
|
-
static VALUE
|
|
78
|
-
action_get_nw_src( VALUE self ) {
|
|
79
|
-
return rb_iv_get( self, "@nw_src" );
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
/*
|
|
84
|
-
* Appends its action(set_nw_src) to the list of actions.
|
|
85
|
-
*
|
|
86
|
-
* @return [ActionSetNwSrc] self
|
|
87
|
-
*/
|
|
88
|
-
static VALUE
|
|
89
|
-
action_set_nw_src_append( VALUE self, VALUE action_ptr ) {
|
|
90
|
-
openflow_actions *actions;
|
|
91
|
-
|
|
92
|
-
Data_Get_Struct( action_ptr, openflow_actions, actions );
|
|
93
|
-
|
|
94
|
-
append_action_set_nw_src( actions, nw_addr_to_i( action_get_nw_src( self ) ) );
|
|
95
|
-
|
|
96
|
-
return self;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
/*
|
|
101
|
-
* (see ActionEnqueue#inspect)
|
|
102
|
-
*/
|
|
103
|
-
static VALUE
|
|
104
|
-
action_set_nw_src_inspect( VALUE self ) {
|
|
105
|
-
char str[ 64 ];
|
|
106
|
-
|
|
107
|
-
sprintf( str, "#<%s nw_src=%s>", rb_obj_classname( self ), RSTRING_PTR( nw_addr_to_s( action_get_nw_src( self ) ) ) );
|
|
108
|
-
return rb_str_new2( str );
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
/*
|
|
113
|
-
* The numeric representation of IPv4 source address.
|
|
114
|
-
*
|
|
115
|
-
* @return [Number] the value of IPv4 source address converted to an integer.
|
|
116
|
-
*/
|
|
117
|
-
static VALUE
|
|
118
|
-
action_set_nw_src_to_i( VALUE self ) {
|
|
119
|
-
return rb_funcall( action_get_nw_src( self ), rb_intern( "to_i" ), 0 );
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
void
|
|
124
|
-
Init_action_set_nw_src() {
|
|
125
|
-
rb_require( "ipaddr" );
|
|
126
|
-
cActionSetNwSrc = rb_define_class_under( mTrema, "ActionSetNwSrc", rb_cObject );
|
|
127
|
-
rb_define_method( cActionSetNwSrc, "initialize", action_set_nw_src_init, -1 );
|
|
128
|
-
rb_define_method( cActionSetNwSrc, "nw_src", action_get_nw_src, 0 );
|
|
129
|
-
rb_define_method( cActionSetNwSrc, "append", action_set_nw_src_append, 1 );
|
|
130
|
-
rb_define_method( cActionSetNwSrc, "inspect", action_set_nw_src_inspect, 0 );
|
|
131
|
-
rb_define_method( cActionSetNwSrc, "to_i", action_set_nw_src_to_i, 0 );
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
/*
|
|
136
|
-
* Local variables:
|
|
137
|
-
* c-basic-offset: 2
|
|
138
|
-
* indent-tabs-mode: nil
|
|
139
|
-
* End:
|
|
140
|
-
*/
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Author: Nick Karanatsios <nickkaranatsios@gmail.com>
|
|
3
|
-
*
|
|
4
|
-
* Copyright (C) 2008-2012 NEC Corporation
|
|
5
|
-
*
|
|
6
|
-
* This program is free software; you can redistribute it and/or modify
|
|
7
|
-
* it under the terms of the GNU General Public License, version 2, as
|
|
8
|
-
* published by the Free Software Foundation.
|
|
9
|
-
*
|
|
10
|
-
* This program is distributed in the hope that it will be useful,
|
|
11
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
-
* GNU General Public License for more details.
|
|
14
|
-
*
|
|
15
|
-
* You should have received a copy of the GNU General Public License along
|
|
16
|
-
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
17
|
-
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
#include "trema.h"
|
|
22
|
-
#include "ruby.h"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
extern VALUE mTrema;
|
|
26
|
-
VALUE cActionSetNwTos;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
/*
|
|
30
|
-
* An action to modify the IP ToS/DSCP field of a packet.
|
|
31
|
-
*
|
|
32
|
-
* @overload initialize(options={})
|
|
33
|
-
*
|
|
34
|
-
* @example
|
|
35
|
-
* ActionSetNwTos.new( :nw_tos => 1 )
|
|
36
|
-
*
|
|
37
|
-
* @param [Hash] options
|
|
38
|
-
* the options hash to create this action with.
|
|
39
|
-
*
|
|
40
|
-
* @option options [Number] :nw_tos
|
|
41
|
-
* the ToS/DSCP field to set to.
|
|
42
|
-
*
|
|
43
|
-
* @raise [ArgumentError] if nw_tos argument is not supplied.
|
|
44
|
-
* @raise [ArgumentError] if nw_tos is not an unsigned 8-bit integer.
|
|
45
|
-
* @raise [TypeError] if options is not a Hash.
|
|
46
|
-
*
|
|
47
|
-
* @return [ActionSetNwTos]
|
|
48
|
-
* an object that encapsulates this action.
|
|
49
|
-
*/
|
|
50
|
-
static VALUE
|
|
51
|
-
action_set_nw_tos_init( int argc, VALUE *argv, VALUE self ) {
|
|
52
|
-
VALUE options;
|
|
53
|
-
|
|
54
|
-
if ( rb_scan_args( argc, argv, "10", &options ) == 1 ) {
|
|
55
|
-
Check_Type( options, T_HASH );
|
|
56
|
-
VALUE nw_tos;
|
|
57
|
-
if ( ( nw_tos = rb_hash_aref( options, ID2SYM( rb_intern( "nw_tos" ) ) ) ) != Qnil ) {
|
|
58
|
-
if ( rb_funcall( nw_tos, rb_intern( "unsigned_8bit?" ), 0 ) == Qfalse ) {
|
|
59
|
-
rb_raise( rb_eArgError, "Nw tos must be an unsigned 8-bit integer" );
|
|
60
|
-
}
|
|
61
|
-
rb_iv_set( self, "@nw_tos", nw_tos );
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
rb_raise( rb_eArgError, "Nw tos is a mandatory option" );
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return self;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
/*
|
|
72
|
-
* The ToS/DSCP value to set to.
|
|
73
|
-
*
|
|
74
|
-
* @return [Number] the value of nw_tos.
|
|
75
|
-
*/
|
|
76
|
-
static VALUE
|
|
77
|
-
action_get_nw_tos( VALUE self ) {
|
|
78
|
-
return rb_iv_get( self, "@nw_tos" );
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
/*
|
|
83
|
-
* Appends its action(nw_tos) to the list of actions.
|
|
84
|
-
*
|
|
85
|
-
* @return [ActionSetNwTos] self
|
|
86
|
-
*/
|
|
87
|
-
static VALUE
|
|
88
|
-
action_set_nw_tos_append( VALUE self, VALUE action_ptr ) {
|
|
89
|
-
openflow_actions *actions;
|
|
90
|
-
Data_Get_Struct( action_ptr, openflow_actions, actions );
|
|
91
|
-
uint8_t nw_tos = ( uint8_t ) NUM2UINT( action_get_nw_tos( self ) );
|
|
92
|
-
append_action_set_nw_tos( actions, nw_tos );
|
|
93
|
-
return self;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
/*
|
|
98
|
-
* (see ActionEnqueue#inspect)
|
|
99
|
-
*/
|
|
100
|
-
static VALUE
|
|
101
|
-
action_set_nw_tos_inspect( VALUE self ) {
|
|
102
|
-
char str[ 64 ];
|
|
103
|
-
uint8_t nw_tos = ( uint8_t ) NUM2UINT( action_get_nw_tos( self ) );
|
|
104
|
-
sprintf( str, "#<%s nw_tos=%u>", rb_obj_classname( self ), nw_tos );
|
|
105
|
-
return rb_str_new2( str );
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
void
|
|
110
|
-
Init_action_set_nw_tos() {
|
|
111
|
-
cActionSetNwTos = rb_define_class_under( mTrema, "ActionSetNwTos", rb_cObject );
|
|
112
|
-
rb_define_method( cActionSetNwTos, "initialize", action_set_nw_tos_init, -1 );
|
|
113
|
-
rb_define_method( cActionSetNwTos, "nw_tos", action_get_nw_tos, 0 );
|
|
114
|
-
rb_define_method( cActionSetNwTos, "append", action_set_nw_tos_append, 1 );
|
|
115
|
-
rb_define_method( cActionSetNwTos, "inspect", action_set_nw_tos_inspect, 0 );
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
/*
|
|
120
|
-
* Local variables:
|
|
121
|
-
* c-basic-offset: 2
|
|
122
|
-
* indent-tabs-mode: nil
|
|
123
|
-
* End:
|
|
124
|
-
*/
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Author: Nick Karanatsios <nickkaranatsios@gmail.com>
|
|
3
|
-
*
|
|
4
|
-
* Copyright (C) 2008-2012 NEC Corporation
|
|
5
|
-
*
|
|
6
|
-
* This program is free software; you can redistribute it and/or modify
|
|
7
|
-
* it under the terms of the GNU General Public License, version 2, as
|
|
8
|
-
* published by the Free Software Foundation.
|
|
9
|
-
*
|
|
10
|
-
* This program is distributed in the hope that it will be useful,
|
|
11
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
-
* GNU General Public License for more details.
|
|
14
|
-
*
|
|
15
|
-
* You should have received a copy of the GNU General Public License along
|
|
16
|
-
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
17
|
-
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
#ifndef ACTION_SET_NW_TOS_H
|
|
22
|
-
#define ACTION_SET_NW_TOS_H
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
#include "ruby.h"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
extern VALUE cActionSetNwTos;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
void Init_action_set_nw_tos( void );
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
#endif // ACTION_SET_NW_TOS_H
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
/*
|
|
38
|
-
* Local variables:
|
|
39
|
-
* c-basic-offset: 2
|
|
40
|
-
* indent-tabs-mode: nil
|
|
41
|
-
* End:
|
|
42
|
-
*/
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Author: Nick Karanatsios <nickkaranatsios@gmail.com>
|
|
3
|
-
*
|
|
4
|
-
* Copyright (C) 2008-2012 NEC Corporation
|
|
5
|
-
*
|
|
6
|
-
* This program is free software; you can redistribute it and/or modify
|
|
7
|
-
* it under the terms of the GNU General Public License, version 2, as
|
|
8
|
-
* published by the Free Software Foundation.
|
|
9
|
-
*
|
|
10
|
-
* This program is distributed in the hope that it will be useful,
|
|
11
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
-
* GNU General Public License for more details.
|
|
14
|
-
*
|
|
15
|
-
* You should have received a copy of the GNU General Public License along
|
|
16
|
-
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
17
|
-
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
#include "trema.h"
|
|
22
|
-
#include "ruby.h"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
extern VALUE mTrema;
|
|
26
|
-
VALUE cActionSetTpDst;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
/*
|
|
30
|
-
* An action to modify the destination TCP or UDP port of a packet.
|
|
31
|
-
*
|
|
32
|
-
* @overload initialize(options={})
|
|
33
|
-
*
|
|
34
|
-
* @example
|
|
35
|
-
* ActionSetTpDst.new( :tp_dst => 5555 )
|
|
36
|
-
*
|
|
37
|
-
* @param [Hash] options
|
|
38
|
-
* the options to create this action class instance with.
|
|
39
|
-
* @option options [Number] :tp_dst
|
|
40
|
-
* the destination TCP or UDP port number. Any numeric 16-bit value.
|
|
41
|
-
*
|
|
42
|
-
* @raise [ArgumentError] if tp_dst argument is not supplied.
|
|
43
|
-
* @raise [ArgumentError] if tp_dst is not an unsigned 16-bit integer.
|
|
44
|
-
* @raise [TypeError] if options is not a Hash.
|
|
45
|
-
*
|
|
46
|
-
* @return [ActionSetTpDst]
|
|
47
|
-
* an object that encapsulates this action.
|
|
48
|
-
*/
|
|
49
|
-
static VALUE
|
|
50
|
-
action_set_tp_dst_init( int argc, VALUE *argv, VALUE self ) {
|
|
51
|
-
VALUE options;
|
|
52
|
-
|
|
53
|
-
if ( rb_scan_args( argc, argv, "10", &options ) == 1 ) {
|
|
54
|
-
Check_Type( options, T_HASH );
|
|
55
|
-
VALUE tp_dst;
|
|
56
|
-
if ( ( tp_dst = rb_hash_aref( options, ID2SYM( rb_intern( "tp_dst" ) ) ) ) != Qnil ) {
|
|
57
|
-
if ( rb_funcall( tp_dst, rb_intern( "unsigned_16bit?" ), 0 ) == Qfalse ) {
|
|
58
|
-
rb_raise( rb_eArgError, "Destination TCP or UDP port must be an unsigned 16-bit integer" );
|
|
59
|
-
}
|
|
60
|
-
rb_iv_set( self, "@tp_dst", tp_dst );
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
rb_raise( rb_eArgError, "Destination TCP or UDP port must be a mandatory option" );
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
return self;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
/*
|
|
71
|
-
* The destination TCP or UDP port number.
|
|
72
|
-
*
|
|
73
|
-
* @return [Number] the value of tp_dst.
|
|
74
|
-
*/
|
|
75
|
-
static VALUE
|
|
76
|
-
action_get_tp_dst( VALUE self ) {
|
|
77
|
-
return rb_iv_get( self, "@tp_dst" );
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
/*
|
|
82
|
-
* Appends its actions(tp_dst) to the list of actions.
|
|
83
|
-
*
|
|
84
|
-
* @return [ActionSetTpDst] self
|
|
85
|
-
*/
|
|
86
|
-
static VALUE
|
|
87
|
-
action_set_tp_dst_append( VALUE self, VALUE action_ptr ) {
|
|
88
|
-
openflow_actions *actions;
|
|
89
|
-
Data_Get_Struct( action_ptr, openflow_actions, actions );
|
|
90
|
-
append_action_set_tp_dst( actions, ( uint16_t ) NUM2UINT( action_get_tp_dst( self ) ) );
|
|
91
|
-
return self;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
/*
|
|
96
|
-
* (see ActionEnqueue#inspect)
|
|
97
|
-
*/
|
|
98
|
-
static VALUE
|
|
99
|
-
action_set_tp_dst_inspect( VALUE self ) {
|
|
100
|
-
char str[ 64 ];
|
|
101
|
-
sprintf( str, "#<%s tp_port=%u>", rb_obj_classname( self ),
|
|
102
|
-
( uint16_t ) NUM2UINT( action_get_tp_dst( self ) ) );
|
|
103
|
-
return rb_str_new2( str );
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
void
|
|
108
|
-
Init_action_set_tp_dst() {
|
|
109
|
-
cActionSetTpDst = rb_define_class_under( mTrema, "ActionSetTpDst", rb_cObject );
|
|
110
|
-
rb_define_method( cActionSetTpDst, "initialize", action_set_tp_dst_init, -1 );
|
|
111
|
-
rb_define_method( cActionSetTpDst, "tp_dst", action_get_tp_dst, 0 );
|
|
112
|
-
rb_define_method( cActionSetTpDst, "append", action_set_tp_dst_append, 1 );
|
|
113
|
-
rb_define_method( cActionSetTpDst, "inspect", action_set_tp_dst_inspect, 0 );
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
/*
|
|
118
|
-
* Local variables:
|
|
119
|
-
* c-basic-offset: 2
|
|
120
|
-
* indent-tabs-mode: nil
|
|
121
|
-
* End:
|
|
122
|
-
*/
|