chiark / gitweb /
libsystemd-dhcp: Use be32_t for IP addresses in network order.
[elogind.git] / src / libsystemd-dhcp / dhcp-client.c
index 01d406c..fe41067 100644 (file)
@@ -36,10 +36,10 @@ struct DHCPLease {
         uint32_t t1;
         uint32_t t2;
         uint32_t lifetime;
-        uint32_t address;
-        uint32_t server_address;
-        uint32_t subnet_mask;
-        uint32_t router;
+        be32_t address;
+        be32_t server_address;
+        be32_t subnet_mask;
+        be32_t router;
 };
 
 typedef struct DHCPLease DHCPLease;
@@ -54,7 +54,7 @@ struct sd_dhcp_client {
         sd_event_source *receive_message;
         uint8_t *req_opts;
         size_t req_opts_size;
-        uint32_t last_addr;
+        be32_t last_addr;
         struct ether_addr mac_addr;
         uint32_t xid;
         usec_t start_time;
@@ -897,6 +897,9 @@ static int client_receive_raw_message(sd_event_source *s, int fd,
                         client->receive_message =
                                 sd_event_source_unref(client->receive_message);
                 }
+
+                r = 0;
+
                 break;
 
         case DHCP_STATE_INIT:
@@ -910,7 +913,7 @@ static int client_receive_raw_message(sd_event_source *s, int fd,
         }
 
 error:
-        if (r < 0)
+        if (r < 0 || r == DHCP_EVENT_NO_LEASE)
                 return client_stop(client, r);
 
         return 0;