openflow-protocol 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/messages/parser.rb +13 -3
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 81bc2fa929616168bb6f53936942ea20f20259a1
4
- data.tar.gz: 99401007e03c7f124a0ccacca7bf2bbf0f692e49
3
+ metadata.gz: 8e7714d41af75fba41ce2f02671fc712eaddb910
4
+ data.tar.gz: 1158656d489227146fa789732a35b309f15e4df2
5
5
  SHA512:
6
- metadata.gz: 22c40db8c808311114b25625cbdc73a3d76947e8041a348a38bf77da9797261101c89815b22087ecd445178aa5d0f1abbbafe349b50270ada4f5efcc293cfc61
7
- data.tar.gz: ddaa75a769912a5fecc453e7cb32ee9423a17b22316bcd0e9ba96b5ad8866a55ad821c70c1f51eb0a41973a6e520b5d0e84199f8a2df04fe6e5108486ebbf57c
6
+ metadata.gz: c884f54f0a7de1a348737bbbc657f6794f3ef636dc865b47f2caf5a061559746b37eca767f7078051bf583b34860c828bf94f6376935423ae47934f9b4ac58cf
7
+ data.tar.gz: ca5f9566a19916c652113b01e10007a2c97317b8a787acef8ff70f7330638e7bcefc19af339811523ffe934420a9abb1f43541545d41ff1376cb2a47b5fb9b75
@@ -1,12 +1,22 @@
1
+ require 'stringio'
2
+
1
3
  Dir[File.expand_path '*.rb', __dir__].each do |file|
2
4
  require_relative file
3
5
  end
4
6
 
5
7
  class OFParser
6
- def self.read(binary)
7
- type = OFMessage::TYPES[binary[1].unpack('C')[0].to_i]
8
+ def self.read(io)
9
+ io = StringIO.new(io) if io.is_a?(String)
10
+
11
+ header = io.readpartial(OFMessage::HEADER_LENGTH)
12
+
13
+ type = OFMessage::TYPES[header[1].unpack('C')[0].to_i]
8
14
  klass_name = 'OF' + type.to_s.split('_').map(&:capitalize).join
9
15
  klass = Object.const_get(klass_name)
10
- klass.read(binary)
16
+ length = header[2..3].unpack('S>')[0].to_i
17
+
18
+ body = io.readpartial(length - OFMessage::HEADER_LENGTH)
19
+
20
+ klass.read(header + body)
11
21
  end
12
22
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openflow-protocol
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jérémy Pagé