Hi,

On Fri, 2015-07-31 at 17:40 +0200, Michael Olbrich wrote:
> The lease added callback only used to determine and announce the peer
> address. Without this, the peer address is announced via D-Bus before the
> peer actually ueses the address.
> If the first OFFER is lost, then the difference can actually be several
> seconds.
> ---
>  gdhcp/server.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/gdhcp/server.c b/gdhcp/server.c
> index 8574c24c4b72..2455c5939e1b 100644
> --- a/gdhcp/server.c
> +++ b/gdhcp/server.c
> @@ -189,7 +189,8 @@ static gint compare_expire(gconstpointer a, gconstpointer 
> b)
>  }
>  
>  static struct dhcp_lease *add_lease(GDHCPServer *dhcp_server, uint32_t 
> expire,
> -                                     const uint8_t *chaddr, uint32_t yiaddr)
> +                                     const uint8_t *chaddr, uint32_t yiaddr,
> +                                     bool final)
>  {
>       struct dhcp_lease *lease = NULL;
>       int ret;
> @@ -214,7 +215,7 @@ static struct dhcp_lease *add_lease(GDHCPServer 
> *dhcp_server, uint32_t expire,
>       g_hash_table_insert(dhcp_server->nip_lease_hash,
>                               GINT_TO_POINTER((int) lease->lease_nip), lease);
>  
> -     if (dhcp_server->lease_added_cb)
> +     if (final && dhcp_server->lease_added_cb)
>               dhcp_server->lease_added_cb(lease->lease_mac, yiaddr);
>  
>       return lease;
> @@ -562,7 +563,7 @@ static void send_offer(GDHCPServer *dhcp_server,
>       }
>  
>       lease = add_lease(dhcp_server, OFFER_TIME,
> -                             packet.chaddr, packet.yiaddr);
> +                             packet.chaddr, packet.yiaddr, false);
>       if (!lease) {
>               debug(dhcp_server,
>                               "Err: No free IP addresses. OFFER abandoned");
> @@ -615,7 +616,7 @@ static void send_ACK(GDHCPServer *dhcp_server,
>  
>       send_packet_to_client(dhcp_server, &packet);
>  
> -     add_lease(dhcp_server, 0, packet.chaddr, packet.yiaddr);
> +     add_lease(dhcp_server, 0, packet.chaddr, packet.yiaddr, true);

Instead of adding a new variable, is it easier to move the lines

if (dhcp_server->lease_added_cb)
                dhcp_server->lease_added_cb(lease->lease_mac, yiaddr);

here?

Cheers,

        Patrik

>  }
>  
>  static void send_NAK(GDHCPServer *dhcp_server,


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

Reply via email to