"Inital commit to Gerrit"
[profile/ivi/dhcp.git] / packaging / dhcp-4.2.0-inherit-leases.patch
1 diff -up dhcp-4.2.0/client/dhclient.c.inherit dhcp-4.2.0/client/dhclient.c
2 --- dhcp-4.2.0/client/dhclient.c.inherit        2010-07-21 14:33:44.000000000 +0200
3 +++ dhcp-4.2.0/client/dhclient.c        2010-07-21 14:40:05.000000000 +0200
4 @@ -2322,6 +2322,7 @@ void send_request (cpp)
5  {
6         struct client_state *client = cpp;
7  
8 +       int i;
9         int result;
10         int interval;
11         struct sockaddr_in destination;
12 @@ -2381,6 +2382,22 @@ void send_request (cpp)
13                 /* Now do a preinit on the interface so that we can
14                    discover a new address. */
15                 script_init (client, "PREINIT", (struct string_list *)0);
16 +
17 +               /* Has an active lease */
18 +               if (client -> interface -> addresses != NULL) {
19 +                       for (i = 0; i < client -> interface -> address_count; i++) {
20 +                               if (client -> active &&
21 +                                   client -> active -> is_bootp &&
22 +                                   client -> active -> expiry > cur_time &&
23 +                                   client -> interface -> addresses[i].s_addr != 0 &&
24 +                                   client -> active -> address.len == 4 &&
25 +                                   memcpy (client -> active -> address.iabuf, &(client -> interface -> addresses[i]), 4) == 0) {
26 +                                       client_envadd (client, "", "keep_old_ip", "%s", "yes");
27 +                                       break;
28 +                               }
29 +                       }
30 +               }
31 +
32                 if (client -> alias)
33                         script_write_params (client, "alias_",
34                                              client -> alias);