Ubus » Historial » Versió 11
Roger Pueyo Centelles, 03-06-2014 14:27
1 | 1 | Roger Pueyo Centelles | h1. Ubus |
---|---|---|---|
2 | |||
3 | 10 | Roger Pueyo Centelles | The [[NCd|Network Characterization daemon]] (NCd) uses "Ubus":http://wiki.openwrt.org/doc/techref/ubus (the "OpenWrt":http://www.openwrt.org micro bus architecture) to communicate with the [[NCui|Network Characterization user interface]] and with other daemons and applications. This page documents the ubus namespace of the NC, with the available procedures and several examples. |
4 | 1 | Roger Pueyo Centelles | |
5 | h2. NCd ubus namespace and procedures summary |
||
6 | |||
7 | 10 | Roger Pueyo Centelles | h3. NC-specific local node information |
8 | 1 | Roger Pueyo Centelles | |
9 | 10 | Roger Pueyo Centelles | The NCd, once registered to the Ubus daemon, provides the following procedures. |
10 | |||
11 | |_.Path |_.Procedure |_.Signature |_.Description | |
||
12 | 1 | Roger Pueyo Centelles | |\4=. | |
13 | 11 | Roger Pueyo Centelles | |ncd.local | [[Ubus#ncd-local-id|id]] | { } | Get the unique id of the local node | |
14 | |ncd.local | [[Ubus#ncd-local-neighbours|neighbours]] | { } | List all the neighbours of the local node | |
||
15 | |ncd.local | [[Ubus#ncd-local-link-devices|linkdevices]] | { "nodes": ["nodeid1", "nodeid2", ...] } | List the devices used to link the local node to other nodes ¹| |
||
16 | |ncd.local.location.name | [[Ubus|ncd-local-location-name-get]] | { } | Get the position (name or description) where the node is located | |
||
17 | |ncd.local.location.name | [[Ubus|ncd-local-location-name-set]] | { "location" : "string" } | Get the position (name or description) where the node is located | |
||
18 | |ncd.local.location.coordinates | [[Ubus|ncd-local-location-coordinates-get]] | { } | Get the position (latitude and longitude coordinates) where the node is located | |
||
19 | |ncd.local.location.coordinates | [[Ubus|ncd-local-location-coordinates-set]] | { "coordinates" : [ "lat", "lon" ] } | Set the position (latitude and longitude coordinates) where the node is located | |
||
20 | 10 | Roger Pueyo Centelles | |
21 | 11 | Roger Pueyo Centelles | ¹ Two nodes can be linked via two different devices (a wired and a wireless device, two wireless devices at different frequencies, etc.) |
22 | 10 | Roger Pueyo Centelles | |
23 | 1 | Roger Pueyo Centelles | |
24 | 10 | Roger Pueyo Centelles | h3. Ubus local relay |
25 | 1 | Roger Pueyo Centelles | |
26 | The NCd is able to relay Ubus calls from the NCui to other Ubus instances registered locally (like netifd, rpcd, etc.). |
||
27 | |||
28 | 10 | Roger Pueyo Centelles | |_.Path |_.Procedure |_.Signature |_.Description | |
29 | |\4=. | |
||
30 | 1 | Roger Pueyo Centelles | |ncd.local.relay.daemon.path | [[Ubus#ncd-local-ubus-relay|procedure]] | { "daemon.path procedure signature" } | Get the unique id of the local node | |
31 | 10 | Roger Pueyo Centelles | |
32 | 11 | Roger Pueyo Centelles | See the example below to get a clear idea of how it works. |
33 | |||
34 | 1 | Roger Pueyo Centelles | |
35 | |||
36 | |||
37 | 11 | Roger Pueyo Centelles | |
38 | 1 | Roger Pueyo Centelles | h3. NC-specific remote node information |
39 | 10 | Roger Pueyo Centelles | |
40 | The NCd can provide the following procedures regarding other nodes in the network running the NCd: |
||
41 | |||
42 | 11 | Roger Pueyo Centelles | |_.Path |_.Procedure |_.Signature |_.Description | |
43 | 1 | Roger Pueyo Centelles | |\4=. | |
44 | 11 | Roger Pueyo Centelles | |ncd.nodeid ² | [[Ubus#ncd-neighbours|neighbours]] | { } | List all the neighbours of the node defined by _nodeid_ | |
45 | |ncd.nodeid | [[Ubus#ncd-nodeid-link-devices|linkdevices]] | { "nodes": ["nodeid1", "nodeid2", ...] } | List the devices used to link the node defined by _nodeid_ to other nodes | |
||
46 | |ncd.nodeid.location.name | [[Ubus|get]] | { } | Get the position (name or description) where the node defined by _nodeid_ is located | |
||
47 | |ncd.nodeid.location.name | [[Ubus|get]] | { "location" : "Location name or description" } | Get the position (name or description) where the node defined by _nodeid_ is located | |
||
48 | |ncd.nodeid.location.coordinates | [[Ubus|get]] | { } | Get the position (latitude and longitude coordinates) where the node defined by _nodeid_ is located | |
||
49 | |ncd.nodeid.location.coordinates | [[Ubus|set]] | { "coordinates" : [ "lat", "lon" ] } | Set the position (latitude and longitude coordinates) where the node defined by _nodeid_ is located | |
||
50 | 1 | Roger Pueyo Centelles | |
51 | 11 | Roger Pueyo Centelles | ² Replace _nodeid_ by the node's unique id |
52 | 1 | Roger Pueyo Centelles | |
53 | 10 | Roger Pueyo Centelles | |
54 | 3 | Roger Pueyo Centelles | |
55 | 10 | Roger Pueyo Centelles | |
56 | 11 | Roger Pueyo Centelles | |
57 | 10 | Roger Pueyo Centelles | h3. Ubus remote relay |
58 | |||
59 | The NCd is able to relay Ubus calls from the NCui to other Ubus instances registered remotely (like netifd, rpcd, etc.). |
||
60 | |||
61 | |_.Path |_.Procedure |_.Signature |_.Description | |
||
62 | |\4=. | |
||
63 | 11 | Roger Pueyo Centelles | |ncd.nodeid.relay.daemon.path ² | [[Ubus#ncd-remote-ubus-relay|procedure]] | { "daemon.path procedure signature" } | Get the unique id of the node defined by _nodeid_ | |
64 | 10 | Roger Pueyo Centelles | |
65 | 11 | Roger Pueyo Centelles | ² Replace _nodeid_ by the node's unique id |
66 | 10 | Roger Pueyo Centelles | |
67 | |||
68 | |||
69 | |||
70 | |||
71 | |||
72 | 11 | Roger Pueyo Centelles | |
73 | 5 | Roger Pueyo Centelles | h2. Usage examples |
74 | 10 | Roger Pueyo Centelles | |
75 | 5 | Roger Pueyo Centelles | h3. ncd local id |
76 | 1 | Roger Pueyo Centelles | |
77 | Request: |
||
78 | 10 | Roger Pueyo Centelles | |
79 | 1 | Roger Pueyo Centelles | @ubus call ncd.local id { }@ |
80 | |||
81 | Response: |
||
82 | |||
83 | @{ "id" : "node_id" }@ |
||
84 | |||
85 | |
||
86 | |||
87 | |||
88 | |||
89 | |||
90 | h3. ncd local neighbours |
||
91 | |||
92 | Request: |
||
93 | |||
94 | @ubus call ncd.local neighbours { }@ |
||
95 | |||
96 | Response: |
||
97 | |||
98 | @{ "nodes" : [ "node011", "node400" ] }@ |
||
99 | 11 | Roger Pueyo Centelles | |
100 | |
||
101 | |||
102 | |||
103 | |||
104 | |||
105 | h3. ncd local link devices |
||
106 | |||
107 | Request: |
||
108 | |||
109 | @ubus call ncd.local linkdevices { "nodes" : [ "node011", "node400" ] }@ |
||
110 | |||
111 | Response: |
||
112 | |||
113 | <pre> |
||
114 | { |
||
115 | "links": [ |
||
116 | { |
||
117 | "node011": [ |
||
118 | "eth0.12", |
||
119 | "wlan0" |
||
120 | ] |
||
121 | }, |
||
122 | { |
||
123 | "node400": [ |
||
124 | "wlan0" |
||
125 | ] |
||
126 | } |
||
127 | ] |
||
128 | } |
||
129 | </pre> |
||
130 | 1 | Roger Pueyo Centelles | |
131 | |
||
132 | |||
133 | |||
134 | |||
135 | |||
136 | 10 | Roger Pueyo Centelles | |
137 | h3. ncd local location name get |
||
138 | 1 | Roger Pueyo Centelles | |
139 | Request: |
||
140 | 10 | Roger Pueyo Centelles | |
141 | 1 | Roger Pueyo Centelles | @ubus call ncd.local.location.name get { }@ |
142 | |||
143 | Response: |
||
144 | 10 | Roger Pueyo Centelles | |
145 | 1 | Roger Pueyo Centelles | @{ "coordinates" : [ "Narrow Street 16, Faketown" ] }@ |
146 | |||
147 | |
||
148 | |||
149 | 10 | Roger Pueyo Centelles | |
150 | |||
151 | |||
152 | |||
153 | h3. ncd local position coordinates get |
||
154 | 1 | Roger Pueyo Centelles | |
155 | Request: |
||
156 | 10 | Roger Pueyo Centelles | |
157 | 1 | Roger Pueyo Centelles | @ubus call ncd.local.location.coordinates get { }@ |
158 | |||
159 | Response: |
||
160 | 10 | Roger Pueyo Centelles | |
161 | 1 | Roger Pueyo Centelles | @{ "coordinates" : [ "42.34796", "3.11036" ] }@ |
162 | |||
163 | |
||
164 | |||
165 | |||
166 | |||
167 | 10 | Roger Pueyo Centelles | |
168 | 1 | Roger Pueyo Centelles | h3. ncd local position name set |
169 | 10 | Roger Pueyo Centelles | |
170 | Request: |
||
171 | |||
172 | 1 | Roger Pueyo Centelles | @ubus call ncd.local.location.name set { "name" : [ "Narrow Street 16, Faketown (rooftop)" }@ |
173 | 10 | Roger Pueyo Centelles | |
174 | 1 | Roger Pueyo Centelles | Response: |
175 | 10 | Roger Pueyo Centelles | |
176 | 1 | Roger Pueyo Centelles | @{ ] }@ |
177 | 10 | Roger Pueyo Centelles | |
178 | |
||
179 | |||
180 | |||
181 | |||
182 | |||
183 | |||
184 | h3. ncd local position coordinates set |
||
185 | 1 | Roger Pueyo Centelles | |
186 | Request: |
||
187 | 10 | Roger Pueyo Centelles | |
188 | 1 | Roger Pueyo Centelles | @ubus call ncd.local.position.coordinates set { "coordinates" : [ "42.34796", "3.11036" ] }@ |
189 | |||
190 | Response: |
||
191 | 10 | Roger Pueyo Centelles | |
192 | @{ }@ |
||
193 | |||
194 | |
||
195 | |||
196 | |||
197 | |||
198 | |||
199 | |||
200 | h3. ncd local ubus relay |
||
201 | |||
202 | Request: |
||
203 | |||
204 | @ubus call ncd.local.relay.iwinfo devices { }@ |
||
205 | |||
206 | Response: |
||
207 | |||
208 | 1 | Roger Pueyo Centelles | <pre> |
209 | 10 | Roger Pueyo Centelles | { |
210 | "devices": [ |
||
211 | "wlan1", |
||
212 | "wlan0", |
||
213 | "wlan0ap" |
||
214 | 1 | Roger Pueyo Centelles | ] |
215 | 10 | Roger Pueyo Centelles | } |
216 | 1 | Roger Pueyo Centelles | </pre> |
217 | |||
218 | 10 | Roger Pueyo Centelles | |
219 | |||
220 | |||
221 | |||
222 | |||
223 | ubus call iwinfo devices |
||
224 | |||
225 | |||
226 | 1 | Roger Pueyo Centelles | |
227 | |||
228 | h2. More examples |
||
229 | |||
230 | There is an example of the communication process between the CNAd and the CNAui via ubus [[CNAui-CNAd_communication_example|here]]. |