xref: /reactos/drivers/network/dd/nvnet/eth.h (revision f308c6a2)
1 /*
2  * PROJECT:     ReactOS nVidia nForce Ethernet Controller Driver
3  * LICENSE:     GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4  * PURPOSE:     Ethernet definitions
5  * COPYRIGHT:   Copyright 2021-2022 Dmitry Borisov <di.sean@protonmail.com>
6  */
7 
8 #pragma once
9 
10 #include <pshpack1.h>
11 typedef struct _ETH_HEADER
12 {
13     UCHAR Destination[ETH_LENGTH_OF_ADDRESS];
14     UCHAR Source[ETH_LENGTH_OF_ADDRESS];
15     USHORT PayloadType;
16 } ETH_HEADER, *PETH_HEADER;
17 #include <poppack.h>
18 
19 #define ETH_IS_LOCALLY_ADMINISTERED(Address) \
20     (BOOLEAN)(((PUCHAR)(Address))[0] & ((UCHAR)0x02))
21 
22 #define ETH_IS_EMPTY(Address) \
23     (BOOLEAN)((((PUCHAR)(Address))[0] | ((PUCHAR)(Address))[1] | ((PUCHAR)(Address))[2] | \
24                ((PUCHAR)(Address))[3] | ((PUCHAR)(Address))[5] | ((PUCHAR)(Address))[5]) == 0)
25 
26 typedef struct IPv4_HEADER
27 {
28     UCHAR VersionLength;
29     UCHAR Tos;
30     USHORT TotalLength;
31     USHORT Id;
32     USHORT Offset;
33     UCHAR Ttl;
34     UCHAR Protocol;
35     USHORT Checksum;
36     ULONG Source;
37     ULONG Destination;
38 } IPv4_HEADER, *PIPv4_HEADER;
39 
40 typedef struct TCPv4_HEADER
41 {
42     USHORT SourcePort;
43     USHORT DestinationPort;
44     ULONG SequenceNumber;
45     ULONG AckNumber;
46     UCHAR DataOffset;
47     UCHAR Flags;
48     USHORT Window;
49     USHORT Checksum;
50     USHORT Urgent;
51 } TCPv4_HEADER, *PTCPv4_HEADER;
52 
53 #define IP_HEADER_LENGTH(Header) \
54     (((Header)->VersionLength & 0x0F) << 2)
55 
56 #define TCP_HEADER_LENGTH(Header) \
57     ((Header->DataOffset & 0xF0) >> 2)
58