nodejs dbus is encoding a quantity as a byte, how do I make it encode it as a uint32?

0

I'm trying to use NPM dbus to control an ethernet adapter and get the following error, shown here in dbus-monitor's output.

error time=1540389658.120119 sender=:1.14 -> destination=:1.198 error_name=org.freedesktop.NetworkManager.Settings.Connection.InvalidProperty reply_serial=37
   string "ipv4.gateway: gateway cannot be set if there are no addresses configured"

So, it's complaining that there are no addresses configured...

Let's look at the address data npm-dbus sent...

    dict entry(
       string "address-data"
       variant                   array [
             array [
                dict entry(
                   string "address"
                   variant                               string "192.168.1.200"
                )
                dict entry(
                   string "prefix"
                   variant                               byte 24
                )
             ]
          ]
    )

This is different to what works using gdbus command line, relevant excerpt here:

  'ipv4':\
   {
    'method': <'manual'>,\
    'dns': <[uint32 4261521600]>,\
    'address-data': <[{'address': <'192.168.1.198'>, 'prefix': <uint32 24>}]>,\
        'gateway': <'192.168.1.1'>
   }

I think the smoking gun is that 'prefix': <uint32 24> in the gdbus version compared with the byte 24 generated by npm-dbus.

I've tried a few ideas to get npm-dbus to code the prefix as a uint32, but not had any success. Here's the javascript object I'm feeding into it:

    ipv4: {
        method: 'manual',
        dns: [4261521600],
        'address-data': [{'address': '192.168.1.200', 'prefix': 24}],
        gateway: '192.168.1.1'
    }

Things I've tried in this object's definition that still resulted in prefix being encoded as a byte:

'prefix': 0x00000018 // byte 24
'prefix': 0x10000018 - 0x10000000 // byte 24

Any ideas?

Thanks!

javascript
node.js
npm
dbus
gvariant
asked on Stack Overflow Oct 24, 2018 by VorpalSword • edited Oct 24, 2018 by (unknown user)

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0