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))
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);
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 = {};
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("PPPoE: could not receive message from raw socket: %s", strerror(-r));
return 0;
} else if ((size_t)len < sizeof(struct pppoe_hdr))
return 0;