[systemd-devel] sd-bus read message with ConnMan

Mantas Mikulėnas grawity at gmail.com
Mon Jun 10 08:14:10 UTC 2019


On Fri, Jun 7, 2019 at 9:08 PM Salman Ahmed <salman.isd at gmail.com> wrote:

> Hello,
>
> I am trying to communicate with connman using sdbus from my application.
> Basically I want to replicate the following cmd line procedure to get
> values for "object path" and string "Host" (underlined below)
> I do
> *dbus-send --system              --dest=net.connman.vpn
> --type=method_call            --print-reply                 /
>  net.connman.vpn.Manager.GetConnections*
>
> and I get
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> *   array [      struct {         object path
> "/net/connman/vpn/connection/uk_london_privateinternetaccess_com_privateinternetaccess_com"
>        array [            dict entry(               string "State"
>      variant                   string "idle"            )            dict
> entry(               string "Type"               variant
> string "openvpn"            )            dict entry(               string
> "Name"               variant                   string "PIA VPN"
> )            dict entry(               string "Host"               variant
>                   string "uk-london.privateinternetaccess.com
> <http://uk-london.privateinternetaccess.com>"            )            dict
> entry(               string "Index"               variant
> int32 0            )            dict entry(               string "Domain"
>              variant                   string "privateinternetaccess.com
> <http://privateinternetaccess.com>"            )            dict entry(
>            string "Immutable"               variant
> boolean true            )            dict entry(               string
> "Nameservers"               variant                   array [
>     ]            )            dict entry(               string
> "UserRoutes"               variant                   array [
>   ]            )            dict entry(               string
> "ServerRoutes"               variant                   array [
>     ]            )         ]      }   ]*
>
>
> In my application I am doing
>        r = sd_bus_call_method( bus,
>                                            "net.connman.vpn",
>                                            "/",
>                                            "net.connman.vpn.Manager",
>                                            "GetConnections",
>                                            &error,
>                                            &m,  NULL, NULL);
>
> Which succeeds.
> Afterwards I want to do  sd_bus_message_read(m, "a(oa{sv})") but I have no
> idea what kind of arguments should I pass in what order to get object path
> and host string. I think I got the a(oa{sv}) part right?
>

Use sd_bus_message_enter_container() first. Here's a very similar example:

https://github.com/systemd/systemd/blob/master/src/core/dbus-manager.c#L802


-- 
Mantas Mikulėnas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20190610/d3d433df/attachment.html>


More information about the systemd-devel mailing list