Ubus » Historial » Revisió 12
Revisió 11 (Roger Pueyo Centelles, 03-06-2014 14:27) → Revisió 12/31 (Roger Pueyo Centelles, 03-06-2014 14:34)
h1. Ubus 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. The NCd can provide local or remote information (i.e. data gathered from other nodes) via the Ubus interface. Some of the h2. NCd ubus namespace and procedures summary h3. NC-specific local node information The NCd, once registered to the Ubus daemon, provides the following procedures. |_.Path |_.Procedure |_.Signature |_.Description | |\4=. | |ncd.local | [[Ubus#ncd-local-id|id]] | { } | Get the unique id of the local node | |ncd.local | [[Ubus#ncd-local-neighbours|neighbours]] | { } | List all the neighbours of the local node | |ncd.local | [[Ubus#ncd-local-link-devices|linkdevices]] | { "nodes": ["nodeid1", "nodeid2", ...] } | List the devices used to link the local node to other nodes ¹| |ncd.local.location.name | [[Ubus|ncd-local-location-name-get]] | { } | Get the position (name or description) where the node is located | |ncd.local.location.name | [[Ubus|ncd-local-location-name-set]] | { "location" : "string" } | Get the position (name or description) where the node is located | |ncd.local.location.coordinates | [[Ubus|ncd-local-location-coordinates-get]] | { } | Get the position (latitude and longitude coordinates) where the node is located | |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 | ¹ Two nodes can be linked via two different devices (a wired and a wireless device, two wireless devices at different frequencies, etc.) h3. Local Ubus local relay via NC The NCd is able to relay Ubus calls from the NCui to other Ubus instances registered locally (like netifd, rpcd, etc.). |_.Path |_.Procedure |_.Signature |_.Description | |\4=. | |ncd.local.relay.daemon.path | [[Ubus#ncd-local-ubus-relay|procedure]] | { "daemon.path procedure signature" } | Get the unique id of the local node | See the example below to get a clear idea of how it works. h3. NC-specific remote node information The NCd can provide the following procedures regarding other nodes in the network running the NCd: |_.Path |_.Procedure |_.Signature |_.Description | |\4=. | |ncd.nodeid ² | [[Ubus#ncd-neighbours|neighbours]] | { } | List all the neighbours of the node defined by _nodeid_ | |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 | |ncd.nodeid.location.name | [[Ubus|get]] | { } | Get the position (name or description) where the node defined by _nodeid_ is located | |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 | |ncd.nodeid.location.coordinates | [[Ubus|get]] | { } | Get the position (latitude and longitude coordinates) where the node defined by _nodeid_ is located | |ncd.nodeid.location.coordinates | [[Ubus|set]] | { "coordinates" : [ "lat", "lon" ] } | Set the position (latitude and longitude coordinates) where the node defined by _nodeid_ is located | ² Replace _nodeid_ by the node's unique id h3. Remote Ubus remote relay via NC The NCd is able to relay Ubus calls from the NCui to other Ubus instances registered remotely (like netifd, rpcd, etc.). |_.Path |_.Procedure |_.Signature |_.Description | |\4=. | |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_ | ² Replace _nodeid_ by the node's unique id h2. Usage examples h3. ncd local id Request: @ubus call ncd.local id { }@ Response: @{ "id" : "node_id" }@ h3. ncd local neighbours Request: @ubus call ncd.local neighbours { }@ Response: @{ "nodes" : [ "node011", "node400" ] }@ h3. ncd local link devices Request: @ubus call ncd.local linkdevices { "nodes" : [ "node011", "node400" ] }@ Response: <pre> { "links": [ { "node011": [ "eth0.12", "wlan0" ] }, { "node400": [ "wlan0" ] } ] } </pre> h3. ncd local location name get Request: @ubus call ncd.local.location.name get { }@ Response: @{ "coordinates" : [ "Narrow Street 16, Faketown" ] }@ h3. ncd local position coordinates get Request: @ubus call ncd.local.location.coordinates get { }@ Response: @{ "coordinates" : [ "42.34796", "3.11036" ] }@ h3. ncd local position name set Request: @ubus call ncd.local.location.name set { "name" : [ "Narrow Street 16, Faketown (rooftop)" }@ Response: @{ ] }@ h3. ncd local position coordinates set Request: @ubus call ncd.local.position.coordinates set { "coordinates" : [ "42.34796", "3.11036" ] }@ Response: @{ }@ h3. ncd local ubus relay Request: @ubus call ncd.local.relay.iwinfo devices { }@ Response: <pre> { "devices": [ "wlan1", "wlan0", "wlan0ap" ] } </pre> ubus call iwinfo devices h2. More examples There is an example of the communication process between the CNAd and the CNAui via ubus [[CNAui-CNAd_communication_example|here]].