openflow 0.0.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e901c508dfc881756eb2e62d15ba56592c79b79a
4
+ data.tar.gz: 92cac247b9f87255d05ff8fc022d0903426fd37e
5
+ SHA512:
6
+ metadata.gz: 0d87bedaf741e05ece6a6c74141b2432b5972d1224b4045b191a7f492dd5b951923e5cbad3a357249e8fdba1c607ce59cd8f31ed20c5aef324564ea5943fccc6
7
+ data.tar.gz: 731f39e899ee9d8c21275f2993021f4e6a45785d475a82dba5256ad6fdbf5b6b669010e961444b3e49a2e2cc5d4c22565225fca9c64d5e0f3ba1708267454dc3
@@ -0,0 +1 @@
1
+ *.rb filter=spabs
@@ -0,0 +1,19 @@
1
+ Gemfile.lock
2
+ *.gem
3
+ *.rbc
4
+ .bundle
5
+ .config
6
+ coverage
7
+ InstalledFiles
8
+ lib/bundler/man
9
+ pkg
10
+ rdoc
11
+ spec/reports
12
+ test/tmp
13
+ test/version_tmp
14
+ tmp
15
+
16
+ # YARD artifacts
17
+ .yardoc
18
+ _yardoc
19
+ doc/
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
4
+ gem 'bit-struct'
5
+
6
+ gem 'rake', group: :test
@@ -0,0 +1,2 @@
1
+ #OpenFlow [![Build Status](https://travis-ci.org/Sovietaced/OpenFlow.png?branch=master)](https://travis-ci.org/Sovietaced/OpenFlow)
2
+ An elegant OpenFlow library written in Ruby
@@ -0,0 +1,12 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'rake/testtask'
5
+
6
+ Rake::TestTask.new(:test) do |test|
7
+ test.libs << 'lib' << 'test'
8
+ test.pattern = 'test/dummy.rb'
9
+ test.verbose = true
10
+ end
11
+
12
+ task :default => :test
File without changes
@@ -0,0 +1,7 @@
1
+ module OpenFlow
2
+ module V10
3
+ class BarrierReply < Message
4
+ initial_value.type = OpenFlow::V10::OFType::BARRIER_REPLY
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module OpenFlow
2
+ module V10
3
+ class BarrierRequest < Message
4
+ initial_value.type = OpenFlow::V10::OFType::BARRIER_REQUEST
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,12 @@
1
+ require 'bit-struct'
2
+
3
+ module OpenFlow
4
+ module V10
5
+ class ConfigFlag
6
+ OFPC_FRAG_NORMAL = 0
7
+ OFPC_FRAG_DROP = 1
8
+ OFPC_FRAG_REASM = 2
9
+ OFPC_FRAG_MASK = 3
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,9 @@
1
+ module OpenFlow
2
+ module V10
3
+ class DescStatsRequest < Message
4
+ # Override Message type
5
+ initial_value.stats_type = 0
6
+ end
7
+ end
8
+ end
9
+
@@ -0,0 +1,10 @@
1
+ module OpenFlow
2
+ module V10
3
+ class EchoReply < Message
4
+ # Override Message type
5
+ initial_value.type = OpenFlow::V10::OFType::ECHO_REPLY
6
+ # New fields
7
+ rest :data, "Data"
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ module OpenFlow
2
+ module V10
3
+ class EchoRequest < Message
4
+ # Override Message type
5
+ initial_value.type = OpenFlow::V10::OFType::ECHO_REQUEST;
6
+ # New fields
7
+ rest :data, "Data"
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,19 @@
1
+ module OpenFlow
2
+ module V10
3
+ class FeaturesReply < Message
4
+ # Override Message type
5
+ initial_value.type = OpenFlow::V10::OFType::FEATURES_REPLY
6
+
7
+ unsigned :datapath_id, 64, "Datapath unique ID"
8
+ unsigned :n_buffers, 32, "Max packets buffered at once"
9
+ unsigned :n_tables, 8, "Number of tables supported by datapath"
10
+ pad :pad, 8, "Align to 64-bits"
11
+ # Features
12
+ unsigned :capabilities, 32, "Bitmap of support ofp_capabilities"
13
+ unsigned :actions, 32, "Bitmap of supported ofp_action_type"
14
+ # Port info
15
+ #struct ofp_phy_port
16
+
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,8 @@
1
+ module OpenFlow
2
+ module V10
3
+ class FeaturesRequest < Message
4
+ # Override Message type
5
+ initial_value.type = OpenFlow::V10::OFType::FEATURES_REQUEST
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,26 @@
1
+ module OpenFlow
2
+ module V10
3
+ class FlowRemoved < Message
4
+ # Override Message type
5
+ initial_value.type = OpenFlow::V10::OFType::FLOW_REMOVED
6
+ #New Fields
7
+ nest :match, OpenFlow::V10::Match, "Match"
8
+ unsigned :cookie, 16, "Opaque controller-issue identifier"
9
+
10
+ unsigned :priority, 16, "Priority level of flow entry"
11
+ unsigned :reason, 8, "One of OFPRR"
12
+ pad :pad, 8, "Align to 32 bits"
13
+
14
+ unsigned :duration_sec, 32, "Time flow was alive in seconds"
15
+ unsigned :duration_nsec, 32, "Time flow was alive in nanoseconds beyond duration_sec"
16
+
17
+ unsigned :idle_timeout, 16, "Idle timeout from original flow"
18
+ pad :pad2, 8, "Align to 64 bits"
19
+
20
+ unsigned :packet_count, 64, "Packet Count"
21
+
22
+ unsigned :byte_count, 64, "Byte Count"
23
+ end
24
+ end
25
+ end
26
+
@@ -0,0 +1,14 @@
1
+ module OpenFlow
2
+ module V10
3
+ class FlowStatsReply < StatsRequest
4
+ # Override Message type
5
+ initial_value.type = OpenFlow::V10::OFType::STATS_REPLY
6
+ initial_value.len = 12
7
+ initial_value.stats_type = 1
8
+ # New Fields
9
+ unsigned :stats_type, 16, "One of the OFPST constants"
10
+ unsigned :flags, 16, "OFPSF_REPLY flags"
11
+ unsigned :body, 8, "Body of the request"
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,12 @@
1
+ module OpenFlow
2
+ module V10
3
+ class FlowStatsRequest < StatsRequest
4
+ # Override Message type
5
+ initial_value.type = OpenFlow::V10::OFType::STATS_REQUEST
6
+ initial_value.stats_type = 1
7
+ # New Fields
8
+ nest :match, OpenFlow::V10::Match, "Match"
9
+ unsigned :table_id, 8, "ID of flow table"
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,8 @@
1
+ module OpenFlow
2
+ module V10
3
+ class GetConfigReply < Message
4
+ # Override Message type
5
+ initial_value.type = OpenFlow::V10::OFType::GET_CONFIG_REPLY
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module OpenFlow
2
+ module V10
3
+ class GetConfigRequest < Message
4
+ # Override Message type
5
+ initial_value.type = OpenFlow::V10::OFType::GET_CONFIG_REQUEST
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module OpenFlow
2
+ module V10
3
+ class Hello < Message
4
+ # Override Message type
5
+ initial_value.type = OpenFlow::V10::OFType::HELLO
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,23 @@
1
+ require 'bit-struct'
2
+
3
+ module OpenFlow
4
+ module V10
5
+ class Match < BitStruct
6
+ unsigned :wildcards, 32, "Wildcard fields"
7
+ unsigned :type, 16, "Input switch port"
8
+ unsigned :dl_src, 8, "Ethernet source address"
9
+ unsigned :dl_dst, 8, "Ethernet destination address"
10
+ unsigned :dl_vlan, 16, "Input VLAN id"
11
+ unsigned :dl_vlan_pcp, 8, "Input VLAN priority"
12
+ pad :pad, 8, "Align to 64 bits"
13
+ unsigned :dl_type, 16, "Ethernet frame type"
14
+ unsigned :nw_tos, 8, "IP ToS (actually DSCP fields, 6 bits)"
15
+ unsigned :nw_proto, 8, "IP protocol or lower 8 bits of ARP opcode"
16
+ pad :pad2, 8, "Align to 64 bits"
17
+ unsigned :nw_src, 32, "IP source address"
18
+ unsigned :nw_dst, 32, "IP destination address"
19
+ unsigned :tp_src, 16, "TCP/UDP source port"
20
+ unsigned :tp_dst, 16, "TCP/UDP destination port"
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,14 @@
1
+ require 'bit-struct'
2
+
3
+ module OpenFlow
4
+ module V10
5
+ class Message < BitStruct
6
+ unsigned :version, 8, "OF Version"
7
+ unsigned :type, 8, "Type"
8
+ unsigned :len, 16, "Message Length"
9
+ unsigned :xid, 32, "Transfer ID"
10
+ # New Fields
11
+ initial_value.version = 1
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,30 @@
1
+ require 'bit-struct'
2
+
3
+ module OpenFlow
4
+ module V10
5
+ class OFType
6
+ HELLO = 0
7
+ ERROR = 1
8
+ ECHO_REQUEST = 2
9
+ ECHO_REPLY = 3
10
+ VENDOR = 4
11
+ FEATURES_REQUEST = 5
12
+ FEATURES_REPLY = 6
13
+ GET_CONFIG_REQUEST = 7
14
+ GET_CONFIG_REPLY = 8
15
+ SET_CONFIG = 9
16
+ PACKET_IN = 10
17
+ FLOW_REMOVED = 11
18
+ PORT_STATUS = 12
19
+ PACKET_OUT = 13
20
+ FLOW_MOD = 14
21
+ PORT_MOD = 15
22
+ STATS_REQUEST = 16
23
+ STATS_REPLY = 17
24
+ BARRIER_REQUESt = 18
25
+ BARRIER_REPLY = 19
26
+ QUEUE_GET_CONFIG_REQUEST = 20
27
+ QUEUE_GET_CONFIG_REPLY = 21
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,52 @@
1
+ require 'bit-struct'
2
+
3
+ module OpenFlow
4
+ module V10
5
+ class PhysicalPort
6
+
7
+ end
8
+
9
+ # ofp_port_config
10
+ class PortConfig
11
+ OFPPC_PORT_DOWN = 1
12
+ OFPPC_NO_STP = 2
13
+ OFPPC_NO_RECV = 4
14
+ OFPPC_NO_RECV_STP = 8
15
+ OFPPC_NO_FLOOD = 16
16
+ OFPPC_NO_FWD = 32
17
+ OFPPC_NO_PACKET_IN = 64
18
+ end
19
+
20
+ # ofp_port_features
21
+ class PortFeatures
22
+ OFPPF_10MB_HD = 1
23
+ OFPPF_10MB_FD = 2
24
+ OFPPF_100MB_HD = 4
25
+ OFPPF_100MB_FD = 8
26
+ OFPPF_1GB_HD = 16
27
+ OFPPF_1GB_FD = 32
28
+ OFPPF_10GB_FD = 64
29
+ OFPPF_COPPER = 128
30
+ OFPPF_FIBER = 256
31
+ OFPPF_AUTONEG = 512
32
+ OFPPF_PAUSE = 1024
33
+ OFPPF_PAUSE_ASYM = 2048
34
+ end
35
+
36
+ # ofp_port_mod_failed_code
37
+ class PortModFailedCode
38
+ OFPPMFC_BAD_PORT = 0
39
+ OFPPMFC_BAD_HW_ADDR = 1
40
+ end
41
+
42
+ # ofp_port_state
43
+ class PortState
44
+ OFPPS_LINK_DOWN = 1
45
+ OFPPS_STP_LISTEN = 0
46
+ OFPPS_STP_LEARN = 256
47
+ OFPPS_STP_FORWARD = 512
48
+ OFPPS_STP_BLOCK = 768
49
+ OFPPS_STP_MASK = 768
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,17 @@
1
+ require 'bit-struct'
2
+
3
+ module OpenFlow
4
+ module V10
5
+ class Port
6
+ OFPP_MAX = 0xff00
7
+ OFPP_IN_PORT = 0xfff8
8
+ OFPP_TABLE = 0xfff9
9
+ OFPP_NORMAL = 0xfffa
10
+ OFPP_FLOOD = 0xfffb
11
+ OFPP_ALL = 0xfffc
12
+ OFPP_CONTROLLER = 0xfffd
13
+ OFPP_LOCAL = 0xfffe
14
+ OFPP_NONE = 0xffff
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,26 @@
1
+ module OpenFlow
2
+ module V10
3
+ class FlowRemoved < Message
4
+ # Override Message type
5
+ initial_value.type = OpenFlow::V10::OFType::FLOW_REMOVED
6
+ #New Fields
7
+ nest :match, OpenFlow::V10::Match, "Match"
8
+ unsigned :cookie, 16, "Opaque controller-issue identifier"
9
+
10
+ unsigned :priority, 16, "Priority level of flow entry"
11
+ unsigned :reason, 8, "One of OFPRR"
12
+ pad :pad, 8, "Align to 32 bits"
13
+
14
+ unsigned :duration_sec, 32, "Time flow was alive in seconds"
15
+ unsigned :duration_nsec, 32, "Time flow was alive in nanoseconds beyond duration_sec"
16
+
17
+ unsigned :idle_timeout, 16, "Idle timeout from original flow"
18
+ pad :pad2, 8, "Align to 64 bits"
19
+
20
+ unsigned :packet_count, 64, "Packet Count"
21
+
22
+ unsigned :byte_count, 64, "Byte Count"
23
+ end
24
+ end
25
+ end
26
+
@@ -0,0 +1,11 @@
1
+ module OpenFlow
2
+ module V10
3
+ class SetConfig < Message
4
+ # Override Message type
5
+ initial_value.type = OpenFlow::V10::OFType::SET_CONFIG
6
+
7
+ unsigned :flags, 16, "OF Port Config Flags"
8
+ unsigned :miss_send_len, 16, "Max bytes of new flow that datapath should send to the controller"
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,23 @@
1
+ module OpenFlow
2
+ module V10
3
+ class Stats < Message
4
+ # Override Message type
5
+ initial_value.len = 12
6
+ # New Fields
7
+ unsigned :stats_type, 16, "Stats type"
8
+ unsigned :flags, 16, "OFPSF_REQ flags"
9
+ unsigned :body, 8, "Request body"
10
+ end
11
+
12
+ # ofp_stats_type
13
+ class StatsType
14
+ ROFPST_DESC = 0
15
+ OFPST_FLOW = 1
16
+ OFPST_AGGREGATE = 2
17
+ OFPST_TABLE = 3
18
+ OFPST_PORT = 4
19
+ OFPST_QUEUE = 5
20
+ OFPST_EXPERIMENTER = 65535
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,12 @@
1
+ module OpenFlow
2
+ module V10
3
+ class StatsReply < Stats
4
+ # Override Message type
5
+ initial_value.type = OpenFlow::V10::OFType::STATS_REPLY
6
+ end
7
+
8
+ class StatsReplyFlag
9
+ REPLY_MORE = 1
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,11 @@
1
+ module OpenFlow
2
+ module V10
3
+ class StatsRequest < Stats
4
+ # Override Message type
5
+ initial_value.type = OpenFlow::V10::OFType::STATS_REQUEST
6
+ end
7
+
8
+ class StatsRequestFlag
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ module OpenFlow
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,25 @@
1
+ require 'socket'
2
+ require './openflow/v10/message'
3
+ require './openflow/v10/hello'
4
+ require './openflow/v10/features_request'
5
+
6
+
7
+ server = TCPServer.open(6666) # Socket to listen on port 2000
8
+ loop { # Servers run forever
9
+ socket = server.accept
10
+ hello = OpenFlow::V10::Hello.new
11
+ hello.len = hello.length
12
+ socket.send(hello, 0)
13
+
14
+ while line = socket.recv(8192) and not line.empty?
15
+ bytes = line.bytes.to_a
16
+ p bytes
17
+ if bytes[1] == 0
18
+ p OpenFlow::V10::Hello.new(line).inspect_detailed
19
+ f = OpenFlow::V10::FeaturesRequest.new
20
+ f.len = hello.length
21
+ socket.send(f, 0)
22
+ end
23
+ end
24
+ socket.close
25
+ }
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "openflow/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "openflow"
7
+ s.version = OpenFlow::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Jason Parraga"]
10
+ s.email = ["Sovietaced@gmail.com"]
11
+ s.homepage = ""
12
+ s.summary = %q{OpenFlow library in Ruby}
13
+ s.description = %q{OpenFlow library in Ruby}
14
+
15
+ s.add_dependency "launchy"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+ end
@@ -0,0 +1,8 @@
1
+ require 'test/unit'
2
+ class Dummy < Test::Unit::TestCase
3
+
4
+ def dummy
5
+ assert_equal true, true
6
+ end
7
+
8
+ end
metadata ADDED
@@ -0,0 +1,93 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: openflow
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Jason Parraga
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: launchy
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: OpenFlow library in Ruby
28
+ email:
29
+ - Sovietaced@gmail.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - .gitattributes
35
+ - .gitignore
36
+ - .travis.yml
37
+ - Gemfile
38
+ - README.md
39
+ - Rakefile
40
+ - lib/openflow.rb
41
+ - lib/openflow/V10/barrier_reply.rb
42
+ - lib/openflow/V10/barrier_request.rb
43
+ - lib/openflow/V10/config_flag.rb
44
+ - lib/openflow/V10/desc_stats.rb
45
+ - lib/openflow/V10/echo_reply.rb
46
+ - lib/openflow/V10/echo_request.rb
47
+ - lib/openflow/V10/features_reply.rb
48
+ - lib/openflow/V10/features_request.rb
49
+ - lib/openflow/V10/flow_removed.rb
50
+ - lib/openflow/V10/flow_stats_reply.rb
51
+ - lib/openflow/V10/flow_stats_request.rb
52
+ - lib/openflow/V10/get_config_reply.rb
53
+ - lib/openflow/V10/get_config_request.rb
54
+ - lib/openflow/V10/hello.rb
55
+ - lib/openflow/V10/match.rb
56
+ - lib/openflow/V10/message.rb
57
+ - lib/openflow/V10/oftype.rb
58
+ - lib/openflow/V10/physical_port.rb
59
+ - lib/openflow/V10/port.rb
60
+ - lib/openflow/V10/port_status.rb
61
+ - lib/openflow/V10/set_config.rb
62
+ - lib/openflow/V10/stats.rb
63
+ - lib/openflow/V10/stats_reply.rb
64
+ - lib/openflow/V10/stats_request.rb
65
+ - lib/openflow/version.rb
66
+ - lib/test.rb
67
+ - openflow.gemspec
68
+ - test/dummy.rb
69
+ homepage: ''
70
+ licenses: []
71
+ metadata: {}
72
+ post_install_message:
73
+ rdoc_options: []
74
+ require_paths:
75
+ - lib
76
+ required_ruby_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - '>='
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ required_rubygems_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ requirements: []
87
+ rubyforge_project:
88
+ rubygems_version: 2.1.11
89
+ signing_key:
90
+ specification_version: 4
91
+ summary: OpenFlow library in Ruby
92
+ test_files:
93
+ - test/dummy.rb