It does not rely here on an ipconfig in the contrary to the dhcp client,
so it will get the settings from the underneath dhcpv4 server.
---
 src/peer.c | 28 ++++++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/src/peer.c b/src/peer.c
index ff5483c..25b942f 100644
--- a/src/peer.c
+++ b/src/peer.c
@@ -150,14 +150,38 @@ static bool allow_property_changed(struct connman_peer 
*peer)
        return true;
 }
 
+static void append_dhcp_server_ipv4(DBusMessageIter *iter, void *user_data)
+{
+       struct connman_peer *peer = user_data;
+       const char *str = "dhcp";
+       const char *gateway;
+       const char *subnet;
+
+       if (!peer->ip_pool)
+               return;
+
+       gateway = __connman_ippool_get_gateway(peer->ip_pool);
+       subnet = __connman_ippool_get_subnet_mask(peer->ip_pool);
+
+       connman_dbus_dict_append_basic(iter, "Method", DBUS_TYPE_STRING, &str);
+       connman_dbus_dict_append_basic(iter, "Address",
+                                               DBUS_TYPE_STRING, &gateway);
+       connman_dbus_dict_append_basic(iter, "Netmask",
+                                               DBUS_TYPE_STRING, &subnet);
+       connman_dbus_dict_append_basic(iter, "Gateway",
+                                               DBUS_TYPE_STRING, &gateway);
+}
+
 static void append_ipv4(DBusMessageIter *iter, void *user_data)
 {
        struct connman_peer *peer = user_data;
 
-       if (peer->state != CONNMAN_PEER_STATE_READY)
+       if (!is_connected(peer))
                return;
 
-       if (peer->ipconfig)
+       if (peer->connection_master)
+               append_dhcp_server_ipv4(iter, peer);
+       else if (peer->ipconfig)
                __connman_ipconfig_append_ipv4(peer->ipconfig, iter);
 }
 
-- 
1.8.5.5

_______________________________________________
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman

Reply via email to