cwmp 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +1 -0
- data/Gemfile +3 -0
- data/LICENSE +21 -0
- data/README.md +5 -0
- data/bin/acs +32 -0
- data/bin/cpe +9 -0
- data/cwmp.gemspec +21 -0
- data/lib/cwmp.rb +4 -0
- data/lib/cwmp/acs.rb +70 -0
- data/lib/cwmp/cpe.rb +114 -0
- data/lib/cwmp/message.rb +270 -0
- data/lib/cwmp/version.rb +3 -0
- metadata +177 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZDhhZTIyNjA2OWM5MmI3NTQ2ZDQxMmZiMWRiYTZmNzVmOWRjZDlhYg==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MWQ0NTNjYzAzMWE0ZDlhZWJiZWM2ZDQ1MmVlNjBmMjhiNWQzODc2Ng==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ZTYxNTRiYTBkZjYwMmI4NThhYTM0YTZjODc2MWNlODA5YTJjZjk3ZDBiZTA5
|
10
|
+
ZTgzNTRmNDJjNmU0MWIzYWE0M2EyZTAyYzBiY2YwMTI4MWJiNDQ1MzIxODFk
|
11
|
+
NDM1M2VhZGRjYjVmOTE5MTdmYjk3MjFjN2RkNzVhMTQxZjBiN2U=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NDVlMWI1NTk2NDM4MDUwM2U0ZDJiNWM3YzQxZjc4ZTA4YzliNjJkYTM5ZWNj
|
14
|
+
MmQ0NDU4YWQxOGJjODUzZDI5MDkxZDVkMTYxOGRiOWIxNTczNGQ5NTM4MWE0
|
15
|
+
YTkxYzBkZWM4ODgzYWI4ZmQ0OTE1MTc5ZDhhODlmNWNhMGRkYmI=
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
.idea
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2014 Luca Cervasio
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
data/bin/acs
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
require 'cwmp'
|
5
|
+
|
6
|
+
options = {}
|
7
|
+
o = OptionParser.new
|
8
|
+
o.on('-d', '--daemon', "Start Moses daemon server") { |b| options['daemon'] = b }
|
9
|
+
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
|
+
o.on('-h', '--help', 'Server port') { puts o; exit }
|
13
|
+
o.on('-v', '--version', 'Version') { puts "Moses v#{Moses::VERSION}"; exit }
|
14
|
+
o.parse!
|
15
|
+
|
16
|
+
|
17
|
+
# if options['daemon']
|
18
|
+
# port = options['port'] || 9292
|
19
|
+
# puts "Starting Moses ACS Daemon on port #{port}"
|
20
|
+
# Moses::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
|
+
# Moses::CLI.new.start
|
25
|
+
# else
|
26
|
+
# puts o; exit
|
27
|
+
# end
|
28
|
+
|
29
|
+
port = ARGV[0] || 9321
|
30
|
+
puts "Starting ACS Daemon on http://localhost:#{port}"
|
31
|
+
Cwmp::Acs.new(port).start
|
32
|
+
|
data/bin/cpe
ADDED
data/cwmp.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require './lib/cwmp/version'
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = 'cwmp'
|
5
|
+
s.version = Cwmp::VERSION
|
6
|
+
s.date = '2014-07-14'
|
7
|
+
s.summary = "A CWMP library"
|
8
|
+
s.description = "A ruby library to parse and generate CWMP messages. Includes a CPE simulator and a simple ACS server."
|
9
|
+
s.authors = ["Luca Cervasio"]
|
10
|
+
s.email = 'luca.cervasio@gmail.com'
|
11
|
+
s.files = `git ls-files`.split($/)
|
12
|
+
s.homepage = 'https://github.com/lucacervasio/ruby-cwmp'
|
13
|
+
s.license = 'MIT'
|
14
|
+
|
15
|
+
s.add_dependency('nokogiri', '~> 1.6', '>= 1.6.0')
|
16
|
+
s.add_dependency('rack', '~> 1.5', '>= 1.5.2')
|
17
|
+
s.add_dependency('thin', '~> 1.6', '>= 1.6.2')
|
18
|
+
s.add_dependency('http_router', '~> 0.11', '>= 0.11.1')
|
19
|
+
s.add_dependency('eventmachine', '~> 1.0', '>= 1.0.3')
|
20
|
+
s.add_dependency('faye-websocket', '~> 0.6', '>= 0.6.2')
|
21
|
+
end
|
data/lib/cwmp.rb
ADDED
data/lib/cwmp/acs.rb
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rack'
|
3
|
+
require 'thin'
|
4
|
+
require 'http_router'
|
5
|
+
require 'nokogiri'
|
6
|
+
|
7
|
+
|
8
|
+
module Cwmp
|
9
|
+
|
10
|
+
class WebApp
|
11
|
+
|
12
|
+
def call(env)
|
13
|
+
req = Rack::Request.new(env)
|
14
|
+
len = req.content_length.to_i
|
15
|
+
|
16
|
+
if len == 0
|
17
|
+
message_type = ''
|
18
|
+
else
|
19
|
+
doc = Nokogiri::XML(req.body.read)
|
20
|
+
message_type = doc.css("soap|Body").children.map(&:name)[1]
|
21
|
+
end
|
22
|
+
|
23
|
+
if message_type == "Inform"
|
24
|
+
manufacturer = doc.css("Manufacturer").text
|
25
|
+
oui = doc.css("OUI").text
|
26
|
+
serial_number = doc.css("SerialNumber").text
|
27
|
+
event_codes = doc.css("EventCode").map { |n| n.text }
|
28
|
+
parameters = {}
|
29
|
+
doc.css("ParameterValueStruct").map { |it| parameters[it.children[1].text] = it.children[3].text }
|
30
|
+
|
31
|
+
puts "got Inform from #{req.ip}:#{req.port} [sn #{serial_number}] with eventcodes #{event_codes.join(", ")}"
|
32
|
+
|
33
|
+
inform_response = Cwmp::Message::inform_response
|
34
|
+
response = Rack::Response.new inform_response, 200, {'Connection' => 'Keep-Alive', 'Server' => 'Moses'}
|
35
|
+
response.set_cookie("sessiontrack", {:value => "294823094lskdfsfsdf", :path => "/", :expires => Time.now+24*60*60})
|
36
|
+
response.finish
|
37
|
+
elsif message_type == "TransferComplete"
|
38
|
+
puts "got TransferComplete"
|
39
|
+
else
|
40
|
+
if message_type.include? "Response"
|
41
|
+
puts "got #{message_type}"
|
42
|
+
elsif len == 0
|
43
|
+
puts "got Empty Post"
|
44
|
+
end
|
45
|
+
|
46
|
+
# Got Empty Post or a Response. Now check for any event to send, otherwise 204
|
47
|
+
[204, {"Connection" => "Close", 'Server' => 'Moses'}, ""]
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
class Acs
|
55
|
+
def initialize (port)
|
56
|
+
@port = port
|
57
|
+
@app = HttpRouter.new do
|
58
|
+
# add('/api').to(SocketApp.new)
|
59
|
+
add('/acs').to(WebApp.new)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def start
|
64
|
+
Thin::Logging.silent = true
|
65
|
+
Rack::Handler::Thin.run @app, :Port => @port
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
|
70
|
+
end
|
data/lib/cwmp/cpe.rb
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
require 'httpclient'
|
2
|
+
require 'socket'
|
3
|
+
|
4
|
+
module Cwmp
|
5
|
+
|
6
|
+
class Cpe
|
7
|
+
|
8
|
+
attr_accessor :serial, :oui, :software_version, :manufacturer, :acs_url, :state
|
9
|
+
|
10
|
+
def initialize (acs_url, h = {})
|
11
|
+
@acs_url = acs_url
|
12
|
+
@serial = h[:serial] || "23434ds"
|
13
|
+
@oui = h[:oui] || "006754"
|
14
|
+
@software_version = h[:software_version] || "0.1.1"
|
15
|
+
@manufacturer = h[:manufacturer] || "Moonar"
|
16
|
+
@state = 'off'
|
17
|
+
@periodic = Thread.new { periodic 30 }
|
18
|
+
@conn_req = Thread.new { connection_request }
|
19
|
+
@factory = true
|
20
|
+
end
|
21
|
+
|
22
|
+
def poweron
|
23
|
+
@state = 'on'
|
24
|
+
if @factory
|
25
|
+
do_connection '0 BOOTSTRAP'
|
26
|
+
else
|
27
|
+
do_connection '1 BOOT'
|
28
|
+
end
|
29
|
+
@factory = false
|
30
|
+
end
|
31
|
+
|
32
|
+
def poweroff
|
33
|
+
@state = 'off'
|
34
|
+
end
|
35
|
+
|
36
|
+
def reboot
|
37
|
+
@state = 'off'
|
38
|
+
sleep 2
|
39
|
+
@state = 'on'
|
40
|
+
do_connection '1 BOOT'
|
41
|
+
end
|
42
|
+
|
43
|
+
def reset
|
44
|
+
poweroff
|
45
|
+
@factory = true
|
46
|
+
poweron
|
47
|
+
end
|
48
|
+
|
49
|
+
def loop
|
50
|
+
@periodic.join
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def periodic time
|
56
|
+
while true
|
57
|
+
sleep time
|
58
|
+
do_connection '2 PERIODIC'
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def connection_request
|
63
|
+
server = TCPServer.open(9600)
|
64
|
+
while true
|
65
|
+
client = server.accept
|
66
|
+
|
67
|
+
response = "<html>...</html>"
|
68
|
+
headers = ["HTTP/1.0 200 OK",
|
69
|
+
"Content-Type: text/html",
|
70
|
+
"Content-Length: #{response.length}"].join("\r\n")
|
71
|
+
|
72
|
+
client.puts headers
|
73
|
+
client.puts "\r\n\r\n"
|
74
|
+
client.puts response
|
75
|
+
|
76
|
+
client.close
|
77
|
+
|
78
|
+
do_connection '6 CONNECTION REQUEST'
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def do_connection(event)
|
83
|
+
c = HTTPClient.new
|
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"
|
90
|
+
|
91
|
+
resp = c.post @acs_url, ""
|
92
|
+
while resp.status != 204
|
93
|
+
doc = Nokogiri::XML(resp.body)
|
94
|
+
message_type = doc.css("soap|Body").children.map(&:name)[1]
|
95
|
+
case message_type
|
96
|
+
when "GetParameterValues"
|
97
|
+
puts "got #{message_type}"
|
98
|
+
resp = c.post @acs_url, Cwmp::Message::get_parameter_values_response
|
99
|
+
when "GetParameterNames"
|
100
|
+
puts "got #{message_type}"
|
101
|
+
resp = c.post @acs_url, Cwmp::Message::get_parameter_names_response
|
102
|
+
when "SetParameterValues"
|
103
|
+
puts "got #{message_type}"
|
104
|
+
resp = c.post @acs_url, Cwmp::Message::set_parameter_values_response
|
105
|
+
end
|
106
|
+
end
|
107
|
+
puts "got #{resp.status}, closing"
|
108
|
+
end
|
109
|
+
|
110
|
+
|
111
|
+
end
|
112
|
+
|
113
|
+
|
114
|
+
end
|
data/lib/cwmp/message.rb
ADDED
@@ -0,0 +1,270 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
|
3
|
+
module Cwmp
|
4
|
+
class Message
|
5
|
+
NAMESPACES = {"xmlns:soap" => "http://schemas.xmlsoap.org/soap/envelope/", "xmlns:soap-enc" => "http://schemas.xmlsoap.org/soap/encoding/", "xmlns:cwmp" => "urn:dslforum-org:cwmp-1-0", "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance", "xml:xsd" => "http://www.w3.org/2001/XMLSchema", "xmlns" => "urn:dslforum-org:cwmp-1-0"}
|
6
|
+
|
7
|
+
def self.inform(manufacturer, oui, serial, eventcodes, software_version)
|
8
|
+
return '<?xml version="1.0" encoding="UTF-8"?>
|
9
|
+
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
|
10
|
+
xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:cwmp="urn:dslforum-org:cwmp-1-0"
|
11
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
12
|
+
<soap:Header/>
|
13
|
+
<soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
|
14
|
+
<cwmp:Inform>
|
15
|
+
<DeviceId>
|
16
|
+
<Manufacturer>'+manufacturer+'</Manufacturer>
|
17
|
+
<OUI>'+oui+'</OUI>
|
18
|
+
<ProductClass>Router</ProductClass>
|
19
|
+
<SerialNumber>'+serial+'</SerialNumber>
|
20
|
+
</DeviceId>
|
21
|
+
<Event>
|
22
|
+
<EventStruct>
|
23
|
+
<EventCode>'+eventcodes+'</EventCode>
|
24
|
+
<CommandKey/>
|
25
|
+
</EventStruct>
|
26
|
+
</Event>
|
27
|
+
<MaxEnvelopes>1</MaxEnvelopes>
|
28
|
+
<CurrentTime>2003-01-01T05:36:55Z</CurrentTime>
|
29
|
+
<RetryCount>0</RetryCount>
|
30
|
+
<ParameterList soap-enc:arrayType="cwmp:ParameterValueStruct[7]">
|
31
|
+
<ParameterValueStruct xsi:type="cwmp:ParameterValueStruct">
|
32
|
+
<Name>InternetGatewayDevice.DeviceInfo.HardwareVersion</Name>
|
33
|
+
<Value xsi:type="xsd:string">MNR001</Value>
|
34
|
+
</ParameterValueStruct>
|
35
|
+
<ParameterValueStruct xsi:type="cwmp:ParameterValueStruct">
|
36
|
+
<Name>InternetGatewayDevice.DeviceInfo.ProvisioningCode</Name>
|
37
|
+
<Value xsi:type="xsd:string">ABCD</Value>
|
38
|
+
</ParameterValueStruct>
|
39
|
+
<ParameterValueStruct xsi:type="cwmp:ParameterValueStruct">
|
40
|
+
<Name>InternetGatewayDevice.DeviceInfo.SoftwareVersion</Name>
|
41
|
+
<Value xsi:type="xsd:string">'+software_version+'</Value>
|
42
|
+
</ParameterValueStruct>
|
43
|
+
<ParameterValueStruct xsi:type="cwmp:ParameterValueStruct">
|
44
|
+
<Name>InternetGatewayDevice.DeviceInfo.SpecVersion</Name>
|
45
|
+
<Value xsi:type="xsd:string">1.0</Value>
|
46
|
+
</ParameterValueStruct>
|
47
|
+
<ParameterValueStruct xsi:type="cwmp:ParameterValueStruct">
|
48
|
+
<Name>InternetGatewayDevice.ManagementServer.ConnectionRequestURL</Name>
|
49
|
+
<Value xsi:type="xsd:string">http://127.0.0.1:9600/'+serial+'</Value>
|
50
|
+
</ParameterValueStruct>
|
51
|
+
<ParameterValueStruct xsi:type="cwmp:ParameterValueStruct">
|
52
|
+
<Name>InternetGatewayDevice.ManagementServer.ParameterKey</Name>
|
53
|
+
<Value xsi:type="xsd:string"/>
|
54
|
+
</ParameterValueStruct>
|
55
|
+
<ParameterValueStruct xsi:type="cwmp:ParameterValueStruct">
|
56
|
+
<Name>InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress
|
57
|
+
</Name>
|
58
|
+
<Value xsi:type="xsd:string">10.19.0.'+serial+'</Value>
|
59
|
+
</ParameterValueStruct>
|
60
|
+
</ParameterList>
|
61
|
+
</cwmp:Inform>
|
62
|
+
</soap:Body>
|
63
|
+
</soap:Envelope>'
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.inform_response
|
67
|
+
b = Nokogiri::XML::Builder.new
|
68
|
+
|
69
|
+
b[:soap].Envelope(NAMESPACES) {
|
70
|
+
b[:soap].Header {}
|
71
|
+
b[:soap].Body {
|
72
|
+
b[:cwmp].InformResponse() {}
|
73
|
+
}
|
74
|
+
}
|
75
|
+
|
76
|
+
return b.to_xml
|
77
|
+
end
|
78
|
+
|
79
|
+
def self.get_parameter_values (leaves)
|
80
|
+
b = Nokogiri::XML::Builder.new
|
81
|
+
|
82
|
+
b[:soap].Envelope(NAMESPACES) {
|
83
|
+
b[:soap].Header {}
|
84
|
+
b[:soap].Body {
|
85
|
+
|
86
|
+
b[:cwmp].GetParameterValues() {
|
87
|
+
b.ParameterNames({"soap-enc:arrayType" => "cwmp:string[#{leaves.kind_of?(Array) ? leaves.size : '1'}]"}) {
|
88
|
+
if leaves.kind_of?(Array)
|
89
|
+
leaves.each do |leaf|
|
90
|
+
b.string leaf
|
91
|
+
end
|
92
|
+
else
|
93
|
+
b.string leaves
|
94
|
+
end
|
95
|
+
}
|
96
|
+
}
|
97
|
+
}
|
98
|
+
}
|
99
|
+
|
100
|
+
return b.to_xml
|
101
|
+
end
|
102
|
+
|
103
|
+
def self.get_parameter_values_response
|
104
|
+
return '<soap:Envelopeesacs.org:9292>
|
105
|
+
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
|
106
|
+
xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/"
|
107
|
+
xmlns:cwmp="urn:dslforum-org:cwmp-1-0"
|
108
|
+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
109
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
110
|
+
<soap:Header>
|
111
|
+
<cwmp:ID soap:mustUnderstand="1"></cwmp:ID>
|
112
|
+
</soap:Header>
|
113
|
+
<soap:Body>
|
114
|
+
<cwmp:GetParameterValuesResponse>
|
115
|
+
<ParameterList soap-enc:arrayType="cwmp:ParameterValueStruct[5]">
|
116
|
+
<ParameterValueStruct>
|
117
|
+
<Name>InternetGatewayDevice.Time.NTPServer1</Name>
|
118
|
+
<Value xsi:type="xsd:string">pool.ntp.org</Value>
|
119
|
+
</ParameterValueStruct>
|
120
|
+
<ParameterValueStruct>
|
121
|
+
<Name>InternetGatewayDevice.Time.CurrentLocalTime</Name>
|
122
|
+
<Value xsi:type="xsd:dateTime">2014-07-11T09:08:25</Value>
|
123
|
+
</ParameterValueStruct>
|
124
|
+
<ParameterValueStruct>
|
125
|
+
<Name>InternetGatewayDevice.Time.LocalTimeZone</Name>
|
126
|
+
<Value xsi:type="xsd:string">+00:00</Value>
|
127
|
+
</ParameterValueStruct>
|
128
|
+
<ParameterValueStruct>
|
129
|
+
<Name>InternetGatewayDevice.Time.LocalTimeZoneName</Name>
|
130
|
+
<Value xsi:type="xsd:string">Greenwich Mean Time : Dublin</Value>
|
131
|
+
</ParameterValueStruct>
|
132
|
+
<ParameterValueStruct>
|
133
|
+
<Name>InternetGatewayDevice.Time.DaylightSavingsUsed</Name>
|
134
|
+
<Value xsi:type="xsd:boolean">0</Value>
|
135
|
+
</ParameterValueStruct>
|
136
|
+
</ParameterList>
|
137
|
+
</cwmp:GetParameterValuesResponse>
|
138
|
+
</soap:Body>
|
139
|
+
</soap:Envelope>'
|
140
|
+
end
|
141
|
+
|
142
|
+
def self.set_parameter_values (leaves)
|
143
|
+
b = Nokogiri::XML::Builder.new
|
144
|
+
|
145
|
+
b[:soap].Envelope(NAMESPACES) {
|
146
|
+
b[:soap].Header {}
|
147
|
+
b[:soap].Body {
|
148
|
+
|
149
|
+
b[:cwmp].SetParameterValues() {
|
150
|
+
b.ParameterList({"soap-enc:arrayType" => "cwmp:ParameterValueStruct[#{leaves[0].kind_of?(Array) ? leaves.size : '1'}]"}) {
|
151
|
+
if leaves[0].kind_of?(Array)
|
152
|
+
leaves.each do |leaf|
|
153
|
+
b.ParameterValueStruct {
|
154
|
+
b.Name leaf[0]
|
155
|
+
b.Value leaf[1]
|
156
|
+
}
|
157
|
+
end
|
158
|
+
else
|
159
|
+
b.ParameterValueStruct {
|
160
|
+
b.Name leaves[0]
|
161
|
+
b.Value leaves[1]
|
162
|
+
}
|
163
|
+
end
|
164
|
+
b.ParameterKey "asdads"
|
165
|
+
}
|
166
|
+
}
|
167
|
+
}
|
168
|
+
}
|
169
|
+
|
170
|
+
return b.to_xml
|
171
|
+
end
|
172
|
+
|
173
|
+
|
174
|
+
def self.set_parameter_values_response
|
175
|
+
return ''
|
176
|
+
end
|
177
|
+
|
178
|
+
def self.get_parameter_names_response
|
179
|
+
return '<soap:Envelopeesacs.org:9292>
|
180
|
+
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
|
181
|
+
xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/"
|
182
|
+
xmlns:cwmp="urn:dslforum-org:cwmp-1-0"
|
183
|
+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
184
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
185
|
+
<soap:Header>
|
186
|
+
<cwmp:ID soap:mustUnderstand="1"></cwmp:ID>
|
187
|
+
</soap:Header>
|
188
|
+
<soap:Body>
|
189
|
+
<cwmp:GetParameterNamesResponse>
|
190
|
+
<ParameterList soap-enc:arrayType="cwmp:ParameterInfoStruct[17]">
|
191
|
+
<ParameterInfoStruct>
|
192
|
+
<Name>InternetGatewayDevice.LANDeviceNumberOfEntries</Name>
|
193
|
+
<Writable>0</Writable>
|
194
|
+
</ParameterInfoStruct>
|
195
|
+
<ParameterInfoStruct>
|
196
|
+
<Name>InternetGatewayDevice.WANDeviceNumberOfEntries</Name>
|
197
|
+
<Writable>0</Writable>
|
198
|
+
</ParameterInfoStruct>
|
199
|
+
<ParameterInfoStruct>
|
200
|
+
<Name>InternetGatewayDevice.DeviceInfo.</Name>
|
201
|
+
<Writable>0</Writable>
|
202
|
+
</ParameterInfoStruct>
|
203
|
+
<ParameterInfoStruct>
|
204
|
+
<Name>InternetGatewayDevice.ManagementServer.</Name>
|
205
|
+
<Writable>0</Writable>
|
206
|
+
</ParameterInfoStruct>
|
207
|
+
<ParameterInfoStruct>
|
208
|
+
<Name>InternetGatewayDevice.Time.</Name>
|
209
|
+
<Writable>0</Writable>
|
210
|
+
</ParameterInfoStruct>
|
211
|
+
<ParameterInfoStruct>
|
212
|
+
<Name>InternetGatewayDevice.Layer3Forwarding.</Name>
|
213
|
+
<Writable>0</Writable>
|
214
|
+
</ParameterInfoStruct>
|
215
|
+
<ParameterInfoStruct>
|
216
|
+
<Name>InternetGatewayDevice.LANDevice.</Name>
|
217
|
+
<Writable>0</Writable>
|
218
|
+
</ParameterInfoStruct>
|
219
|
+
<ParameterInfoStruct>
|
220
|
+
<Name>InternetGatewayDevice.WANDevice.</Name>
|
221
|
+
<Writable>0</Writable>
|
222
|
+
</ParameterInfoStruct>
|
223
|
+
<ParameterInfoStruct>
|
224
|
+
<Name>InternetGatewayDevice.X_00507F_InternetAcc.</Name>
|
225
|
+
<Writable>0</Writable>
|
226
|
+
</ParameterInfoStruct>
|
227
|
+
<ParameterInfoStruct>
|
228
|
+
<Name>InternetGatewayDevice.X_00507F_LAN.</Name>
|
229
|
+
<Writable>0</Writable>
|
230
|
+
</ParameterInfoStruct>
|
231
|
+
<ParameterInfoStruct>
|
232
|
+
<Name>InternetGatewayDevice.X_00507F_NAT.</Name>
|
233
|
+
<Writable>0</Writable>
|
234
|
+
</ParameterInfoStruct>
|
235
|
+
<ParameterInfoStruct>
|
236
|
+
<Name>InternetGatewayDevice.X_00507F_VLAN.</Name>
|
237
|
+
<Writable>0</Writable>
|
238
|
+
</ParameterInfoStruct>
|
239
|
+
<ParameterInfoStruct>
|
240
|
+
<Name>InternetGatewayDevice.X_00507F_Firewall.</Name>
|
241
|
+
<Writable>0</Writable>
|
242
|
+
</ParameterInfoStruct>
|
243
|
+
<ParameterInfoStruct>
|
244
|
+
<Name>InternetGatewayDevice.X_00507F_Applications.</Name>
|
245
|
+
<Writable>0</Writable>
|
246
|
+
</ParameterInfoStruct>
|
247
|
+
<ParameterInfoStruct>
|
248
|
+
<Name>InternetGatewayDevice.X_00507F_System.</Name>
|
249
|
+
<Writable>0</Writable>
|
250
|
+
</ParameterInfoStruct>
|
251
|
+
<ParameterInfoStruct>
|
252
|
+
<Name>InternetGatewayDevice.X_00507F_Status.</Name>
|
253
|
+
<Writable>0</Writable>
|
254
|
+
</ParameterInfoStruct>
|
255
|
+
<ParameterInfoStruct>
|
256
|
+
<Name>InternetGatewayDevice.X_00507F_Diagnostics.</Name>
|
257
|
+
<Writable>0</Writable>
|
258
|
+
</ParameterInfoStruct>
|
259
|
+
</ParameterList>
|
260
|
+
</cwmp:GetParameterNamesResponse>
|
261
|
+
</soap:Body>
|
262
|
+
</soap:Envelope>'
|
263
|
+
end
|
264
|
+
end
|
265
|
+
end
|
266
|
+
|
267
|
+
|
268
|
+
# puts Moses::Message::inform_response
|
269
|
+
# puts Moses::Message::get_parameter_values ["Device.", "as"]
|
270
|
+
# puts Moses::Message::set_parameter_values [["Device.Time", "now"], ["Device.Harder", "asdasdasd"]]
|
data/lib/cwmp/version.rb
ADDED
metadata
ADDED
@@ -0,0 +1,177 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cwmp
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Luca Cervasio
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-07-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: nokogiri
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.6.0
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.6'
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.6.0
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: rack
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ~>
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '1.5'
|
40
|
+
- - ! '>='
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 1.5.2
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ~>
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '1.5'
|
50
|
+
- - ! '>='
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 1.5.2
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: thin
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ~>
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '1.6'
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 1.6.2
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '1.6'
|
70
|
+
- - ! '>='
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: 1.6.2
|
73
|
+
- !ruby/object:Gem::Dependency
|
74
|
+
name: http_router
|
75
|
+
requirement: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ~>
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0.11'
|
80
|
+
- - ! '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.11.1
|
83
|
+
type: :runtime
|
84
|
+
prerelease: false
|
85
|
+
version_requirements: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ~>
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.11'
|
90
|
+
- - ! '>='
|
91
|
+
- !ruby/object:Gem::Version
|
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
|
+
description: A ruby library to parse and generate CWMP messages. Includes a CPE simulator
|
134
|
+
and a simple ACS server.
|
135
|
+
email: luca.cervasio@gmail.com
|
136
|
+
executables: []
|
137
|
+
extensions: []
|
138
|
+
extra_rdoc_files: []
|
139
|
+
files:
|
140
|
+
- .gitignore
|
141
|
+
- Gemfile
|
142
|
+
- LICENSE
|
143
|
+
- README.md
|
144
|
+
- bin/acs
|
145
|
+
- bin/cpe
|
146
|
+
- cwmp.gemspec
|
147
|
+
- lib/cwmp.rb
|
148
|
+
- lib/cwmp/acs.rb
|
149
|
+
- lib/cwmp/cpe.rb
|
150
|
+
- lib/cwmp/message.rb
|
151
|
+
- lib/cwmp/version.rb
|
152
|
+
homepage: https://github.com/lucacervasio/ruby-cwmp
|
153
|
+
licenses:
|
154
|
+
- MIT
|
155
|
+
metadata: {}
|
156
|
+
post_install_message:
|
157
|
+
rdoc_options: []
|
158
|
+
require_paths:
|
159
|
+
- lib
|
160
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
161
|
+
requirements:
|
162
|
+
- - ! '>='
|
163
|
+
- !ruby/object:Gem::Version
|
164
|
+
version: '0'
|
165
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
166
|
+
requirements:
|
167
|
+
- - ! '>='
|
168
|
+
- !ruby/object:Gem::Version
|
169
|
+
version: '0'
|
170
|
+
requirements: []
|
171
|
+
rubyforge_project:
|
172
|
+
rubygems_version: 2.2.2
|
173
|
+
signing_key:
|
174
|
+
specification_version: 4
|
175
|
+
summary: A CWMP library
|
176
|
+
test_files: []
|
177
|
+
has_rdoc:
|