Projecte

General

Perfil

Ubus » Historial » Versió 10

Roger Pueyo Centelles, 02-06-2014 17:36

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 10 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.location.name          | [[Ubus|ncd-local-location-name-get]]                               | { }                                                    | Get the position (name or description) where the node is located |
16
|ncd.local.location.name          | [[Ubus|ncd-local-location-name-set]]                               | { "location" : "string" }                              | Get the position (name or description) where the node is located |
17
|ncd.local.location.coordinates   | [[Ubus|ncd-local-location-coordinates-get]]                               | { }                                                    | Get the position (latitude and longitude coordinates) where the node is located |
18
|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 |
19 1 Roger Pueyo Centelles
20 10 Roger Pueyo Centelles
 
21 1 Roger Pueyo Centelles
22 10 Roger Pueyo Centelles
h3. Ubus local relay
23 1 Roger Pueyo Centelles
24 10 Roger Pueyo Centelles
The NCd is able to relay Ubus calls from the NCui to other Ubus instances registered locally (like netifd, rpcd, etc.).
25
26
|_.Path                       |_.Procedure                                      |_.Signature                                      |_.Description |
27 1 Roger Pueyo Centelles
|\4=. |
28 10 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 |
29 1 Roger Pueyo Centelles
30 10 Roger Pueyo Centelles
 
31 1 Roger Pueyo Centelles
32 10 Roger Pueyo Centelles
See the example below to get a clear idea of how it works.
33
34
h3. NC-specific remote node information
35
36
The NCd can provide the following procedures regarding other nodes in the network running the NCd:
37
38 1 Roger Pueyo Centelles
|_.Path                          |_.Procedure                                      |_.Signature                                    |_.Description |
39
|\4=. |
40 10 Roger Pueyo Centelles
|ncd.nodeid ¹                    | [[Ubus#ncd-neighbours|neighbours]]            | { }                                           | List all the neighbours of the node defined by  _nodeid_ |
41
|ncd.local.location.name          | [[Ubus|get]]                               | { }                                                    | Get the position (name or description) where the node defined by _nodeid_ is located |
42
|ncd.local.location.name          | [[Ubus|get]]                               | { "location" : "Location name or description" }        | Get the position (name or description) where the node defined by _nodeid_ is located |
43
|ncd.local.location.coordinates   | [[Ubus|get]]                               | { }                                                    | Get the position (latitude and longitude coordinates) where the node defined by _nodeid_ is located |
44
|ncd.local.location.coordinates   | [[Ubus|set]]                               | { "coordinates" : [ "lat", "lon" ] }                   | Set the position (latitude and longitude coordinates) where the node defined by _nodeid_ is located |
45 3 Roger Pueyo Centelles
46 10 Roger Pueyo Centelles
 
47 1 Roger Pueyo Centelles
48 10 Roger Pueyo Centelles
¹ Replace _nodeid_ by the node's unique id
49 3 Roger Pueyo Centelles
50 10 Roger Pueyo Centelles
51
h3. Ubus remote relay
52
53
The NCd is able to relay Ubus calls from the NCui to other Ubus instances registered remotely (like netifd, rpcd, etc.).
54
55
|_.Path                              |_.Procedure                                      |_.Signature                                      |_.Description |
56
|\4=. |
57
|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_ |
58
59
 
60
61
¹ Replace _nodeid_ by the node's unique id
62
63
64
65
66 1 Roger Pueyo Centelles
h2. Usage examples
67 5 Roger Pueyo Centelles
68 10 Roger Pueyo Centelles
h3. ncd local id
69 5 Roger Pueyo Centelles
70 1 Roger Pueyo Centelles
Request:
71
 
72 10 Roger Pueyo Centelles
 @ubus call ncd.local id { }@
73 1 Roger Pueyo Centelles
74
Response:
75
76
 @{ "id" : "node_id" }@
77
78
 
79
80
81
82
83 10 Roger Pueyo Centelles
h3. ncd local neighbours
84 1 Roger Pueyo Centelles
85
Request:
86
 
87 10 Roger Pueyo Centelles
 @ubus call ncd.local neighbours { }@
88 1 Roger Pueyo Centelles
89
Response:
90
91 10 Roger Pueyo Centelles
 @{ "nodes" : [ "node011", "node400" ] }@
92 1 Roger Pueyo Centelles
93
 
94
95
96
97
98
99 10 Roger Pueyo Centelles
h3. ncd local location name get
100
101 1 Roger Pueyo Centelles
Request:
102
 
103 10 Roger Pueyo Centelles
 @ubus call ncd.local.location.name get { }@
104 1 Roger Pueyo Centelles
105
Response:
106
107 10 Roger Pueyo Centelles
 @{ "coordinates" : [ "Narrow Street 16, Faketown" ] }@
108 1 Roger Pueyo Centelles
109
 
110
111
112 10 Roger Pueyo Centelles
113
114
115
h3. ncd local position coordinates get
116
117 1 Roger Pueyo Centelles
Request:
118
 
119 10 Roger Pueyo Centelles
 @ubus call ncd.local.location.coordinates get { }@
120 1 Roger Pueyo Centelles
121
Response:
122
123 10 Roger Pueyo Centelles
 @{ "coordinates" : [ "42.34796", "3.11036" ] }@
124 1 Roger Pueyo Centelles
125
 
126
127
128
129
130 10 Roger Pueyo Centelles
h3. ncd local position name set
131 1 Roger Pueyo Centelles
132 10 Roger Pueyo Centelles
Request:
133
 
134
 @ubus call ncd.local.location.name set { "name" : [ "Narrow Street 16, Faketown (rooftop)" }@
135 1 Roger Pueyo Centelles
136 10 Roger Pueyo Centelles
Response:
137 1 Roger Pueyo Centelles
138 10 Roger Pueyo Centelles
 @{ ] }@
139 1 Roger Pueyo Centelles
140 10 Roger Pueyo Centelles
 
141
142
143
144
145
146
h3. ncd local position coordinates set
147
148 1 Roger Pueyo Centelles
Request:
149
 
150 10 Roger Pueyo Centelles
 @ubus call ncd.local.position.coordinates set { "coordinates" : [ "42.34796", "3.11036" ] }@
151 1 Roger Pueyo Centelles
152
Response:
153
154 10 Roger Pueyo Centelles
 @{ }@
155
156
 
157
158
159
160
161
162
h3. ncd local ubus relay
163
164
Request:
165
 
166
 @ubus call ncd.local.relay.iwinfo devices { }@
167
168
Response:
169
170
 <pre>
171 1 Roger Pueyo Centelles
{
172 10 Roger Pueyo Centelles
	"devices": [
173
		"wlan1",
174
		"wlan0",
175
		"wlan0ap"
176
	]
177 1 Roger Pueyo Centelles
}
178 10 Roger Pueyo Centelles
 </pre>
179 1 Roger Pueyo Centelles
180
&nbsp;
181 10 Roger Pueyo Centelles
182
183
184
185
ubus call iwinfo devices
186
187
188
189 1 Roger Pueyo Centelles
190
h2. More examples
191
192
There is an example of the communication process between the CNAd and the CNAui via ubus [[CNAui-CNAd_communication_example|here]].