[RP-PPPoE] rp-pppoe.h: endian detection patch
Sascha W.
master.b.at.raven at chefmail.de
Mon Jul 30 18:21:39 EDT 2012
enhencement patch
--- pppoe.h 2011-10-23 22:40:39.000000000 +0200
+++ dd-wrt/rp-pppoe-3.5/src/pppoe.h 2012-07-31 00:19:03.436946019 +0200
@@ -218,21 +218,24 @@
#define IPV4ALEN 4
#define SMALLBUF 256
+
/* A PPPoE Packet, including Ethernet headers */
typedef struct PPPoEPacketStruct {
struct ethhdr ethHdr; /* Ethernet header */
-#ifdef PACK_BITFIELDS_REVERSED
+#if __BYTE_ORDER == __BIG_ENDIAN
unsigned int type:4; /* PPPoE Type (must be 1) */
unsigned int ver:4; /* PPPoE Version (must be 1) */
-#else
+#elif __BYTE_ORDER == __LITTLE_ENDIAN
unsigned int ver:4; /* PPPoE Version (must be 1) */
unsigned int type:4; /* PPPoE Type (must be 1) */
+#else
+#error "Could not determine the system's endianness"
#endif
unsigned int code:8; /* PPPoE code */
unsigned int session:16; /* PPPoE session */
unsigned int length:16; /* Payload length */
unsigned char payload[ETH_DATA_LEN]; /* A bit of room to spare */
-} PPPoEPacket;
+} __attribute__((packed)) PPPoEPacket;
/* Header size of a PPPoE packet */
#define PPPOE_OVERHEAD 6 /* type, code, session, length */
@@ -246,7 +249,7 @@
unsigned int type:16; /* tag type */
unsigned int length:16; /* Length of payload */
unsigned char payload[ETH_DATA_LEN]; /* A LOT of room to spare */
-} PPPoETag;
+} __attribute__((packed)) PPPoETag;
/* Header size of a PPPoE tag */
#define TAG_HDR_SIZE 4
Sash
(DD-WRT)
More information about the RP-PPPoE
mailing list