cwmp 0.2.0 → 0.2.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.
- checksums.yaml +8 -8
- data/client_xmpp_ruby.rb +37 -0
- data/lib/cwmp/cpe.rb +64 -4
- data/lib/cwmp/message.rb +24 -3
- data/lib/cwmp/version.rb +2 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZGNiMDdmODQyNzE1M2RhYjYxYmI2ZDlmYjA0YTEwNGQ3MDg0MWQ1NA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OGNkZDYwZmM2MmM4YjIyZWIyZWRiY2QwNGYwZTU2MzU4NzUzOWE4MA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YWMxNjUzNDJmYjNlYmY1MDMwZDg4ZWY2MGJlMGY3OGI1Mjk3M2EyMWIyZWM3
|
10
|
+
YmE5MjZiMDQxNTQ1ZmVlYTNlNmRkNTFjMTE5ZmNkOGM2ZjQ0ZDliM2VmMTU1
|
11
|
+
ZmVkNTkzNWZmNzkxZDcwMTdkYzU4MjkzMGE5NDMyYWM4M2Q4MjI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZDVjMzAwNmFiM2I2YjcyNGY3MjVmZGM3ZDQ2NzVkNGI3NTkwODM5ZTUwNzIy
|
14
|
+
YzgxNTJkMGYxOGU1YjMzMDYwZDEwYWI0ZDI2Y2E2ZjNmODI3OTI2NzBlOTIz
|
15
|
+
NWI4MTllZTc1YWMzMzZjMTdhNzhmNjc5ZWUxNDY2NWY5ODVjMDY=
|
data/client_xmpp_ruby.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
# This bot will reply to every message it receives. To end the game, send 'exit'
|
4
|
+
|
5
|
+
$:.unshift '../../../../../lib'
|
6
|
+
|
7
|
+
require 'xmpp4r/client'
|
8
|
+
include Jabber
|
9
|
+
|
10
|
+
# settings
|
11
|
+
if ARGV.length != 2
|
12
|
+
puts "Run with ./echo_thread.rb user@server/resource password"
|
13
|
+
exit 1
|
14
|
+
end
|
15
|
+
myJID = JID.new(ARGV[0])
|
16
|
+
myPassword = ARGV[1]
|
17
|
+
cl = Client.new(myJID)
|
18
|
+
cl.connect
|
19
|
+
cl.auth(myPassword)
|
20
|
+
cl.send(Presence.new)
|
21
|
+
puts "Connected ! send messages to #{myJID.strip.to_s}."
|
22
|
+
mainthread = Thread.current
|
23
|
+
cl.add_message_callback do |m|
|
24
|
+
if m.type != :error
|
25
|
+
m2 = Message.new(m.from, "You sent: #{m.body}")
|
26
|
+
m2.type = m.type
|
27
|
+
cl.send(m2)
|
28
|
+
if m.body == 'exit'
|
29
|
+
m2 = Message.new(m.from, "Exiting ...")
|
30
|
+
m2.type = m.type
|
31
|
+
cl.send(m2)
|
32
|
+
mainthread.wakeup
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
Thread.stop
|
37
|
+
cl.close
|
data/lib/cwmp/cpe.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
require 'httpclient'
|
2
2
|
require 'socket'
|
3
|
+
require 'xmpp4r/client'
|
4
|
+
require 'nokogiri'
|
5
|
+
include Jabber
|
3
6
|
|
4
7
|
module Cwmp
|
5
8
|
|
@@ -15,6 +18,7 @@ module Cwmp
|
|
15
18
|
@state = 'off'
|
16
19
|
@periodic = Thread.new { periodic periodic } if periodic > 0
|
17
20
|
@conn_req = Thread.new { connection_request }
|
21
|
+
@xmpp_req = Thread.new { xmpp_connection_request }
|
18
22
|
@factory = true
|
19
23
|
end
|
20
24
|
|
@@ -46,6 +50,7 @@ module Cwmp
|
|
46
50
|
end
|
47
51
|
|
48
52
|
def loop
|
53
|
+
@xmpp_req.join
|
49
54
|
@conn_req.join
|
50
55
|
end
|
51
56
|
|
@@ -79,6 +84,59 @@ module Cwmp
|
|
79
84
|
end
|
80
85
|
end
|
81
86
|
|
87
|
+
def xmpp_connection_request
|
88
|
+
puts "start xmpp connection"
|
89
|
+
myJID = JID.new('cpe@mosesacs.org/casatua')
|
90
|
+
myPassword = 'pass'
|
91
|
+
cl = Client.new(myJID)
|
92
|
+
cl.connect
|
93
|
+
cl.auth(myPassword)
|
94
|
+
cl.send(Presence.new)
|
95
|
+
puts "Connected ! send messages to #{myJID.strip.to_s}."
|
96
|
+
|
97
|
+
mainthread = Thread.current
|
98
|
+
cl.add_iq_callback do |m|
|
99
|
+
if m.type == :error
|
100
|
+
puts "error"
|
101
|
+
elsif m.type == :get
|
102
|
+
puts "send xmpp connection request result"
|
103
|
+
|
104
|
+
puts "#{xmpp_connection_request_response_iq(m.from)}"
|
105
|
+
cl.send(xmpp_connection_request_response_iq(m.from))
|
106
|
+
|
107
|
+
puts "send Inform with event CONNECTION REQUEST"
|
108
|
+
do_connection '6 CONNECTION REQUEST'
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
112
|
+
Thread.stop
|
113
|
+
cl.close
|
114
|
+
|
115
|
+
end
|
116
|
+
|
117
|
+
def xmpp_connection_request_response_iq from
|
118
|
+
iq = Iq.new(:result)
|
119
|
+
iq.from = 'cpe1@mosesacs.org'
|
120
|
+
iq.to = from
|
121
|
+
iq.id = 'cr001'
|
122
|
+
iq.add_namespace('urn:broadband-forum-org:cwmp:xmppConnReq-1-0')
|
123
|
+
return iq
|
124
|
+
end
|
125
|
+
|
126
|
+
def xmpp_connection_request_iq
|
127
|
+
iq = Iq.new(:get)
|
128
|
+
iq.from = 'cpe1@mosesacs.org'
|
129
|
+
iq.to = 'acs@mosesacs.org'
|
130
|
+
iq.id = 'cr001'
|
131
|
+
iq.add_namespace('urn:broadband-forum-org:cwmp:xmppConnReq-1-0')
|
132
|
+
cr = iq.add REXML::Element.new('connectionRequest')
|
133
|
+
cr.add_namespace('urn:broadband-forum-org:cwmp:xmppConnReq-1-0')
|
134
|
+
cr.add(REXML::Element.new('username').add_text('username'))
|
135
|
+
cr.add(REXML::Element.new('password').add_text('password'))
|
136
|
+
iq.add(cr)
|
137
|
+
return iq
|
138
|
+
end
|
139
|
+
|
82
140
|
def do_connection(event)
|
83
141
|
begin
|
84
142
|
c = HTTPClient.new
|
@@ -96,15 +154,17 @@ module Cwmp
|
|
96
154
|
message_type = doc.css("#{soap_ns}|Body").children.map(&:name)[1]
|
97
155
|
puts "got #{message_type}"
|
98
156
|
case message_type
|
99
|
-
when "GetParameterValues"
|
157
|
+
when "cwmp:GetParameterValues"
|
100
158
|
resp = c.post @acs_url, (Cwmp::Message::get_parameter_values_response).xml, {'User-Agent' => "ruby-cwmp #{Cwmp::VERSION}", "Content-Type" => 'text/xml; charset="utf-8"'}
|
101
|
-
when "GetParameterNames"
|
159
|
+
when "cwmp:GetParameterNames"
|
102
160
|
resp = c.post @acs_url, (Cwmp::Message::get_parameter_names_response).xml, {'User-Agent' => "ruby-cwmp #{Cwmp::VERSION}", "Content-Type" => 'text/xml; charset="utf-8"'}
|
103
|
-
when "SetParameterValues"
|
161
|
+
when "cwmp:SetParameterValues"
|
104
162
|
resp = c.post @acs_url, (Cwmp::Message::set_parameter_values_response).xml, {'User-Agent' => "ruby-cwmp #{Cwmp::VERSION}", "Content-Type" => 'text/xml; charset="utf-8"'}
|
163
|
+
when "cmwp:ChangeDUState"
|
164
|
+
resp = c.post @acs_url, (Cwmp::Message::change_du_state_response).xml, {'User-Agent' => "ruby-cwmp #{Cwmp::VERSION}", "Content-Type" => 'text/xml; charset="utf-8"'}
|
105
165
|
end
|
106
166
|
end
|
107
|
-
puts "got #{resp.status}, closing"
|
167
|
+
puts "got a #{resp.status}, closing"
|
108
168
|
c.reset @acs_url
|
109
169
|
rescue Errno::ECONNREFUSED
|
110
170
|
puts "can't connect to #{@acs_url}"
|
data/lib/cwmp/message.rb
CHANGED
@@ -70,13 +70,15 @@ module Cwmp
|
|
70
70
|
|
71
71
|
def self.inform(manufacturer, oui, serial, eventcodes, software_version)
|
72
72
|
m = Cwmp::Message.new
|
73
|
-
|
73
|
+
puts "here we go"
|
74
74
|
m.message_type = "Inform"
|
75
75
|
m.raw_xml_message = '<?xml version="1.0" encoding="UTF-8"?>
|
76
76
|
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
|
77
77
|
xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:cwmp="urn:dslforum-org:cwmp-1-0"
|
78
78
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
79
|
-
<soap:Header
|
79
|
+
<soap:Header>
|
80
|
+
<cwmp:ID soap:mustUnderstand="1">37</cwmp:ID>
|
81
|
+
</soap:Header>
|
80
82
|
<soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
|
81
83
|
<cwmp:Inform>
|
82
84
|
<DeviceId>
|
@@ -151,6 +153,25 @@ module Cwmp
|
|
151
153
|
return m
|
152
154
|
end
|
153
155
|
|
156
|
+
def self.change_du_state_response
|
157
|
+
m = Cwmp::Message.new
|
158
|
+
|
159
|
+
m.message_type = "ChangeDUStateResponse"
|
160
|
+
|
161
|
+
b = Nokogiri::XML::Builder.new
|
162
|
+
|
163
|
+
b[:soap].Envelope(NAMESPACES) {
|
164
|
+
b[:soap].Header {}
|
165
|
+
b[:soap].Body {
|
166
|
+
b[:cwmp].ChangeDUStateResponse() {}
|
167
|
+
}
|
168
|
+
}
|
169
|
+
|
170
|
+
m.raw_xml_message = b.to_xml
|
171
|
+
|
172
|
+
return m
|
173
|
+
end
|
174
|
+
|
154
175
|
def self.set_parameter_values(leaves)
|
155
176
|
b = Nokogiri::XML::Builder.new
|
156
177
|
|
@@ -343,4 +364,4 @@ module Cwmp
|
|
343
364
|
end
|
344
365
|
|
345
366
|
end
|
346
|
-
end
|
367
|
+
end
|
data/lib/cwmp/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
module Cwmp
|
2
|
-
VERSION = "0.2.
|
3
|
-
end
|
2
|
+
VERSION = "0.2.1"
|
3
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cwmp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luca Cervasio
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -147,6 +147,7 @@ files:
|
|
147
147
|
- Rakefile
|
148
148
|
- bin/acs
|
149
149
|
- bin/cpe
|
150
|
+
- client_xmpp_ruby.rb
|
150
151
|
- cwmp.gemspec
|
151
152
|
- examples/api_usage.rb
|
152
153
|
- lib/cwmp.rb
|