]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/libsystemd-network/sd-dhcp-client.c
doc: correct orthography, word forms and missing/extraneous words
[thirdparty/systemd.git] / src / libsystemd-network / sd-dhcp-client.c
index c12768cf0e5b002a66eb48162515f81b292ca735..137537253a4aad9a9cfb034c31a11050204f429d 100644 (file)
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
-#include <stdlib.h>
 #include <errno.h>
-#include <string.h>
-#include <stdio.h>
 #include <net/ethernet.h>
 #include <net/if_arp.h>
-#include <linux/if_infiniband.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 #include <sys/ioctl.h>
+#include <linux/if_infiniband.h>
 
-#include "util.h"
-#include "random-util.h"
-#include "async.h"
+#include "sd-dhcp-client.h"
 
-#include "dhcp-protocol.h"
+#include "alloc-util.h"
+#include "async.h"
+#include "dhcp-identifier.h"
 #include "dhcp-internal.h"
 #include "dhcp-lease-internal.h"
-#include "dhcp-identifier.h"
-#include "sd-dhcp-client.h"
+#include "dhcp-protocol.h"
+#include "random-util.h"
+#include "string-util.h"
+#include "util.h"
 
 #define MAX_CLIENT_ID_LEN (sizeof(uint32_t) + MAX_DUID_LEN)  /* Arbitrary limit */
 #define MAX_MAC_ADDR_LEN CONST_MAX(INFINIBAND_ALEN, ETH_ALEN)
@@ -213,7 +215,7 @@ int sd_dhcp_client_set_mac(sd_dhcp_client *client, const uint8_t *addr,
                 log_dhcp_client(client, "Changing MAC address on running DHCP "
                                 "client, restarting");
                 need_restart = true;
-                client_stop(client, DHCP_EVENT_STOP);
+                client_stop(client, SD_DHCP_CLIENT_EVENT_STOP);
         }
 
         memcpy(&client->mac_addr, addr, addr_len);
@@ -277,7 +279,7 @@ int sd_dhcp_client_set_client_id(sd_dhcp_client *client, uint8_t type,
                 log_dhcp_client(client, "Changing client ID on running DHCP "
                                 "client, restarting");
                 need_restart = true;
-                client_stop(client, DHCP_EVENT_STOP);
+                client_stop(client, SD_DHCP_CLIENT_EVENT_STOP);
         }
 
         client->client_id.type = type;
@@ -385,7 +387,7 @@ static void client_stop(sd_dhcp_client *client, int error) {
 
         if (error < 0)
                 log_dhcp_client(client, "STOPPED: %s", strerror(-error));
-        else if (error == DHCP_EVENT_STOP)
+        else if (error == SD_DHCP_CLIENT_EVENT_STOP)
                 log_dhcp_client(client, "STOPPED");
         else
                 log_dhcp_client(client, "STOPPED: Unknown event");
@@ -983,7 +985,7 @@ static int client_timeout_expire(sd_event_source *s, uint64_t usec,
 
         log_dhcp_client(client, "EXPIRED");
 
-        client_notify(client, DHCP_EVENT_EXPIRED);
+        client_notify(client, SD_DHCP_CLIENT_EVENT_EXPIRED);
 
         /* lease was lost, start over if not freed or stopped in callback */
         if (client->state != DHCP_STATE_STOPPED) {
@@ -1143,14 +1145,14 @@ static int client_handle_ack(sd_dhcp_client *client, DHCPMessage *ack,
                 }
         }
 
-        r = DHCP_EVENT_IP_ACQUIRE;
+        r = SD_DHCP_CLIENT_EVENT_IP_ACQUIRE;
         if (client->lease) {
                 if (client->lease->address != lease->address ||
                     client->lease->subnet_mask != lease->subnet_mask ||
                     client->lease->router != lease->router) {
-                        r = DHCP_EVENT_IP_CHANGE;
+                        r = SD_DHCP_CLIENT_EVENT_IP_CHANGE;
                 } else
-                        r = DHCP_EVENT_RENEW;
+                        r = SD_DHCP_CLIENT_EVENT_RENEW;
 
                 client->lease = sd_dhcp_lease_unref(client->lease);
         }
@@ -1265,8 +1267,7 @@ static int client_set_lease_timeouts(sd_dhcp_client *client) {
                 return r;
 
         log_dhcp_client(client, "lease expires in %s",
-                        format_timespan(time_string, FORMAT_TIMESPAN_MAX,
-                        lifetime_timeout - time_now, 0));
+                        format_timespan(time_string, FORMAT_TIMESPAN_MAX, lifetime_timeout - time_now, USEC_PER_SEC));
 
         /* don't arm earlier timeouts if this has already expired */
         if (lifetime_timeout <= time_now)
@@ -1292,8 +1293,7 @@ static int client_set_lease_timeouts(sd_dhcp_client *client) {
                 return r;
 
         log_dhcp_client(client, "T2 expires in %s",
-                        format_timespan(time_string, FORMAT_TIMESPAN_MAX,
-                        t2_timeout - time_now, 0));
+                        format_timespan(time_string, FORMAT_TIMESPAN_MAX, t2_timeout - time_now, USEC_PER_SEC));
 
         /* don't arm earlier timeout if this has already expired */
         if (t2_timeout <= time_now)
@@ -1318,8 +1318,7 @@ static int client_set_lease_timeouts(sd_dhcp_client *client) {
                 return r;
 
         log_dhcp_client(client, "T1 expires in %s",
-                        format_timespan(time_string, FORMAT_TIMESPAN_MAX,
-                        t1_timeout - time_now, 0));
+                        format_timespan(time_string, FORMAT_TIMESPAN_MAX, t1_timeout - time_now, USEC_PER_SEC));
 
         return 0;
 }
@@ -1382,8 +1381,8 @@ static int client_handle_message(sd_dhcp_client *client, DHCPMessage *message,
 
                         if (IN_SET(client->state, DHCP_STATE_REQUESTING,
                                    DHCP_STATE_REBOOTING))
-                                notify_event = DHCP_EVENT_IP_ACQUIRE;
-                        else if (r != DHCP_EVENT_IP_ACQUIRE)
+                                notify_event = SD_DHCP_CLIENT_EVENT_IP_ACQUIRE;
+                        else if (r != SD_DHCP_CLIENT_EVENT_IP_ACQUIRE)
                                 notify_event = r;
 
                         client->state = DHCP_STATE_BOUND;
@@ -1518,7 +1517,7 @@ static int client_receive_message_udp(sd_event_source *s, int fd,
                 expected_hlen = ETH_ALEN;
                 expected_chaddr = (const struct ether_addr *) &client->mac_addr;
         } else {
-               /* Non-ethernet links expect zero chaddr */
+               /* Non-Ethernet links expect zero chaddr */
                expected_hlen = 0;
                expected_chaddr = &zero_mac;
         }
@@ -1633,7 +1632,7 @@ int sd_dhcp_client_stop(sd_dhcp_client *client) {
 
         assert_return(client, -EINVAL);
 
-        client_stop(client, DHCP_EVENT_STOP);
+        client_stop(client, SD_DHCP_CLIENT_EVENT_STOP);
         client->state = DHCP_STATE_STOPPED;
 
         return 0;