shl: update shl-macro.h

Fix a bug in SHL_ALIGN_POWER2 and add new shl_closep helpers.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
dbus: update to systemd API >=213

The libsystemd-bus API changed recently. Update our calls to use the new
API so it compiles with newer systemd versions.

Signed-off-by: Andrey Gusakov <adnrey.gusakov@cogentembedded.com>
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
dbus: use 'int' instead of 'bool' in sd_bus

sd_bus never uses 'bool', and given the weird implicit type promotions, it
is totally right to do so. Make sure we never pass pointers to 'bool' to
va_arg sd_bus functions to avoid overwriting stack space.

Signed-off-by: Andrey Gusakov <adnrey.gusakov@cogentembedded.com>
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
wifi: handle P2P_GROUP_FORMATION_FAILURE

Forward group-formation-failure events via dbus so sinkctl can restart
p2p-scans immediately. Unfortunately, the event itself does not contain
any useful information at all. Therefore, we have to track the connection
attempts ourselves.

Signed-off-by: Andrey Gusakov <adnrey.gusakov@cogentembedded.com>
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
rtsp/wpas: pass va_list by reference

As it turns out, the C standard forbids passing va_list by value and then
continue using it in the parent function (C Standard, 7.16, paragraph 3).

Luckily, there's a footnote stating:
    "It is permitted to create a pointer to a va_list and pass that
    pointer to another function, in which case the original function may
    take further use of the original list after the other function
    returns."

Therefore, we're safe passing va_list by reference and thus can keep the
current coding style.

This fixes weird bugs on ARM32 which really doesn't allow passing va_list
by value.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
ctl: divide M6 (SETUP) and M7 (PLAY) stages

In M7 message session ID should be included. Session ID is returned in M6
response. So we should wait for M6 response.

Signed-off-by: Andrey Gusakov <adnrey.gusakov@cogentembedded.com>
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
ctl: save wfd_presentation_URL from M4

M6 M7 messages should use URL from wfd_presentation_URL of M4. Parse it
during set_parameter and use it in further requests instead of a
hard-coded URL.

Signed-off-by: Andrey Gusakov <adnrey.gusakov@cogentembedded.com>
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
ctl: remove unused variables

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
README: bump dependency on systemd

97323d905c0b05cbadbf0ba574feb14127fc1182 increased the required
version of systemd to >= 213

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
wifi: fix possible null-pointer dereference on sta_mac

p->sp->sta_mac is not mandatory set so check it before accessing it.

Signed-off-by: Andrey Gusakov <andrey.gusakov@cogentembedded.com>
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
dhcp: sync with gdhcp

Copy over recent changes to gdhcp from ConnMan. We should really start
exporting sd-dhcp from libsystemd so we can finally drop this alltogether.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
shared: format MAC with leading zeros

Don't skip leading zeroes for MAC addresses. Some software cannot handle
this well.

Signed-off-by: Andrey Gusakov <andrey.gusakov@cogentembedded.com>
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
wifi: reformat MACs returned from DHCP

ether_ntoa() function used in DHCP server skips leading zeros so
reformat is needed to make strcmp() work for mac-comparisons.

Signed-off-by: Andrey Gusakov <andrey.gusakov@cogentembedded.com>
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
sink: exit header/body in case rtsp_message_readv() fails

rtsp_message_readv() is a convenience function. If one of the values to be
read fails, it does not restore the previous situation. Therefore, handle
that in sinkctl in case we cannot read a value.

Reported-by: Andrey Gusakov <andrey.gusakov@cogentembedded.com>
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>