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
data/ruby/trema/match.c
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Author: Yasuhito Takamiya <yasuhito@gmail.com>
|
|
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
|
|
@@ -35,7 +33,7 @@ match_alloc( VALUE klass ) {
|
|
|
35
33
|
}
|
|
36
34
|
|
|
37
35
|
|
|
38
|
-
static struct
|
|
36
|
+
static struct
|
|
39
37
|
ofp_match *get_match( VALUE self ) {
|
|
40
38
|
struct ofp_match *match;
|
|
41
39
|
Data_Get_Struct( self, struct ofp_match, match );
|
|
@@ -102,7 +100,7 @@ ofp_match *get_match( VALUE self ) {
|
|
|
102
100
|
* the destination TCP/UDP port number to wildcard.
|
|
103
101
|
*
|
|
104
102
|
* @return [Match] self
|
|
105
|
-
* the modified or exact match from packet depending on whether the options
|
|
103
|
+
* the modified or exact match from packet depending on whether the options
|
|
106
104
|
* argument supplied or not.
|
|
107
105
|
*/
|
|
108
106
|
static VALUE
|
|
@@ -336,7 +334,7 @@ match_nw_src( VALUE self ) {
|
|
|
336
334
|
|
|
337
335
|
/*
|
|
338
336
|
* An IPv4 destination address in its numeric representation.
|
|
339
|
-
*
|
|
337
|
+
*
|
|
340
338
|
* @return [IP] the value of nw_dst.
|
|
341
339
|
*/
|
|
342
340
|
static VALUE
|
|
@@ -365,13 +363,13 @@ match_tp_dst( VALUE self ) {
|
|
|
365
363
|
|
|
366
364
|
/*
|
|
367
365
|
* Creates a {Match} instance which describe fields such as MAC addresses, IP
|
|
368
|
-
* addresses, TCP/UDP ports of a flow to match against. An exact match
|
|
366
|
+
* addresses, TCP/UDP ports of a flow to match against. An exact match
|
|
369
367
|
* flow would match on all fields whereas don't care bits are wildcarded and
|
|
370
368
|
* ignored.
|
|
371
369
|
*
|
|
372
370
|
* @overload initialize(options={})
|
|
373
371
|
*
|
|
374
|
-
* @example
|
|
372
|
+
* @example
|
|
375
373
|
* Match.new(
|
|
376
374
|
* :in_port => port_no,
|
|
377
375
|
* :dl_src => "xx:xx:xx;xx:xx:xx",
|
|
@@ -475,7 +473,7 @@ match_init( int argc, VALUE *argv, VALUE self ) {
|
|
|
475
473
|
else {
|
|
476
474
|
dl_addr = rb_funcall( rb_eval_string( "Trema::Mac" ), rb_intern( "new" ), 1, dl_src );
|
|
477
475
|
}
|
|
478
|
-
|
|
476
|
+
dl_addr_to_a( dl_addr, match->dl_src );
|
|
479
477
|
match->wildcards &= ( uint32_t ) ~OFPFW_DL_SRC;
|
|
480
478
|
}
|
|
481
479
|
|
|
@@ -488,7 +486,7 @@ match_init( int argc, VALUE *argv, VALUE self ) {
|
|
|
488
486
|
else {
|
|
489
487
|
dl_addr = rb_funcall( rb_eval_string( "Trema::Mac" ), rb_intern( "new" ), 1, dl_dst );
|
|
490
488
|
}
|
|
491
|
-
|
|
489
|
+
dl_addr_to_a( dl_addr, match->dl_dst );
|
|
492
490
|
match->wildcards &= ( uint32_t ) ~OFPFW_DL_DST;
|
|
493
491
|
}
|
|
494
492
|
|
data/ruby/trema/open-vswitch.rb
CHANGED
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
|
|
21
21
|
require "trema/daemon"
|
|
22
22
|
require "trema/executables"
|
|
23
|
+
require "trema/hardware-switch"
|
|
23
24
|
require "trema/ofctl"
|
|
24
|
-
require "trema/openflow-switch"
|
|
25
25
|
require "trema/path"
|
|
26
26
|
|
|
27
27
|
|
|
@@ -29,7 +29,7 @@ module Trema
|
|
|
29
29
|
#
|
|
30
30
|
# Open vSwitch support (http://openvswitch.org)
|
|
31
31
|
#
|
|
32
|
-
class OpenVswitch <
|
|
32
|
+
class OpenVswitch < HardwareSwitch
|
|
33
33
|
include Trema::Daemon
|
|
34
34
|
|
|
35
35
|
|
|
@@ -18,65 +18,14 @@
|
|
|
18
18
|
#
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
require "trema/
|
|
21
|
+
require "trema/network-component"
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
module Trema
|
|
25
25
|
#
|
|
26
|
-
#
|
|
26
|
+
# Keeps a list of {HardwareSwitch} and {OpenVswitch}
|
|
27
27
|
#
|
|
28
|
-
class OpenflowSwitch
|
|
29
|
-
#
|
|
30
|
-
# The name of this switch
|
|
31
|
-
#
|
|
32
|
-
# @example
|
|
33
|
-
# switch.name #=> "My expensive OpenFlow switch"
|
|
34
|
-
#
|
|
35
|
-
# @return [String]
|
|
36
|
-
#
|
|
37
|
-
attr_reader :name
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
#
|
|
41
|
-
# Creates a new OpenflowSwitch from {DSL::Switch}
|
|
42
|
-
#
|
|
43
|
-
# @example
|
|
44
|
-
# switch = Trema::OpenflowSwitch.new( stanza )
|
|
45
|
-
#
|
|
46
|
-
# @return [OpenflowSwitch]
|
|
47
|
-
#
|
|
48
|
-
def initialize stanza
|
|
49
|
-
stanza.validate
|
|
50
|
-
@name = stanza.name
|
|
51
|
-
@stanza = stanza
|
|
52
|
-
Switch.add self
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
#
|
|
57
|
-
# Returns datapath id in long format
|
|
58
|
-
#
|
|
59
|
-
# @example
|
|
60
|
-
# switch.dpid_long #=> "0000000000000abc"
|
|
61
|
-
#
|
|
62
|
-
# @return [String]
|
|
63
|
-
#
|
|
64
|
-
def dpid_long
|
|
65
|
-
@stanza.fetch :dpid_long
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
#
|
|
70
|
-
# Returns datapath id prefixed with "0x"
|
|
71
|
-
#
|
|
72
|
-
# @example
|
|
73
|
-
# switch.dpid_short #=> "0xabc"
|
|
74
|
-
#
|
|
75
|
-
# @return [String]
|
|
76
|
-
#
|
|
77
|
-
def dpid_short
|
|
78
|
-
@stanza.fetch :dpid_short
|
|
79
|
-
end
|
|
28
|
+
class OpenflowSwitch < NetworkComponent
|
|
80
29
|
end
|
|
81
30
|
end
|
|
82
31
|
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Author: Yasuhito Takamiya <yasuhito@gmail.com>
|
|
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
|
|
@@ -26,38 +24,28 @@
|
|
|
26
24
|
|
|
27
25
|
extern VALUE mTrema;
|
|
28
26
|
VALUE cPacketIn;
|
|
29
|
-
VALUE mPacketInVTAG;
|
|
30
|
-
VALUE mPacketInARP;
|
|
31
|
-
VALUE mPacketInIPv4;
|
|
32
|
-
VALUE mPacketInICMPv4;
|
|
33
|
-
VALUE mPacketInIGMP;
|
|
34
|
-
VALUE mPacketInTCP;
|
|
35
|
-
VALUE mPacketInUDP;
|
|
36
|
-
|
|
37
27
|
|
|
38
|
-
#define PACKET_IN_RETURN_MAC( packet_member ) { \
|
|
39
|
-
VALUE ret = ULL2NUM( mac_to_uint64( get_packet_in_info( self )->packet_member ) ); \
|
|
40
|
-
return rb_funcall( rb_eval_string( "Trema::Mac" ), rb_intern( "new" ), 1, ret ); }
|
|
41
28
|
|
|
42
|
-
#define
|
|
43
|
-
|
|
44
|
-
|
|
29
|
+
#define PACKET_IN_RETURN_MAC( packet_member ) \
|
|
30
|
+
{ \
|
|
31
|
+
VALUE ret = ULL2NUM( mac_to_uint64( get_packet_in_info( self )->packet_member ) ); \
|
|
32
|
+
return rb_funcall( rb_eval_string( "Trema::Mac" ), rb_intern( "new" ), 1, ret ); \
|
|
33
|
+
}
|
|
45
34
|
|
|
35
|
+
#define PACKET_IN_RETURN_IP( packet_member ) \
|
|
36
|
+
{ \
|
|
37
|
+
VALUE ret = ULONG2NUM( get_packet_in_info( self )->packet_member ); \
|
|
38
|
+
return rb_funcall( rb_eval_string( "Trema::IP" ), rb_intern( "new" ), 1, ret ); \
|
|
39
|
+
}
|
|
46
40
|
|
|
47
|
-
#
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
static VALUE
|
|
56
|
-
packet_in_init( VALUE kclass ) {
|
|
57
|
-
packet_in *_packet_in = xmalloc( sizeof( packet_in ) );
|
|
58
|
-
return Data_Wrap_Struct( klass, 0, xfree, _packet_in );
|
|
59
|
-
}
|
|
60
|
-
#endif
|
|
41
|
+
#define PACKET_IN_RETURN_NUM( flag, func, packet_member ) \
|
|
42
|
+
{ \
|
|
43
|
+
if ( get_packet_in_info( self )->format & flag ) { \
|
|
44
|
+
return func( get_packet_in_info( self )->packet_member ); \
|
|
45
|
+
} else { \
|
|
46
|
+
return Qnil; \
|
|
47
|
+
} \
|
|
48
|
+
}
|
|
61
49
|
|
|
62
50
|
|
|
63
51
|
static VALUE
|
|
@@ -106,8 +94,8 @@ packet_in_transaction_id( VALUE self ) {
|
|
|
106
94
|
|
|
107
95
|
|
|
108
96
|
/*
|
|
109
|
-
* Buffer id value signifies if the entire frame (packet is not buffered) or
|
|
110
|
-
* portion of it (packet is buffered) is included in the data field of
|
|
97
|
+
* Buffer id value signifies if the entire frame (packet is not buffered) or
|
|
98
|
+
* portion of it (packet is buffered) is included in the data field of
|
|
111
99
|
* this +OFPT_PACKET_IN+ message.
|
|
112
100
|
*
|
|
113
101
|
* @return [Number] the value of buffer id.
|
|
@@ -237,7 +225,7 @@ packet_in_is_vtag( VALUE self ) {
|
|
|
237
225
|
*/
|
|
238
226
|
static VALUE
|
|
239
227
|
packet_in_vlan_tpid( VALUE self ) {
|
|
240
|
-
|
|
228
|
+
PACKET_IN_RETURN_NUM( ETH_8021Q, UINT2NUM, vlan_tpid );
|
|
241
229
|
}
|
|
242
230
|
|
|
243
231
|
|
|
@@ -248,7 +236,7 @@ packet_in_vlan_tpid( VALUE self ) {
|
|
|
248
236
|
*/
|
|
249
237
|
static VALUE
|
|
250
238
|
packet_in_vlan_tci( VALUE self ) {
|
|
251
|
-
|
|
239
|
+
PACKET_IN_RETURN_NUM( ETH_8021Q, UINT2NUM, vlan_tci );
|
|
252
240
|
}
|
|
253
241
|
|
|
254
242
|
|
|
@@ -259,7 +247,7 @@ packet_in_vlan_tci( VALUE self ) {
|
|
|
259
247
|
*/
|
|
260
248
|
static VALUE
|
|
261
249
|
packet_in_vlan_prio( VALUE self ) {
|
|
262
|
-
|
|
250
|
+
PACKET_IN_RETURN_NUM( ETH_8021Q, UINT2NUM, vlan_prio );
|
|
263
251
|
}
|
|
264
252
|
|
|
265
253
|
|
|
@@ -270,7 +258,7 @@ packet_in_vlan_prio( VALUE self ) {
|
|
|
270
258
|
*/
|
|
271
259
|
static VALUE
|
|
272
260
|
packet_in_vlan_cfi( VALUE self ) {
|
|
273
|
-
|
|
261
|
+
PACKET_IN_RETURN_NUM( ETH_8021Q, UINT2NUM, vlan_cfi );
|
|
274
262
|
}
|
|
275
263
|
|
|
276
264
|
|
|
@@ -281,7 +269,7 @@ packet_in_vlan_cfi( VALUE self ) {
|
|
|
281
269
|
*/
|
|
282
270
|
static VALUE
|
|
283
271
|
packet_in_vlan_vid( VALUE self ) {
|
|
284
|
-
|
|
272
|
+
PACKET_IN_RETURN_NUM( ETH_8021Q, UINT2NUM, vlan_vid );
|
|
285
273
|
}
|
|
286
274
|
|
|
287
275
|
|
|
@@ -301,6 +289,38 @@ packet_in_is_arp( VALUE self ) {
|
|
|
301
289
|
}
|
|
302
290
|
|
|
303
291
|
|
|
292
|
+
/*
|
|
293
|
+
* Is an ARP request packet?
|
|
294
|
+
*
|
|
295
|
+
* @return [bool] arp_request? Is an ARP request packet?
|
|
296
|
+
*/
|
|
297
|
+
static VALUE
|
|
298
|
+
packet_in_is_arp_request( VALUE self ) {
|
|
299
|
+
if ( packet_type_arp_request( get_packet_in( self )->data ) ) {
|
|
300
|
+
return Qtrue;
|
|
301
|
+
}
|
|
302
|
+
else {
|
|
303
|
+
return Qfalse;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
/*
|
|
309
|
+
* Is an ARP reply packet?
|
|
310
|
+
*
|
|
311
|
+
* @return [bool] arp_reply? Is an ARP reply packet?
|
|
312
|
+
*/
|
|
313
|
+
static VALUE
|
|
314
|
+
packet_in_is_arp_reply( VALUE self ) {
|
|
315
|
+
if ( packet_type_arp_reply( get_packet_in( self )->data ) ) {
|
|
316
|
+
return Qtrue;
|
|
317
|
+
}
|
|
318
|
+
else {
|
|
319
|
+
return Qfalse;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
|
|
304
324
|
/*
|
|
305
325
|
* The ARP operation code.
|
|
306
326
|
*
|
|
@@ -308,7 +328,7 @@ packet_in_is_arp( VALUE self ) {
|
|
|
308
328
|
*/
|
|
309
329
|
static VALUE
|
|
310
330
|
packet_in_arp_oper( VALUE self ) {
|
|
311
|
-
|
|
331
|
+
PACKET_IN_RETURN_NUM( NW_ARP, UINT2NUM, arp_ar_op );
|
|
312
332
|
}
|
|
313
333
|
|
|
314
334
|
|
|
@@ -319,7 +339,12 @@ packet_in_arp_oper( VALUE self ) {
|
|
|
319
339
|
*/
|
|
320
340
|
static VALUE
|
|
321
341
|
packet_in_arp_sha( VALUE self ) {
|
|
322
|
-
|
|
342
|
+
if ( ( get_packet_in_info( self )->format & NW_ARP ) ) {
|
|
343
|
+
PACKET_IN_RETURN_MAC( arp_sha );
|
|
344
|
+
}
|
|
345
|
+
else {
|
|
346
|
+
return Qnil;
|
|
347
|
+
}
|
|
323
348
|
}
|
|
324
349
|
|
|
325
350
|
|
|
@@ -330,7 +355,12 @@ packet_in_arp_sha( VALUE self ) {
|
|
|
330
355
|
*/
|
|
331
356
|
static VALUE
|
|
332
357
|
packet_in_arp_spa( VALUE self ) {
|
|
333
|
-
|
|
358
|
+
if ( ( get_packet_in_info( self )->format & NW_ARP ) ) {
|
|
359
|
+
PACKET_IN_RETURN_IP( arp_spa );
|
|
360
|
+
}
|
|
361
|
+
else {
|
|
362
|
+
return Qnil;
|
|
363
|
+
}
|
|
334
364
|
}
|
|
335
365
|
|
|
336
366
|
|
|
@@ -341,7 +371,12 @@ packet_in_arp_spa( VALUE self ) {
|
|
|
341
371
|
*/
|
|
342
372
|
static VALUE
|
|
343
373
|
packet_in_arp_tha( VALUE self ) {
|
|
344
|
-
|
|
374
|
+
if ( ( get_packet_in_info( self )->format & NW_ARP ) ) {
|
|
375
|
+
PACKET_IN_RETURN_MAC( arp_tha );
|
|
376
|
+
}
|
|
377
|
+
else {
|
|
378
|
+
return Qnil;
|
|
379
|
+
}
|
|
345
380
|
}
|
|
346
381
|
|
|
347
382
|
|
|
@@ -352,7 +387,12 @@ packet_in_arp_tha( VALUE self ) {
|
|
|
352
387
|
*/
|
|
353
388
|
static VALUE
|
|
354
389
|
packet_in_arp_tpa( VALUE self ) {
|
|
355
|
-
|
|
390
|
+
if ( ( get_packet_in_info( self )->format & NW_ARP ) ) {
|
|
391
|
+
PACKET_IN_RETURN_IP( arp_tpa );
|
|
392
|
+
}
|
|
393
|
+
else {
|
|
394
|
+
return Qnil;
|
|
395
|
+
}
|
|
356
396
|
}
|
|
357
397
|
|
|
358
398
|
|
|
@@ -379,7 +419,7 @@ packet_in_is_ipv4( VALUE self ) {
|
|
|
379
419
|
*/
|
|
380
420
|
static VALUE
|
|
381
421
|
packet_in_ipv4_version( VALUE self ) {
|
|
382
|
-
|
|
422
|
+
PACKET_IN_RETURN_NUM( NW_IPV4, UINT2NUM, ipv4_version );
|
|
383
423
|
}
|
|
384
424
|
|
|
385
425
|
|
|
@@ -390,7 +430,7 @@ packet_in_ipv4_version( VALUE self ) {
|
|
|
390
430
|
*/
|
|
391
431
|
static VALUE
|
|
392
432
|
packet_in_ipv4_ihl( VALUE self ) {
|
|
393
|
-
|
|
433
|
+
PACKET_IN_RETURN_NUM( NW_IPV4, UINT2NUM, ipv4_ihl );
|
|
394
434
|
}
|
|
395
435
|
|
|
396
436
|
|
|
@@ -401,7 +441,7 @@ packet_in_ipv4_ihl( VALUE self ) {
|
|
|
401
441
|
*/
|
|
402
442
|
static VALUE
|
|
403
443
|
packet_in_ipv4_tos( VALUE self ) {
|
|
404
|
-
|
|
444
|
+
PACKET_IN_RETURN_NUM( NW_IPV4, UINT2NUM, ipv4_tos );
|
|
405
445
|
}
|
|
406
446
|
|
|
407
447
|
|
|
@@ -412,7 +452,7 @@ packet_in_ipv4_tos( VALUE self ) {
|
|
|
412
452
|
*/
|
|
413
453
|
static VALUE
|
|
414
454
|
packet_in_ipv4_tot_len( VALUE self ) {
|
|
415
|
-
|
|
455
|
+
PACKET_IN_RETURN_NUM( NW_IPV4, UINT2NUM, ipv4_tot_len );
|
|
416
456
|
}
|
|
417
457
|
|
|
418
458
|
|
|
@@ -423,7 +463,7 @@ packet_in_ipv4_tot_len( VALUE self ) {
|
|
|
423
463
|
*/
|
|
424
464
|
static VALUE
|
|
425
465
|
packet_in_ipv4_id( VALUE self ) {
|
|
426
|
-
|
|
466
|
+
PACKET_IN_RETURN_NUM( NW_IPV4, UINT2NUM, ipv4_id );
|
|
427
467
|
}
|
|
428
468
|
|
|
429
469
|
|
|
@@ -434,7 +474,7 @@ packet_in_ipv4_id( VALUE self ) {
|
|
|
434
474
|
*/
|
|
435
475
|
static VALUE
|
|
436
476
|
packet_in_ipv4_frag_off( VALUE self ) {
|
|
437
|
-
|
|
477
|
+
PACKET_IN_RETURN_NUM( NW_IPV4, UINT2NUM, ipv4_frag_off );
|
|
438
478
|
}
|
|
439
479
|
|
|
440
480
|
|
|
@@ -445,7 +485,7 @@ packet_in_ipv4_frag_off( VALUE self ) {
|
|
|
445
485
|
*/
|
|
446
486
|
static VALUE
|
|
447
487
|
packet_in_ipv4_ttl( VALUE self ) {
|
|
448
|
-
|
|
488
|
+
PACKET_IN_RETURN_NUM( NW_IPV4, UINT2NUM, ipv4_ttl );
|
|
449
489
|
}
|
|
450
490
|
|
|
451
491
|
|
|
@@ -456,7 +496,7 @@ packet_in_ipv4_ttl( VALUE self ) {
|
|
|
456
496
|
*/
|
|
457
497
|
static VALUE
|
|
458
498
|
packet_in_ipv4_protocol( VALUE self ) {
|
|
459
|
-
|
|
499
|
+
PACKET_IN_RETURN_NUM( NW_IPV4, UINT2NUM, ipv4_protocol );
|
|
460
500
|
}
|
|
461
501
|
|
|
462
502
|
|
|
@@ -467,7 +507,7 @@ packet_in_ipv4_protocol( VALUE self ) {
|
|
|
467
507
|
*/
|
|
468
508
|
static VALUE
|
|
469
509
|
packet_in_ipv4_checksum( VALUE self ) {
|
|
470
|
-
|
|
510
|
+
PACKET_IN_RETURN_NUM( NW_IPV4, UINT2NUM, ipv4_checksum );
|
|
471
511
|
}
|
|
472
512
|
|
|
473
513
|
|
|
@@ -478,7 +518,12 @@ packet_in_ipv4_checksum( VALUE self ) {
|
|
|
478
518
|
*/
|
|
479
519
|
static VALUE
|
|
480
520
|
packet_in_ipv4_saddr( VALUE self ) {
|
|
481
|
-
|
|
521
|
+
if ( ( get_packet_in_info( self )->format & NW_IPV4 ) ) {
|
|
522
|
+
PACKET_IN_RETURN_IP( ipv4_saddr );
|
|
523
|
+
}
|
|
524
|
+
else {
|
|
525
|
+
return Qnil;
|
|
526
|
+
}
|
|
482
527
|
}
|
|
483
528
|
|
|
484
529
|
|
|
@@ -489,7 +534,12 @@ packet_in_ipv4_saddr( VALUE self ) {
|
|
|
489
534
|
*/
|
|
490
535
|
static VALUE
|
|
491
536
|
packet_in_ipv4_daddr( VALUE self ) {
|
|
492
|
-
|
|
537
|
+
if ( ( get_packet_in_info( self )->format & NW_IPV4 ) ) {
|
|
538
|
+
PACKET_IN_RETURN_IP( ipv4_daddr );
|
|
539
|
+
}
|
|
540
|
+
else {
|
|
541
|
+
return Qnil;
|
|
542
|
+
}
|
|
493
543
|
}
|
|
494
544
|
|
|
495
545
|
|
|
@@ -516,7 +566,7 @@ packet_in_is_icmpv4( VALUE self ) {
|
|
|
516
566
|
*/
|
|
517
567
|
static VALUE
|
|
518
568
|
packet_in_icmpv4_type( VALUE self ) {
|
|
519
|
-
|
|
569
|
+
PACKET_IN_RETURN_NUM( NW_ICMPV4, UINT2NUM, icmpv4_type );
|
|
520
570
|
}
|
|
521
571
|
|
|
522
572
|
|
|
@@ -527,7 +577,7 @@ packet_in_icmpv4_type( VALUE self ) {
|
|
|
527
577
|
*/
|
|
528
578
|
static VALUE
|
|
529
579
|
packet_in_icmpv4_code( VALUE self ) {
|
|
530
|
-
|
|
580
|
+
PACKET_IN_RETURN_NUM( NW_ICMPV4, UINT2NUM, icmpv4_code );
|
|
531
581
|
}
|
|
532
582
|
|
|
533
583
|
|
|
@@ -538,7 +588,7 @@ packet_in_icmpv4_code( VALUE self ) {
|
|
|
538
588
|
*/
|
|
539
589
|
static VALUE
|
|
540
590
|
packet_in_icmpv4_checksum( VALUE self ) {
|
|
541
|
-
|
|
591
|
+
PACKET_IN_RETURN_NUM( NW_ICMPV4, UINT2NUM, icmpv4_checksum );
|
|
542
592
|
}
|
|
543
593
|
|
|
544
594
|
|
|
@@ -549,7 +599,7 @@ packet_in_icmpv4_checksum( VALUE self ) {
|
|
|
549
599
|
*/
|
|
550
600
|
static VALUE
|
|
551
601
|
packet_in_icmpv4_id( VALUE self ) {
|
|
552
|
-
|
|
602
|
+
PACKET_IN_RETURN_NUM( NW_ICMPV4, UINT2NUM, icmpv4_id );
|
|
553
603
|
}
|
|
554
604
|
|
|
555
605
|
|
|
@@ -560,7 +610,7 @@ packet_in_icmpv4_id( VALUE self ) {
|
|
|
560
610
|
*/
|
|
561
611
|
static VALUE
|
|
562
612
|
packet_in_icmpv4_seq( VALUE self ) {
|
|
563
|
-
|
|
613
|
+
PACKET_IN_RETURN_NUM( NW_ICMPV4, UINT2NUM, icmpv4_seq );
|
|
564
614
|
}
|
|
565
615
|
|
|
566
616
|
|
|
@@ -571,7 +621,76 @@ packet_in_icmpv4_seq( VALUE self ) {
|
|
|
571
621
|
*/
|
|
572
622
|
static VALUE
|
|
573
623
|
packet_in_icmpv4_gateway( VALUE self ) {
|
|
574
|
-
|
|
624
|
+
if ( ( get_packet_in_info( self )->format & NW_ICMPV4 ) ) {
|
|
625
|
+
PACKET_IN_RETURN_IP( icmpv4_gateway );
|
|
626
|
+
}
|
|
627
|
+
else {
|
|
628
|
+
return Qnil;
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
|
|
633
|
+
/*
|
|
634
|
+
* Is an ICMPv4 echo reply packet?
|
|
635
|
+
*
|
|
636
|
+
* @return [bool] icmpv4_echo_reply? Is an ICMP echo reply packet?
|
|
637
|
+
*/
|
|
638
|
+
static VALUE
|
|
639
|
+
packet_in_is_icmpv4_echo_reply( VALUE self ) {
|
|
640
|
+
if ( packet_type_icmpv4_echo_reply( get_packet_in( self )->data ) ) {
|
|
641
|
+
return Qtrue;
|
|
642
|
+
}
|
|
643
|
+
else {
|
|
644
|
+
return Qfalse;
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
|
|
649
|
+
/*
|
|
650
|
+
* Is an ICMPv4 destination unreachable packet?
|
|
651
|
+
*
|
|
652
|
+
* @return [bool] icmpv4_dst_unreach? Is an ICMP destination unreachable packet?
|
|
653
|
+
*/
|
|
654
|
+
static VALUE
|
|
655
|
+
packet_in_is_icmpv4_dst_unreach( VALUE self ) {
|
|
656
|
+
if ( packet_type_icmpv4_dst_unreach( get_packet_in( self )->data ) ) {
|
|
657
|
+
return Qtrue;
|
|
658
|
+
}
|
|
659
|
+
else {
|
|
660
|
+
return Qfalse;
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
|
|
665
|
+
/*
|
|
666
|
+
* Is an ICMPv4 redirect packet?
|
|
667
|
+
*
|
|
668
|
+
* @return [bool] icmpv4_redirect? Is an ICMP redirect packet?
|
|
669
|
+
*/
|
|
670
|
+
static VALUE
|
|
671
|
+
packet_in_is_icmpv4_redirect( VALUE self ) {
|
|
672
|
+
if ( packet_type_icmpv4_redirect( get_packet_in( self )->data ) ) {
|
|
673
|
+
return Qtrue;
|
|
674
|
+
}
|
|
675
|
+
else {
|
|
676
|
+
return Qfalse;
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
|
|
681
|
+
/*
|
|
682
|
+
* Is an ICMPv4 echo request packet?
|
|
683
|
+
*
|
|
684
|
+
* @return [bool] icmpv4_echo_request? Is an ICMP echo request packet?
|
|
685
|
+
*/
|
|
686
|
+
static VALUE
|
|
687
|
+
packet_in_is_icmpv4_echo_request( VALUE self ) {
|
|
688
|
+
if ( packet_type_icmpv4_echo_request( get_packet_in( self )->data ) ) {
|
|
689
|
+
return Qtrue;
|
|
690
|
+
}
|
|
691
|
+
else {
|
|
692
|
+
return Qfalse;
|
|
693
|
+
}
|
|
575
694
|
}
|
|
576
695
|
|
|
577
696
|
|
|
@@ -678,7 +797,7 @@ packet_in_is_igmp_v3_membership_report( VALUE self ) {
|
|
|
678
797
|
*/
|
|
679
798
|
static VALUE
|
|
680
799
|
packet_in_igmp_type( VALUE self ) {
|
|
681
|
-
|
|
800
|
+
PACKET_IN_RETURN_NUM( NW_IGMP, UINT2NUM, igmp_type );
|
|
682
801
|
}
|
|
683
802
|
|
|
684
803
|
|
|
@@ -689,7 +808,12 @@ packet_in_igmp_type( VALUE self ) {
|
|
|
689
808
|
*/
|
|
690
809
|
static VALUE
|
|
691
810
|
packet_in_igmp_group( VALUE self ) {
|
|
692
|
-
|
|
811
|
+
if ( ( get_packet_in_info( self )->format & NW_IGMP ) ) {
|
|
812
|
+
PACKET_IN_RETURN_IP( igmp_group );
|
|
813
|
+
}
|
|
814
|
+
else {
|
|
815
|
+
return Qnil;
|
|
816
|
+
}
|
|
693
817
|
}
|
|
694
818
|
|
|
695
819
|
|
|
@@ -700,7 +824,7 @@ packet_in_igmp_group( VALUE self ) {
|
|
|
700
824
|
*/
|
|
701
825
|
static VALUE
|
|
702
826
|
packet_in_igmp_checksum( VALUE self ) {
|
|
703
|
-
|
|
827
|
+
PACKET_IN_RETURN_NUM( NW_IGMP, UINT2NUM, igmp_checksum );
|
|
704
828
|
}
|
|
705
829
|
|
|
706
830
|
|
|
@@ -727,7 +851,7 @@ packet_in_is_tcp( VALUE self ) {
|
|
|
727
851
|
*/
|
|
728
852
|
static VALUE
|
|
729
853
|
packet_in_tcp_src_port( VALUE self ) {
|
|
730
|
-
|
|
854
|
+
PACKET_IN_RETURN_NUM( TP_TCP, UINT2NUM, tcp_src_port );
|
|
731
855
|
}
|
|
732
856
|
|
|
733
857
|
|
|
@@ -738,7 +862,7 @@ packet_in_tcp_src_port( VALUE self ) {
|
|
|
738
862
|
*/
|
|
739
863
|
static VALUE
|
|
740
864
|
packet_in_tcp_dst_port( VALUE self ) {
|
|
741
|
-
|
|
865
|
+
PACKET_IN_RETURN_NUM( TP_TCP, UINT2NUM, tcp_dst_port );
|
|
742
866
|
}
|
|
743
867
|
|
|
744
868
|
|
|
@@ -749,7 +873,7 @@ packet_in_tcp_dst_port( VALUE self ) {
|
|
|
749
873
|
*/
|
|
750
874
|
static VALUE
|
|
751
875
|
packet_in_tcp_seq_no( VALUE self ) {
|
|
752
|
-
|
|
876
|
+
PACKET_IN_RETURN_NUM( TP_TCP, ULONG2NUM, tcp_seq_no );
|
|
753
877
|
}
|
|
754
878
|
|
|
755
879
|
|
|
@@ -760,7 +884,7 @@ packet_in_tcp_seq_no( VALUE self ) {
|
|
|
760
884
|
*/
|
|
761
885
|
static VALUE
|
|
762
886
|
packet_in_tcp_ack_no( VALUE self ) {
|
|
763
|
-
|
|
887
|
+
PACKET_IN_RETURN_NUM( TP_TCP, ULONG2NUM, tcp_ack_no );
|
|
764
888
|
}
|
|
765
889
|
|
|
766
890
|
|
|
@@ -771,7 +895,7 @@ packet_in_tcp_ack_no( VALUE self ) {
|
|
|
771
895
|
*/
|
|
772
896
|
static VALUE
|
|
773
897
|
packet_in_tcp_offset( VALUE self ) {
|
|
774
|
-
|
|
898
|
+
PACKET_IN_RETURN_NUM( TP_TCP, UINT2NUM, tcp_offset );
|
|
775
899
|
}
|
|
776
900
|
|
|
777
901
|
|
|
@@ -782,7 +906,7 @@ packet_in_tcp_offset( VALUE self ) {
|
|
|
782
906
|
*/
|
|
783
907
|
static VALUE
|
|
784
908
|
packet_in_tcp_flags( VALUE self ) {
|
|
785
|
-
|
|
909
|
+
PACKET_IN_RETURN_NUM( TP_TCP, UINT2NUM, tcp_flags );
|
|
786
910
|
}
|
|
787
911
|
|
|
788
912
|
|
|
@@ -793,7 +917,7 @@ packet_in_tcp_flags( VALUE self ) {
|
|
|
793
917
|
*/
|
|
794
918
|
static VALUE
|
|
795
919
|
packet_in_tcp_window( VALUE self ) {
|
|
796
|
-
|
|
920
|
+
PACKET_IN_RETURN_NUM( TP_TCP, UINT2NUM, tcp_window );
|
|
797
921
|
}
|
|
798
922
|
|
|
799
923
|
|
|
@@ -804,7 +928,7 @@ packet_in_tcp_window( VALUE self ) {
|
|
|
804
928
|
*/
|
|
805
929
|
static VALUE
|
|
806
930
|
packet_in_tcp_checksum( VALUE self ) {
|
|
807
|
-
|
|
931
|
+
PACKET_IN_RETURN_NUM( TP_TCP, UINT2NUM, tcp_checksum );
|
|
808
932
|
}
|
|
809
933
|
|
|
810
934
|
|
|
@@ -815,7 +939,7 @@ packet_in_tcp_checksum( VALUE self ) {
|
|
|
815
939
|
*/
|
|
816
940
|
static VALUE
|
|
817
941
|
packet_in_tcp_urgent( VALUE self ) {
|
|
818
|
-
|
|
942
|
+
PACKET_IN_RETURN_NUM( TP_TCP, UINT2NUM, tcp_urgent );
|
|
819
943
|
}
|
|
820
944
|
|
|
821
945
|
|
|
@@ -855,7 +979,7 @@ packet_in_udp_payload( VALUE self ) {
|
|
|
855
979
|
*/
|
|
856
980
|
static VALUE
|
|
857
981
|
packet_in_udp_src_port( VALUE self ) {
|
|
858
|
-
|
|
982
|
+
PACKET_IN_RETURN_NUM( TP_UDP, UINT2NUM, udp_src_port );
|
|
859
983
|
}
|
|
860
984
|
|
|
861
985
|
|
|
@@ -866,7 +990,7 @@ packet_in_udp_src_port( VALUE self ) {
|
|
|
866
990
|
*/
|
|
867
991
|
static VALUE
|
|
868
992
|
packet_in_udp_dst_port( VALUE self ) {
|
|
869
|
-
|
|
993
|
+
PACKET_IN_RETURN_NUM( TP_UDP, UINT2NUM, udp_dst_port );
|
|
870
994
|
}
|
|
871
995
|
|
|
872
996
|
|
|
@@ -877,7 +1001,7 @@ packet_in_udp_dst_port( VALUE self ) {
|
|
|
877
1001
|
*/
|
|
878
1002
|
static VALUE
|
|
879
1003
|
packet_in_udp_len( VALUE self ) {
|
|
880
|
-
|
|
1004
|
+
PACKET_IN_RETURN_NUM( TP_UDP, UINT2NUM, udp_len );
|
|
881
1005
|
}
|
|
882
1006
|
|
|
883
1007
|
|
|
@@ -888,7 +1012,7 @@ packet_in_udp_len( VALUE self ) {
|
|
|
888
1012
|
*/
|
|
889
1013
|
static VALUE
|
|
890
1014
|
packet_in_udp_checksum( VALUE self ) {
|
|
891
|
-
|
|
1015
|
+
PACKET_IN_RETURN_NUM( TP_UDP, UINT2NUM, udp_checksum );
|
|
892
1016
|
}
|
|
893
1017
|
|
|
894
1018
|
|
|
@@ -898,15 +1022,9 @@ Init_packet_in() {
|
|
|
898
1022
|
rb_require( "trema/mac" );
|
|
899
1023
|
cPacketIn = rb_define_class_under( mTrema, "PacketIn", rb_cObject );
|
|
900
1024
|
rb_define_alloc_func( cPacketIn, packet_in_alloc );
|
|
901
|
-
|
|
902
|
-
/*
|
|
903
|
-
* Do not remove this is to fake yard to create a constructor for
|
|
904
|
-
* PacketIn object.
|
|
905
|
-
*/
|
|
906
|
-
rb_define_method( cPacketIn, "initialize", packet_in_init, 0 );
|
|
907
|
-
#endif
|
|
1025
|
+
|
|
908
1026
|
rb_define_method( cPacketIn, "datapath_id", packet_in_datapath_id, 0 );
|
|
909
|
-
rb_define_method( cPacketIn, "transaction_id", packet_in_transaction_id, 0 );
|
|
1027
|
+
rb_define_method( cPacketIn, "transaction_id", packet_in_transaction_id, 0 );
|
|
910
1028
|
rb_define_method( cPacketIn, "buffer_id", packet_in_buffer_id, 0 );
|
|
911
1029
|
rb_define_method( cPacketIn, "buffered?", packet_in_is_buffered, 0 );
|
|
912
1030
|
rb_define_method( cPacketIn, "in_port", packet_in_in_port, 0 );
|
|
@@ -926,68 +1044,67 @@ Init_packet_in() {
|
|
|
926
1044
|
rb_define_method( cPacketIn, "tcp?", packet_in_is_tcp, 0 );
|
|
927
1045
|
rb_define_method( cPacketIn, "udp?", packet_in_is_udp, 0 );
|
|
928
1046
|
|
|
929
|
-
|
|
930
|
-
rb_define_method(
|
|
931
|
-
rb_define_method(
|
|
932
|
-
rb_define_method(
|
|
933
|
-
rb_define_method(
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
rb_define_method(
|
|
938
|
-
rb_define_method(
|
|
939
|
-
rb_define_method(
|
|
940
|
-
rb_define_method(
|
|
941
|
-
rb_define_method(
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
rb_define_method(
|
|
945
|
-
rb_define_method(
|
|
946
|
-
rb_define_method(
|
|
947
|
-
rb_define_method(
|
|
948
|
-
rb_define_method(
|
|
949
|
-
rb_define_method(
|
|
950
|
-
rb_define_method(
|
|
951
|
-
rb_define_method(
|
|
952
|
-
rb_define_method(
|
|
953
|
-
rb_define_method(
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
rb_define_method(
|
|
958
|
-
rb_define_method(
|
|
959
|
-
rb_define_method(
|
|
960
|
-
rb_define_method(
|
|
961
|
-
rb_define_method(
|
|
962
|
-
rb_define_method(
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
rb_define_method(
|
|
967
|
-
rb_define_method(
|
|
968
|
-
rb_define_method(
|
|
969
|
-
rb_define_method(
|
|
970
|
-
rb_define_method(
|
|
971
|
-
rb_define_method(
|
|
972
|
-
rb_define_method(
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
rb_define_method(
|
|
976
|
-
rb_define_method(
|
|
977
|
-
rb_define_method(
|
|
978
|
-
rb_define_method(
|
|
979
|
-
rb_define_method(
|
|
980
|
-
rb_define_method(
|
|
981
|
-
rb_define_method(
|
|
982
|
-
rb_define_method(
|
|
983
|
-
rb_define_method(
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
rb_define_method(
|
|
987
|
-
rb_define_method(
|
|
988
|
-
rb_define_method(
|
|
989
|
-
rb_define_method(
|
|
990
|
-
rb_define_method( mPacketInUDP, "udp_len", packet_in_udp_len, 0 );
|
|
1047
|
+
rb_define_method( cPacketIn, "vlan_tpid", packet_in_vlan_tpid, 0 );
|
|
1048
|
+
rb_define_method( cPacketIn, "vlan_tci", packet_in_vlan_tci, 0 );
|
|
1049
|
+
rb_define_method( cPacketIn, "vlan_prio", packet_in_vlan_prio, 0 );
|
|
1050
|
+
rb_define_method( cPacketIn, "vlan_cfi", packet_in_vlan_cfi, 0 );
|
|
1051
|
+
rb_define_method( cPacketIn, "vlan_vid", packet_in_vlan_vid, 0 );
|
|
1052
|
+
|
|
1053
|
+
rb_define_method( cPacketIn, "arp_oper", packet_in_arp_oper, 0 );
|
|
1054
|
+
rb_define_method( cPacketIn, "arp_sha", packet_in_arp_sha, 0 );
|
|
1055
|
+
rb_define_method( cPacketIn, "arp_spa", packet_in_arp_spa, 0 );
|
|
1056
|
+
rb_define_method( cPacketIn, "arp_tha", packet_in_arp_tha, 0 );
|
|
1057
|
+
rb_define_method( cPacketIn, "arp_tpa", packet_in_arp_tpa, 0 );
|
|
1058
|
+
rb_define_method( cPacketIn, "arp_request?", packet_in_is_arp_request, 0 );
|
|
1059
|
+
rb_define_method( cPacketIn, "arp_reply?", packet_in_is_arp_reply, 0 );
|
|
1060
|
+
|
|
1061
|
+
rb_define_method( cPacketIn, "ipv4_version", packet_in_ipv4_version, 0 );
|
|
1062
|
+
rb_define_method( cPacketIn, "ipv4_ihl", packet_in_ipv4_ihl, 0 );
|
|
1063
|
+
rb_define_method( cPacketIn, "ipv4_tos", packet_in_ipv4_tos, 0 );
|
|
1064
|
+
rb_define_method( cPacketIn, "ipv4_tot_len", packet_in_ipv4_tot_len, 0 );
|
|
1065
|
+
rb_define_method( cPacketIn, "ipv4_id", packet_in_ipv4_id, 0 );
|
|
1066
|
+
rb_define_method( cPacketIn, "ipv4_frag_off", packet_in_ipv4_frag_off, 0 );
|
|
1067
|
+
rb_define_method( cPacketIn, "ipv4_ttl", packet_in_ipv4_ttl, 0 );
|
|
1068
|
+
rb_define_method( cPacketIn, "ipv4_protocol", packet_in_ipv4_protocol, 0 );
|
|
1069
|
+
rb_define_method( cPacketIn, "ipv4_checksum", packet_in_ipv4_checksum, 0 );
|
|
1070
|
+
rb_define_method( cPacketIn, "ipv4_saddr", packet_in_ipv4_saddr, 0 );
|
|
1071
|
+
rb_define_method( cPacketIn, "ipv4_daddr", packet_in_ipv4_daddr, 0 );
|
|
1072
|
+
|
|
1073
|
+
rb_define_method( cPacketIn, "icmpv4_type", packet_in_icmpv4_type, 0 );
|
|
1074
|
+
rb_define_method( cPacketIn, "icmpv4_code", packet_in_icmpv4_code, 0 );
|
|
1075
|
+
rb_define_method( cPacketIn, "icmpv4_checksum", packet_in_icmpv4_checksum, 0 );
|
|
1076
|
+
rb_define_method( cPacketIn, "icmpv4_id", packet_in_icmpv4_id, 0 );
|
|
1077
|
+
rb_define_method( cPacketIn, "icmpv4_seq", packet_in_icmpv4_seq, 0 );
|
|
1078
|
+
rb_define_method( cPacketIn, "icmpv4_gateway", packet_in_icmpv4_gateway, 0 );
|
|
1079
|
+
rb_define_method( cPacketIn, "icmpv4_echo_reply?", packet_in_is_icmpv4_echo_reply, 0 );
|
|
1080
|
+
rb_define_method( cPacketIn, "icmpv4_dst_unreach?", packet_in_is_icmpv4_dst_unreach, 0 );
|
|
1081
|
+
rb_define_method( cPacketIn, "icmpv4_redirect?", packet_in_is_icmpv4_redirect, 0 );
|
|
1082
|
+
rb_define_method( cPacketIn, "icmpv4_echo_request?", packet_in_is_icmpv4_echo_request, 0 );
|
|
1083
|
+
|
|
1084
|
+
rb_define_method( cPacketIn, "igmp_type", packet_in_igmp_type, 0 );
|
|
1085
|
+
rb_define_method( cPacketIn, "igmp_group", packet_in_igmp_group, 0 );
|
|
1086
|
+
rb_define_method( cPacketIn, "igmp_checksum", packet_in_igmp_checksum, 0 );
|
|
1087
|
+
rb_define_method( cPacketIn, "igmp_membership_query?", packet_in_is_igmp_membership_query, 0 );
|
|
1088
|
+
rb_define_method( cPacketIn, "igmp_v1_membership_report?", packet_in_is_igmp_v1_membership_report, 0 );
|
|
1089
|
+
rb_define_method( cPacketIn, "igmp_v2_membership_report?", packet_in_is_igmp_v2_membership_report, 0 );
|
|
1090
|
+
rb_define_method( cPacketIn, "igmp_v2_leave_group?", packet_in_is_igmp_v2_leave_group, 0 );
|
|
1091
|
+
rb_define_method( cPacketIn, "igmp_v3_membership_report?", packet_in_is_igmp_v3_membership_report, 0 );
|
|
1092
|
+
|
|
1093
|
+
rb_define_method( cPacketIn, "tcp_src_port", packet_in_tcp_src_port, 0 );
|
|
1094
|
+
rb_define_method( cPacketIn, "tcp_dst_port", packet_in_tcp_dst_port, 0 );
|
|
1095
|
+
rb_define_method( cPacketIn, "tcp_seq_no", packet_in_tcp_seq_no, 0 );
|
|
1096
|
+
rb_define_method( cPacketIn, "tcp_ack_no", packet_in_tcp_ack_no, 0 );
|
|
1097
|
+
rb_define_method( cPacketIn, "tcp_offset", packet_in_tcp_offset, 0 );
|
|
1098
|
+
rb_define_method( cPacketIn, "tcp_flags", packet_in_tcp_flags, 0 );
|
|
1099
|
+
rb_define_method( cPacketIn, "tcp_window", packet_in_tcp_window, 0 );
|
|
1100
|
+
rb_define_method( cPacketIn, "tcp_checksum", packet_in_tcp_checksum, 0 );
|
|
1101
|
+
rb_define_method( cPacketIn, "tcp_urgent", packet_in_tcp_urgent, 0 );
|
|
1102
|
+
|
|
1103
|
+
rb_define_method( cPacketIn, "udp_payload", packet_in_udp_payload, 0 );
|
|
1104
|
+
rb_define_method( cPacketIn, "udp_src_port", packet_in_udp_src_port, 0 );
|
|
1105
|
+
rb_define_method( cPacketIn, "udp_dst_port", packet_in_udp_dst_port, 0 );
|
|
1106
|
+
rb_define_method( cPacketIn, "udp_checksum", packet_in_udp_checksum, 0 );
|
|
1107
|
+
rb_define_method( cPacketIn, "udp_len", packet_in_udp_len, 0 );
|
|
991
1108
|
}
|
|
992
1109
|
|
|
993
1110
|
|
|
@@ -1006,36 +1123,6 @@ handle_packet_in( uint64_t datapath_id, packet_in message ) {
|
|
|
1006
1123
|
Data_Get_Struct( r_message, packet_in, tmp );
|
|
1007
1124
|
memcpy( tmp, &message, sizeof( packet_in ) );
|
|
1008
1125
|
|
|
1009
|
-
packet_info* info = ( packet_info * ) tmp->data->user_data;
|
|
1010
|
-
|
|
1011
|
-
if ( ( info->format & ETH_8021Q ) ) {
|
|
1012
|
-
rb_funcall( cPacketIn, rb_intern( "include" ), 1, mPacketInVTAG );
|
|
1013
|
-
}
|
|
1014
|
-
|
|
1015
|
-
if ( ( info->format & NW_ARP ) ) {
|
|
1016
|
-
rb_funcall( cPacketIn, rb_intern( "include" ), 1, mPacketInARP );
|
|
1017
|
-
}
|
|
1018
|
-
|
|
1019
|
-
if ( ( info->format & NW_IPV4 ) ) {
|
|
1020
|
-
rb_funcall( cPacketIn, rb_intern( "include" ), 1, mPacketInIPv4 );
|
|
1021
|
-
}
|
|
1022
|
-
|
|
1023
|
-
if ( ( info->format & NW_ICMPV4 ) ) {
|
|
1024
|
-
rb_funcall( cPacketIn, rb_intern( "include" ), 1, mPacketInICMPv4 );
|
|
1025
|
-
}
|
|
1026
|
-
|
|
1027
|
-
if ( ( info->format & NW_IGMP ) ) {
|
|
1028
|
-
rb_funcall( cPacketIn, rb_intern( "include" ), 1, mPacketInIGMP );
|
|
1029
|
-
}
|
|
1030
|
-
|
|
1031
|
-
if ( ( info->format & TP_TCP ) ) {
|
|
1032
|
-
rb_funcall( cPacketIn, rb_intern( "include" ), 1, mPacketInTCP );
|
|
1033
|
-
}
|
|
1034
|
-
|
|
1035
|
-
if ( ( info->format & TP_UDP ) ) {
|
|
1036
|
-
rb_funcall( cPacketIn, rb_intern( "include" ), 1, mPacketInUDP );
|
|
1037
|
-
}
|
|
1038
|
-
|
|
1039
1126
|
rb_funcall( controller, rb_intern( "packet_in" ), 2, ULL2NUM( datapath_id ), r_message );
|
|
1040
1127
|
}
|
|
1041
1128
|
|