cwmp 0.1.2 → 0.1.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.
- checksums.yaml +8 -8
- data/README.md +1 -1
- data/bin/acs +1 -15
- data/bin/cpe +14 -2
- data/cwmp.gemspec +17 -18
- data/lib/cwmp/acs.rb +49 -5
- data/lib/cwmp/cpe.rb +28 -25
- data/lib/cwmp/message.rb +2 -2
- data/lib/cwmp/version.rb +1 -1
- metadata +6 -44
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YjZmMzY4NjIxNGFmMGMxYjA0ZTMyNzE5YTQ4ZjgwYjRkZTc2NGYzNQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
N2Y1ZjYwMjJmODE2ZDk2OTMxNjEwM2ZhMzU2MzIzNTVlYmE0MmY5Mg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YjBmYjE3ZDg4NDVhODJiZDIyNDIwM2U1NzEyNzBiOTE3Y2UwNTNjOWFiMjAz
|
10
|
+
ZjgwYWI4MjliYzFiYjYxNzlkYTNjMjJhZjRlZDhkMmExNDczZDEzMTZlYzk2
|
11
|
+
ZWU0MjIwOGM5ZGIzMmI0ZjY3NmMxNTYxZmE5NDRjOGM1MDhiZDI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MjVhZjZlZGNmM2M2ZmNlYzAwYzkxYWI3NTk3ZjYyMTlmNGE5NTVmMDVhZmIy
|
14
|
+
Njc0MGQyMWIzMjMyNmNmOGJhOTgzM2NjOGY1Y2I5YzYwOTU0MDBmYWVjMDgz
|
15
|
+
NmMyMzEzMWVhNzQ1NjBjNjI2YTdlY2U0ZGRhMTYzMTlkYjRhMDQ=
|
data/README.md
CHANGED
data/bin/acs
CHANGED
@@ -5,27 +5,13 @@ require 'cwmp'
|
|
5
5
|
|
6
6
|
options = {}
|
7
7
|
o = OptionParser.new
|
8
|
-
o.on('-d', '--daemon', "Start acs daemon") { |b| options['daemon'] = b }
|
9
8
|
o.on('-p', '--port NUM', Integer, 'Server port') { |port| options['port'] = port }
|
10
|
-
o.on('-r', '--reconnect', "Connects to remote daemon via CLI") { |b| options['reconnect'] = b }
|
11
|
-
o.on('-H', '--host HOST', 'Specify host for remote CLI connection') { |host| options['host'] = host }
|
12
9
|
o.on('-h', '--help', 'Server port') { puts o; exit }
|
13
10
|
o.on('-v', '--version', 'Version') { puts "acs v#{Cwmp::VERSION}"; exit }
|
14
11
|
o.parse!
|
15
12
|
|
13
|
+
port = options['port'] || 9321
|
16
14
|
|
17
|
-
# if options['daemon']
|
18
|
-
# port = options['port'] || 9292
|
19
|
-
# puts "Starting ACS Daemon on port #{port}"
|
20
|
-
# Cwmp::Acs.new(port).start
|
21
|
-
# elsif options['reconnect']
|
22
|
-
# url = options['host'] || "http://localhost:9292/api"
|
23
|
-
# puts "Connecting to remote daemon on #{url}"
|
24
|
-
# else
|
25
|
-
# puts o; exit
|
26
|
-
# end
|
27
|
-
|
28
|
-
port = ARGV[0] || 9321
|
29
15
|
puts "Starting ACS Daemon on http://localhost:#{port}"
|
30
16
|
Cwmp::Acs.new(port).start
|
31
17
|
|
data/bin/cpe
CHANGED
@@ -1,9 +1,21 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
+
require 'optparse'
|
3
4
|
require 'cwmp'
|
4
5
|
|
5
|
-
|
6
|
-
|
6
|
+
options = {}
|
7
|
+
o = OptionParser.new
|
8
|
+
o.on('-u', '--url url', 'ACS url to connect') { |url| options['url'] = url}
|
9
|
+
o.on('-p', '--periodic 60', Integer, 'Interval for periodic Inform (0=disable)') { |periodic| options['periodic'] = periodic}
|
10
|
+
o.on('-h', '--help', 'Server port') { puts o; exit }
|
11
|
+
o.on('-v', '--version', 'Version') { puts "cpe v#{Cwmp::VERSION}"; exit }
|
12
|
+
o.parse!
|
13
|
+
|
14
|
+
url = options['url'] || 'http://localhost:9292/acs'
|
15
|
+
periodic_interval = options['periodic'] || 0
|
7
16
|
|
17
|
+
cpe = Cwmp::Cpe.new url, periodic_interval, {:serial => "A54FD"}
|
18
|
+
cpe.poweron
|
8
19
|
cpe.loop
|
9
20
|
|
21
|
+
|
data/cwmp.gemspec
CHANGED
@@ -1,22 +1,21 @@
|
|
1
1
|
require './lib/cwmp/version'
|
2
2
|
|
3
|
-
Gem::Specification.new do |
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = 'cwmp'
|
5
|
+
spec.version = Cwmp::VERSION
|
6
|
+
spec.date = '2014-07-14'
|
7
|
+
spec.summary = "A CWMP library"
|
8
|
+
spec.description = "A ruby library to parse and generate CWMP messages. Includes an ACS server and a CPE simulator."
|
9
|
+
spec.authors = ["Luca Cervasio"]
|
10
|
+
spec.email = 'luca.cervasio@gmail.com'
|
11
|
+
spec.files = `git ls-files`.split($/)
|
12
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
13
|
+
spec.homepage = 'https://github.com/lucacervasio/ruby-cwmp'
|
14
|
+
spec.license = 'MIT'
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
s.add_dependency('faye-websocket', '~> 0.6', '>= 0.6.2')
|
21
|
-
s.add_dependency('httpclient', '~> 2.4', '>= 2.4.0')
|
16
|
+
spec.add_dependency('nokogiri', '~> 1.6', '>= 1.6.0')
|
17
|
+
spec.add_dependency('rack', '~> 1.5', '>= 1.5.2')
|
18
|
+
spec.add_dependency('thin', '~> 1.6', '>= 1.6.2')
|
19
|
+
spec.add_dependency('http_router', '~> 0.11', '>= 0.11.1')
|
20
|
+
spec.add_dependency('httpclient', '~> 2.4', '>= 2.4.0')
|
22
21
|
end
|
data/lib/cwmp/acs.rb
CHANGED
@@ -3,11 +3,12 @@ require 'rack'
|
|
3
3
|
require 'thin'
|
4
4
|
require 'http_router'
|
5
5
|
require 'nokogiri'
|
6
|
+
require 'readline'
|
6
7
|
|
7
8
|
|
8
9
|
module Cwmp
|
9
10
|
|
10
|
-
class
|
11
|
+
class Handler
|
11
12
|
|
12
13
|
def call(env)
|
13
14
|
req = Rack::Request.new(env)
|
@@ -56,15 +57,58 @@ module Cwmp
|
|
56
57
|
@port = port
|
57
58
|
@app = HttpRouter.new do
|
58
59
|
# add('/api').to(SocketApp.new)
|
59
|
-
add('/acs').to(
|
60
|
+
add('/acs').to(Handler.new)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def start_cli
|
65
|
+
|
66
|
+
list = [
|
67
|
+
'GetParameterValues', 'SetParameterValues', 'Reboot', 'FactoryReset', 'Download', 'AddObject', 'DeleteObject',
|
68
|
+
'help', 'quit', "waitMessage"
|
69
|
+
].sort
|
70
|
+
|
71
|
+
comp = proc { |s| list.grep(/^#{Regexp.escape(s)}/) }
|
72
|
+
|
73
|
+
::Readline.completion_append_character = " "
|
74
|
+
::Readline.completion_proc = comp
|
75
|
+
|
76
|
+
while line = ::Readline.readline('> ', true)
|
77
|
+
case line
|
78
|
+
when "quit"
|
79
|
+
puts "Bye"
|
80
|
+
exit(0)
|
81
|
+
when "help"
|
82
|
+
help
|
83
|
+
when "list"
|
84
|
+
puts "list"
|
85
|
+
end
|
60
86
|
end
|
61
87
|
end
|
62
88
|
|
63
89
|
def start
|
64
|
-
|
65
|
-
|
90
|
+
@web = Thread.new do
|
91
|
+
Thin::Logging.silent = true
|
92
|
+
Rack::Handler::Thin.run @app, :Port => @port
|
93
|
+
end
|
94
|
+
|
95
|
+
Thread.new do
|
96
|
+
while true do
|
97
|
+
sleep 1
|
98
|
+
Readline.clear_rl
|
99
|
+
puts "i"
|
100
|
+
Readline.restore
|
101
|
+
end
|
102
|
+
end
|
103
|
+
start_cli
|
66
104
|
end
|
67
105
|
end
|
68
106
|
|
69
107
|
|
70
|
-
|
108
|
+
|
109
|
+
|
110
|
+
end
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
|
data/lib/cwmp/cpe.rb
CHANGED
@@ -4,17 +4,16 @@ require 'socket'
|
|
4
4
|
module Cwmp
|
5
5
|
|
6
6
|
class Cpe
|
7
|
-
|
8
7
|
attr_accessor :serial, :oui, :software_version, :manufacturer, :acs_url, :state
|
9
8
|
|
10
|
-
def initialize (acs_url, h = {})
|
9
|
+
def initialize (acs_url, periodic, h = {})
|
11
10
|
@acs_url = acs_url
|
12
11
|
@serial = h[:serial] || "23434ds"
|
13
12
|
@oui = h[:oui] || "006754"
|
14
13
|
@software_version = h[:software_version] || "0.1.1"
|
15
14
|
@manufacturer = h[:manufacturer] || "Moonar"
|
16
15
|
@state = 'off'
|
17
|
-
@periodic = Thread.new { periodic
|
16
|
+
@periodic = Thread.new { periodic periodic } if periodic > 0
|
18
17
|
@conn_req = Thread.new { connection_request }
|
19
18
|
@factory = true
|
20
19
|
end
|
@@ -47,12 +46,13 @@ module Cwmp
|
|
47
46
|
end
|
48
47
|
|
49
48
|
def loop
|
50
|
-
@
|
49
|
+
@conn_req.join
|
51
50
|
end
|
52
51
|
|
53
52
|
private
|
54
53
|
|
55
54
|
def periodic time
|
55
|
+
puts "setting periodic inform every #{time} seconds"
|
56
56
|
while true
|
57
57
|
sleep time
|
58
58
|
do_connection '2 PERIODIC'
|
@@ -80,31 +80,34 @@ module Cwmp
|
|
80
80
|
end
|
81
81
|
|
82
82
|
def do_connection(event)
|
83
|
-
|
84
|
-
|
85
|
-
puts "sending Inform with event #{event}"
|
86
|
-
resp = c.post @acs_url, Cwmp::Message::inform(@manufacturer, @oui, @serial, event, @software_version)
|
87
|
-
doc = Nokogiri::XML(resp.body)
|
88
|
-
message_type = doc.css("soap|Body").children.map(&:name)[1]
|
89
|
-
puts "got #{message_type} message"
|
83
|
+
begin
|
84
|
+
c = HTTPClient.new
|
90
85
|
|
91
|
-
|
92
|
-
|
86
|
+
puts "sending Inform with event #{event}"
|
87
|
+
resp = c.post @acs_url, Cwmp::Message::inform(@manufacturer, @oui, @serial, event, @software_version), {'User-Agent' => "ruby-cwmp #{Cwmp::VERSION}", "Content-Type" => 'text/xml; charset="utf-8"'}
|
93
88
|
doc = Nokogiri::XML(resp.body)
|
94
|
-
message_type = doc.css("
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
89
|
+
message_type = doc.css("soapenv|Body").children.map(&:name)[1]
|
90
|
+
puts "got #{message_type} message"
|
91
|
+
resp = c.post @acs_url, "", {'User-Agent' => "ruby-cwmp #{Cwmp::VERSION}", "Content-Type" => 'text/xml; charset="utf-8"'}
|
92
|
+
while resp.status != 204
|
93
|
+
doc = Nokogiri::XML(resp.body)
|
94
|
+
message_type = doc.css("soapenv|Body").children.map(&:name)[1]
|
95
|
+
puts "got #{message_type}"
|
96
|
+
case message_type
|
97
|
+
when "GetParameterValues"
|
98
|
+
resp = c.post @acs_url, Cwmp::Message::get_parameter_values_response, {'User-Agent' => "ruby-cwmp #{Cwmp::VERSION}", "Content-Type" => 'text/xml; charset="utf-8"'}
|
99
|
+
when "GetParameterNames"
|
100
|
+
resp = c.post @acs_url, Cwmp::Message::get_parameter_names_response, {'User-Agent' => "ruby-cwmp #{Cwmp::VERSION}", "Content-Type" => 'text/xml; charset="utf-8"'}
|
101
|
+
when "SetParameterValues"
|
102
|
+
resp = c.post @acs_url, Cwmp::Message::set_parameter_values_response, {'User-Agent' => "ruby-cwmp #{Cwmp::VERSION}", "Content-Type" => 'text/xml; charset="utf-8"'}
|
103
|
+
end
|
105
104
|
end
|
105
|
+
puts "got #{resp.status}, closing"
|
106
|
+
c.reset @acs_url
|
107
|
+
rescue Errno::ECONNREFUSED
|
108
|
+
puts "can't connect to #{@acs_url}"
|
109
|
+
exit(1)
|
106
110
|
end
|
107
|
-
puts "got #{resp.status}, closing"
|
108
111
|
end
|
109
112
|
|
110
113
|
end
|
data/lib/cwmp/message.rb
CHANGED
@@ -101,7 +101,7 @@ module Cwmp
|
|
101
101
|
end
|
102
102
|
|
103
103
|
def self.get_parameter_values_response
|
104
|
-
return '<soap:
|
104
|
+
return '<soap:Envelope
|
105
105
|
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
|
106
106
|
xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/"
|
107
107
|
xmlns:cwmp="urn:dslforum-org:cwmp-1-0"
|
@@ -176,7 +176,7 @@ module Cwmp
|
|
176
176
|
end
|
177
177
|
|
178
178
|
def self.get_parameter_names_response
|
179
|
-
return '<soap:
|
179
|
+
return '<soap:Envelope
|
180
180
|
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
|
181
181
|
xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/"
|
182
182
|
xmlns:cwmp="urn:dslforum-org:cwmp-1-0"
|
data/lib/cwmp/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cwmp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luca Cervasio
|
@@ -90,46 +90,6 @@ dependencies:
|
|
90
90
|
- - ! '>='
|
91
91
|
- !ruby/object:Gem::Version
|
92
92
|
version: 0.11.1
|
93
|
-
- !ruby/object:Gem::Dependency
|
94
|
-
name: eventmachine
|
95
|
-
requirement: !ruby/object:Gem::Requirement
|
96
|
-
requirements:
|
97
|
-
- - ~>
|
98
|
-
- !ruby/object:Gem::Version
|
99
|
-
version: '1.0'
|
100
|
-
- - ! '>='
|
101
|
-
- !ruby/object:Gem::Version
|
102
|
-
version: 1.0.3
|
103
|
-
type: :runtime
|
104
|
-
prerelease: false
|
105
|
-
version_requirements: !ruby/object:Gem::Requirement
|
106
|
-
requirements:
|
107
|
-
- - ~>
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
version: '1.0'
|
110
|
-
- - ! '>='
|
111
|
-
- !ruby/object:Gem::Version
|
112
|
-
version: 1.0.3
|
113
|
-
- !ruby/object:Gem::Dependency
|
114
|
-
name: faye-websocket
|
115
|
-
requirement: !ruby/object:Gem::Requirement
|
116
|
-
requirements:
|
117
|
-
- - ~>
|
118
|
-
- !ruby/object:Gem::Version
|
119
|
-
version: '0.6'
|
120
|
-
- - ! '>='
|
121
|
-
- !ruby/object:Gem::Version
|
122
|
-
version: 0.6.2
|
123
|
-
type: :runtime
|
124
|
-
prerelease: false
|
125
|
-
version_requirements: !ruby/object:Gem::Requirement
|
126
|
-
requirements:
|
127
|
-
- - ~>
|
128
|
-
- !ruby/object:Gem::Version
|
129
|
-
version: '0.6'
|
130
|
-
- - ! '>='
|
131
|
-
- !ruby/object:Gem::Version
|
132
|
-
version: 0.6.2
|
133
93
|
- !ruby/object:Gem::Dependency
|
134
94
|
name: httpclient
|
135
95
|
requirement: !ruby/object:Gem::Requirement
|
@@ -150,10 +110,12 @@ dependencies:
|
|
150
110
|
- - ! '>='
|
151
111
|
- !ruby/object:Gem::Version
|
152
112
|
version: 2.4.0
|
153
|
-
description: A ruby library to parse and generate CWMP messages. Includes
|
154
|
-
and a
|
113
|
+
description: A ruby library to parse and generate CWMP messages. Includes an ACS server
|
114
|
+
and a CPE simulator.
|
155
115
|
email: luca.cervasio@gmail.com
|
156
|
-
executables:
|
116
|
+
executables:
|
117
|
+
- acs
|
118
|
+
- cpe
|
157
119
|
extensions: []
|
158
120
|
extra_rdoc_files: []
|
159
121
|
files:
|