pio 0.12.0 → 0.13.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/features/packet_in_read.feature +14 -12
- data/lib/pio/exact_match.rb +8 -48
- data/lib/pio/packet_in.rb +52 -0
- data/lib/pio/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 961afabded91db3ee0c2cc5958abdd2477a5c735
|
4
|
+
data.tar.gz: e7d5dd569c6a0138e2e8868aec8d16ce8db91597
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c313331ac7d13721206b253ffcc7069bc080c9c91f237d6315bc0c31609085b187d40bac070bf4d320696b457e3a40033cb2d004edcb927c256eb55bcd5cecdc
|
7
|
+
data.tar.gz: df35e068243c4a509b8e06109198dce31850a1bdbfb9943fe234ce3654a50587266954629336b4379cde355fc224b5f028b97ef6d3a96e77260a419181beebf7
|
data/CHANGELOG.md
CHANGED
@@ -4,15 +4,17 @@ Feature: Pio::PacketIn.read
|
|
4
4
|
When I try to parse the file with "PacketIn" class
|
5
5
|
Then it should finish successfully
|
6
6
|
And the parsed data have the following field and value:
|
7
|
-
| field
|
8
|
-
| class
|
9
|
-
| ofp_version
|
10
|
-
| message_type
|
11
|
-
| message_length
|
12
|
-
| transaction_id
|
13
|
-
| xid
|
14
|
-
| buffer_id
|
15
|
-
| total_len
|
16
|
-
| in_port
|
17
|
-
| reason
|
18
|
-
| data.length
|
7
|
+
| field | value |
|
8
|
+
| class | Pio::PacketIn |
|
9
|
+
| ofp_version | 1 |
|
10
|
+
| message_type | 10 |
|
11
|
+
| message_length | 78 |
|
12
|
+
| transaction_id | 0 |
|
13
|
+
| xid | 0 |
|
14
|
+
| buffer_id | 4294967040 |
|
15
|
+
| total_len | 60 |
|
16
|
+
| in_port | 1 |
|
17
|
+
| reason | no_match |
|
18
|
+
| data.length | 60 |
|
19
|
+
| source_mac | ac:5d:10:31:37:79 |
|
20
|
+
| destination_mac | ff:ff:ff:ff:ff:ff |
|
data/lib/pio/exact_match.rb
CHANGED
@@ -4,58 +4,16 @@ require 'pio/type/ethernet_header'
|
|
4
4
|
module Pio
|
5
5
|
# OpenFlow 1.0 exact match
|
6
6
|
class ExactMatch
|
7
|
-
# Pio::PacketIn#data parser
|
8
|
-
class PacketInDataParser
|
9
|
-
# Ethernet header parser
|
10
|
-
class EthernetHeaderParser < BinData::Record
|
11
|
-
extend Pio::Type::EthernetHeader
|
12
|
-
|
13
|
-
endian :big
|
14
|
-
|
15
|
-
ethernet_header
|
16
|
-
rest :payload
|
17
|
-
end
|
18
|
-
|
19
|
-
# IPv4 packet parser
|
20
|
-
class IPv4Packet < BinData::Record
|
21
|
-
extend Pio::Type::EthernetHeader
|
22
|
-
extend Type::IPv4Header
|
23
|
-
|
24
|
-
endian :big
|
25
|
-
|
26
|
-
ethernet_header
|
27
|
-
ipv4_header
|
28
|
-
|
29
|
-
uint16 :transport_source_port
|
30
|
-
uint16 :transport_destination_port
|
31
|
-
rest :rest
|
32
|
-
end
|
33
|
-
|
34
|
-
def self.read(raw_data)
|
35
|
-
ethernet_header = EthernetHeaderParser.read(raw_data)
|
36
|
-
case ethernet_header.ether_type
|
37
|
-
when 0x0800
|
38
|
-
IPv4Packet.read raw_data
|
39
|
-
when 0x0806
|
40
|
-
Pio::Arp.read raw_data
|
41
|
-
else
|
42
|
-
fail 'Failed to parse packet_in data.'
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
extend Forwardable
|
48
|
-
|
49
7
|
# rubocop:disable MethodLength
|
50
8
|
# rubocop:disable AbcSize
|
51
9
|
def initialize(packet_in)
|
52
|
-
data =
|
10
|
+
data = packet_in.parsed_data
|
53
11
|
case data
|
54
|
-
when
|
12
|
+
when PacketIn::DataParser::IPv4Packet
|
55
13
|
options = {
|
56
14
|
in_port: packet_in.in_port,
|
57
|
-
dl_src:
|
58
|
-
dl_dst:
|
15
|
+
dl_src: packet_in.source_mac,
|
16
|
+
dl_dst: packet_in.destination_mac,
|
59
17
|
dl_vlan: data.vlan_vid,
|
60
18
|
dl_vlan_pcp: data.vlan_pcp,
|
61
19
|
dl_type: data.ether_type,
|
@@ -69,8 +27,8 @@ module Pio
|
|
69
27
|
when Arp::Request
|
70
28
|
options = {
|
71
29
|
in_port: packet_in.in_port,
|
72
|
-
dl_src:
|
73
|
-
dl_dst:
|
30
|
+
dl_src: packet_in.source_mac,
|
31
|
+
dl_dst: packet_in.destination_mac,
|
74
32
|
dl_vlan: data.vlan_vid,
|
75
33
|
dl_vlan_pcp: data.vlan_pcp,
|
76
34
|
dl_type: data.ether_type,
|
@@ -87,6 +45,8 @@ module Pio
|
|
87
45
|
# rubocop:enable MethodLength
|
88
46
|
# rubocop:enable AbcSize
|
89
47
|
|
48
|
+
extend Forwardable
|
49
|
+
|
90
50
|
def_delegator :@match, :wildcards
|
91
51
|
def_delegator :@match, :in_port
|
92
52
|
def_delegator :@match, :dl_src
|
data/lib/pio/packet_in.rb
CHANGED
@@ -42,10 +42,62 @@ module Pio
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
+
# Pio::PacketIn#data parser
|
46
|
+
class DataParser
|
47
|
+
# Ethernet header parser
|
48
|
+
class EthernetHeaderParser < BinData::Record
|
49
|
+
extend Pio::Type::EthernetHeader
|
50
|
+
|
51
|
+
endian :big
|
52
|
+
|
53
|
+
ethernet_header
|
54
|
+
rest :payload
|
55
|
+
end
|
56
|
+
|
57
|
+
# IPv4 packet parser
|
58
|
+
class IPv4Packet < BinData::Record
|
59
|
+
extend Pio::Type::EthernetHeader
|
60
|
+
extend Type::IPv4Header
|
61
|
+
|
62
|
+
endian :big
|
63
|
+
|
64
|
+
ethernet_header
|
65
|
+
ipv4_header
|
66
|
+
|
67
|
+
uint16 :transport_source_port
|
68
|
+
uint16 :transport_destination_port
|
69
|
+
rest :rest
|
70
|
+
end
|
71
|
+
|
72
|
+
def self.read(raw_data)
|
73
|
+
ethernet_header = EthernetHeaderParser.read(raw_data)
|
74
|
+
case ethernet_header.ether_type
|
75
|
+
when 0x0800
|
76
|
+
IPv4Packet.read raw_data
|
77
|
+
when 0x0806
|
78
|
+
Pio::Arp.read raw_data
|
79
|
+
else
|
80
|
+
fail 'Failed to parse packet_in data.'
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
45
85
|
def_delegators :body, :buffer_id
|
46
86
|
def_delegators :body, :total_len
|
47
87
|
def_delegators :body, :in_port
|
48
88
|
def_delegators :body, :reason
|
49
89
|
def_delegators :body, :data
|
90
|
+
|
91
|
+
def parsed_data
|
92
|
+
@parsed_data ||= DataParser.read(data)
|
93
|
+
end
|
94
|
+
|
95
|
+
def source_mac
|
96
|
+
parsed_data.source_mac
|
97
|
+
end
|
98
|
+
|
99
|
+
def destination_mac
|
100
|
+
parsed_data.destination_mac
|
101
|
+
end
|
50
102
|
end
|
51
103
|
end
|
data/lib/pio/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yasuhito Takamiya
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bindata
|
@@ -586,7 +586,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
586
586
|
version: '0'
|
587
587
|
requirements: []
|
588
588
|
rubyforge_project:
|
589
|
-
rubygems_version: 2.
|
589
|
+
rubygems_version: 2.4.3
|
590
590
|
signing_key:
|
591
591
|
specification_version: 4
|
592
592
|
summary: Packet parser and generator.
|