chiark / gitweb /
remove unused includes
[elogind.git] / src / libsystemd-network / sd-pppoe.c
index 21ddaebdd2943388e80186da88feaa6d12021d0b..67a2cc6e979985a8358ec4d429337d8b64a73755 100644 (file)
@@ -22,7 +22,6 @@
 /* See RFC 2516 */
 
 #include <sys/ioctl.h>
-#include <linux/ppp_defs.h>
 #include <linux/ppp-ioctl.h>
 #include <net/if.h>
 #include <netinet/in.h>
@@ -36,7 +35,6 @@
 #include "socket-util.h"
 #include "async.h"
 #include "refcnt.h"
-#include "unaligned.h"
 #include "utf8.h"
 
 #define PPPOE_MAX_PACKET_SIZE 1484
@@ -100,19 +98,13 @@ struct sd_pppoe {
         be16toh((header)->length)
 
 #define PPPOE_PACKET_TAIL(packet)                                                                               \
-        (struct pppoe_tag *)((uint8_t*)(packet) + sizeof(struct pppoe_hdr) + PPPOE_PACKET_LENGTH(packet))
+        (struct pppoe_tag*)((uint8_t*)(packet) + sizeof(struct pppoe_hdr) + PPPOE_PACKET_LENGTH(packet))
 
-#define PPPOE_TAG_LENGTH(tag)                   \
-        unaligned_read_be16(&(tag)->tag_len)
+#define PPPOE_TAG_LENGTH(tag)  \
+        be16toh((tag)->tag_len)
 
-#define PPPOE_TAG_TYPE(tag)                     \
-        htobe16(unaligned_read_be16(&(tag)->tag_type))
-
-#define PPPOE_TAG_SET_LENGTH(tag, len) \
-        unaligned_write_be16(&(tag)->tag_len, len)
-
-#define PPPOE_TAG_SET_TYPE(tag, len) \
-        unaligned_write_be16(&(tag)->tag_type, be16toh(len))
+#define PPPOE_TAG_TYPE(tag) \
+        (tag)->tag_type
 
 #define PPPOE_TAG_NEXT(tag)                                                                      \
         (struct pppoe_tag *)((uint8_t *)(tag) + sizeof(struct pppoe_tag) + PPPOE_TAG_LENGTH(tag))
@@ -278,8 +270,8 @@ static void pppoe_tag_append(struct pppoe_hdr *packet, size_t packet_size, be16_
 
         tag = PPPOE_PACKET_TAIL(packet);
 
-        PPPOE_TAG_SET_LENGTH(tag, tag_len);
-        PPPOE_TAG_SET_TYPE(tag, tag_type);
+        tag->tag_len = htobe16(tag_len);
+        tag->tag_type = tag_type;
         if (tag_data)
                 memcpy(tag->tag_data, tag_data, tag_len);
 
@@ -428,7 +420,7 @@ static int pppoe_timeout(sd_event_source *s, uint64_t usec, void *userdata) {
         case PPPOE_STATE_INITIALIZING:
                 r = pppoe_send_initiation(ppp);
                 if (r < 0)
-                        log_warning("PPPoE: sending PADI failed: %s", strerror(-r));
+                        log_warning_errno(r, "PPPoE: sending PADI failed: %m");
 
                 break;
         case PPPOE_STATE_REQUESTING:
@@ -437,14 +429,14 @@ static int pppoe_timeout(sd_event_source *s, uint64_t usec, void *userdata) {
 
                         r = pppoe_send_initiation(ppp);
                         if (r < 0)
-                                log_warning("PPPoE: sending PADI failed: %s", strerror(-r));
+                                log_warning_errno(r, "PPPoE: sending PADI failed: %m");
 
                         ppp->padr_resend_count = PPPOE_MAX_PADR_RESEND;
                         ppp->state = PPPOE_STATE_INITIALIZING;
                 } else {
                         r = pppoe_send_request(ppp);
                         if (r < 0)
-                                log_warning("PPPoE: sending PADR failed: %s", strerror(-r));
+                                log_warning_errno(r, "PPPoE: sending PADR failed: %m");
                 }
 
                 break;
@@ -698,8 +690,7 @@ static int pppoe_handle_message(sd_pppoe *ppp, struct pppoe_hdr *packet, struct
         return 0;
 }
 
-static int pppoe_receive_message(sd_event_source *s, int fd,
-                                 uint32_t revents, void *userdata) {
+static int pppoe_receive_message(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
         sd_pppoe *ppp = userdata;
         _cleanup_free_ struct pppoe_hdr *packet = NULL;
         union sockaddr_union link = {};
@@ -721,11 +712,9 @@ static int pppoe_receive_message(sd_event_source *s, int fd,
         if (!packet)
                 return -ENOMEM;
 
-        len = recvfrom(fd, packet, buflen, 0,
-                       &link.sa, &addrlen);
+        len = recvfrom(fd, packet, buflen, 0, &link.sa, &addrlen);
         if (len < 0) {
-                log_warning("PPPoE: colud not receive message from raw socket: %s",
-                          strerror(-r));
+                log_warning_errno(r, "PPPoE: could not receive message from raw socket: %m");
                 return 0;
         } else if ((size_t)len < sizeof(struct pppoe_hdr))
                 return 0;