mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2024-12-25 23:10:32 +00:00
Deduce when ethertype field is actually data length
This commit is contained in:
parent
3809e15849
commit
f709dc872a
2 changed files with 12 additions and 10 deletions
|
@ -27,16 +27,12 @@ U0 EthernetGlobalsInit()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: check length , figure out the length+4
|
|
||||||
U0 EthernetFrameParse(CEthernetFrame *frame_out, U8 *frame, U16 length)
|
U0 EthernetFrameParse(CEthernetFrame *frame_out, U8 *frame, U16 length)
|
||||||
{
|
{
|
||||||
//TODO: Check length ! We need to figure out what
|
// Shrine says MemCopy has a high overhead.
|
||||||
//lengths are appropriate
|
// Almost tempted to say that means that a lot
|
||||||
|
// of the current system should be done with
|
||||||
//Shrine also says MemCopy has a
|
// less extra allocation altogether, more passing.
|
||||||
//high overhead. Almost tempted to say that means that a lot
|
|
||||||
//of the current system should be done with less extra allocation
|
|
||||||
//altogether, more passing.
|
|
||||||
// In practice, MemCopy causes the most slowdown on bare-metal.
|
// In practice, MemCopy causes the most slowdown on bare-metal.
|
||||||
|
|
||||||
NetLog("ETHERNET FRAME PARSE: Parsing frame, copying out to frame_out param.");
|
NetLog("ETHERNET FRAME PARSE: Parsing frame, copying out to frame_out param.");
|
||||||
|
@ -49,7 +45,10 @@ U0 EthernetFrameParse(CEthernetFrame *frame_out, U8 *frame, U16 length)
|
||||||
|
|
||||||
frame_out->data = frame + ETHERNET_DATA_OFFSET;
|
frame_out->data = frame + ETHERNET_DATA_OFFSET;
|
||||||
|
|
||||||
frame_out->length = length - ETHERNET_MAC_HEADER_LENGTH - 4; // He has a comment literally just saying "??". + or - 4?
|
if (frame_out->ethertype <= ETHERNET_v2_MTU) // check if the field is a length or an ethertype
|
||||||
|
frame_out->length = frame_out->ethertype;
|
||||||
|
else
|
||||||
|
frame_out->length = length - ETHERNET_MAC_HEADER_LENGTH - FCS_LENGTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
U0 EthernetFrameFinish(I64 de_index)
|
U0 EthernetFrameFinish(I64 de_index)
|
||||||
|
|
|
@ -5,11 +5,14 @@
|
||||||
#define ETHERNET_ETHERTYPE_OFFSET 12
|
#define ETHERNET_ETHERTYPE_OFFSET 12
|
||||||
#define ETHERNET_DATA_OFFSET 14
|
#define ETHERNET_DATA_OFFSET 14
|
||||||
#define MAC_ADDRESS_LENGTH 6
|
#define MAC_ADDRESS_LENGTH 6
|
||||||
|
#define FCS_LENGTH 4
|
||||||
|
|
||||||
/* Ethernet Frame Size.
|
/* Ethernet Frame Size.
|
||||||
Linux uses 1544, OSDev and Shrine use 1548. Based on IEEE 802.3as, max frame size was agreed upon as 2000 bytes. */
|
Linux uses 1544, OSDev and Shrine use 1548. Based on IEEE 802.3as, max frame size was agreed upon as 2000 bytes. */
|
||||||
#define ETHERNET_FRAME_SIZE 2000
|
#define ETHERNET_FRAME_SIZE 2000
|
||||||
|
|
||||||
|
#define ETHERNET_v2_MTU 1500
|
||||||
|
|
||||||
#define HTYPE_ETHERNET 1
|
#define HTYPE_ETHERNET 1
|
||||||
#define HLEN_ETHERNET 6
|
#define HLEN_ETHERNET 6
|
||||||
#define PLEN_IPV4 4
|
#define PLEN_IPV4 4
|
||||||
|
|
Loading…
Reference in a new issue