FreeNOS
|
Ethernet networking protocol. More...
#include <Ethernet.h>
Data Structures | |
struct | Address |
Ethernet network address. More... | |
struct | Header |
Ethernet network packet header. More... | |
Public Types | |
enum | PayloadType { IPV4 = 0x0800u, IPV6 = 0x86ddu, ARP = 0x0806u } |
List of ethernet payload types. More... | |
typedef struct Ethernet::Address | Address |
Ethernet network address. More... | |
typedef struct Ethernet::Header | Header |
Ethernet network packet header. More... | |
Public Member Functions | |
Ethernet (NetworkServer &server, NetworkDevice &device) | |
Constructor. More... | |
virtual | ~Ethernet () |
Destructor. More... | |
virtual FileSystem::Result | initialize () |
Perform initialization. More... | |
virtual FileSystem::Result | getAddress (Address *address) |
Retrieve Ethernet address. More... | |
virtual FileSystem::Result | setAddress (const Address *address) |
Set Ethernet address. More... | |
virtual FileSystem::Result | getTransmitPacket (NetworkQueue::Packet **pkt, const void *address, const Size addressSize, const Identifier protocol, const Size payloadSize) |
Get a new packet for transmission. More... | |
void | setARP (::ARP *arp) |
Set ARP instance. More... | |
void | setIP (::IPV4 *ip) |
Set IPV4 instance. More... | |
virtual FileSystem::Result | process (const NetworkQueue::Packet *pkt, const Size offset) |
Process incoming network packet. More... | |
Public Member Functions inherited from NetworkProtocol | |
NetworkProtocol (NetworkServer &server, NetworkDevice &device, NetworkProtocol &parent) | |
Constructor. More... | |
virtual | ~NetworkProtocol () |
Destructor. More... | |
virtual const Size | getMaximumPacketSize () const |
Get maximum packet size. More... | |
Public Member Functions inherited from Directory | |
Directory (const u32 inode) | |
Constructor. More... | |
virtual | ~Directory () |
Destructor. More... | |
virtual FileSystem::Result | read (IOBuffer &buffer, Size &size, const Size offset) |
Read directory entries. More... | |
virtual File * | lookup (const char *name) |
Retrieve a File from storage. More... | |
void | insert (FileSystem::FileType type, const char *name) |
Insert a new directory entry. More... | |
void | remove (const char *name) |
Remove a directory entry. More... | |
void | clear () |
Clears the internal list of entries. More... | |
Public Member Functions inherited from File | |
File (const u32 inode, const FileSystem::FileType type=FileSystem::RegularFile, const UserID uid=ZERO, const GroupID gid=ZERO) | |
Constructor function. More... | |
virtual | ~File () |
Destructor function. More... | |
u32 | getInode () const |
Get inode number. More... | |
FileSystem::FileType | getType () const |
Retrieve our filetype. More... | |
virtual FileSystem::Result | write (IOBuffer &buffer, Size &size, const Size offset) |
Write bytes to the file. More... | |
virtual FileSystem::Result | status (FileSystem::FileStat &st) |
Retrieve file statistics. More... | |
virtual bool | canRead () const |
Check if the File has data ready for reading. More... | |
virtual bool | canWrite () const |
Check if the File can be written to. More... | |
Static Public Member Functions | |
static const String | toString (const Address address) |
Convert address to string. More... | |
Static Public Attributes | |
static const Size | CRCSize = 4 |
Size of the CRC checksum (which is set after the payload) More... | |
Private Attributes | |
Address | m_address |
Current ethernet address. More... | |
::ARP * | m_arp |
ARP protocol. More... | |
::IPV4 * | m_ipv4 |
IPV4 protocol. More... | |
Additional Inherited Members | |
Protected Types inherited from NetworkProtocol | |
enum | Identifier { Ethernet = 1, IPV4, ARP, ICMP, UDP, TCP } |
List of known network protocol identifiers. More... | |
Protected Attributes inherited from NetworkProtocol | |
NetworkServer & | m_server |
Network server instance. More... | |
NetworkDevice & | m_device |
Network device instance. More... | |
NetworkProtocol & | m_parent |
Parent upper-layer protocol instance. More... | |
Protected Attributes inherited from File | |
const u32 | m_inode |
Inode number. More... | |
const FileSystem::FileType | m_type |
Type of this file. More... | |
UserID | m_uid |
Owner of the file. More... | |
GroupID | m_gid |
Group of the file. More... | |
FileSystem::FileModes | m_access |
Access permissions. More... | |
Size | m_size |
Size of the file, in bytes. More... | |
Ethernet networking protocol.
Definition at line 42 of file Ethernet.h.
typedef struct Ethernet::Address Ethernet::Address |
Ethernet network address.
typedef struct Ethernet::Header Ethernet::Header |
Ethernet network packet header.
This header is prepended to every ethernet packet send on the actual physical link.
List of ethernet payload types.
Enumerator | |
---|---|
IPV4 | Internet protocol v4. |
IPV6 | Internet protocol v6. |
ARP | Address resolution protocol. |
Definition at line 75 of file Ethernet.h.
Ethernet::Ethernet | ( | NetworkServer & | server, |
NetworkDevice & | device | ||
) |
Constructor.
server | Reference to the NetworkServer instance |
device | Reference to the NetworkDevice instance |
Definition at line 26 of file Ethernet.cpp.
References m_address, m_arp, m_ipv4, MemoryBlock::set(), and ZERO.
|
virtual |
Destructor.
Definition at line 35 of file Ethernet.cpp.
|
virtual |
Retrieve Ethernet address.
address | Output buffer to store the address |
Definition at line 49 of file Ethernet.cpp.
References MemoryBlock::copy(), m_address, and FileSystem::Success.
Referenced by EthernetAddress::read().
|
virtual |
Get a new packet for transmission.
pkt | On output contains a pointer to a Packet |
address | Address of the destination of this packet |
addressSize | Number of bytes of the address |
protocol | Identifier for the protocol to create the packet for |
payloadSize | Number of payload bytes |
Reimplemented from NetworkProtocol.
Definition at line 91 of file Ethernet.cpp.
References NetworkProtocol::ARP, MemoryBlock::copy(), Ethernet::Header::destination, ERROR, NetworkQueue::get(), NetworkDevice::getTransmitQueue(), NetworkProtocol::IPV4, m_address, NetworkProtocol::m_device, FileSystem::NotSupported, FileSystem::RetryAgain, Ethernet::Header::source, FileSystem::Success, Ethernet::Header::type, and writeBe16().
|
virtual |
Perform initialization.
Implements NetworkProtocol.
Definition at line 39 of file Ethernet.cpp.
References NetworkDevice::getAddress(), FileSystemServer::getNextInode(), m_address, NetworkProtocol::m_device, NetworkProtocol::m_server, FileSystemServer::registerDirectory(), FileSystemServer::registerFile(), and FileSystem::Success.
Referenced by NetworkDevice::initialize().
|
virtual |
Process incoming network packet.
pkt | Incoming packet pointer |
offset | Offset for processing |
Implements NetworkProtocol.
Definition at line 126 of file Ethernet.cpp.
References ARP, NetworkQueue::Packet::data, DEBUG, FileSystem::InvalidArgument, IPV4, m_arp, m_ipv4, ARP::process(), IPV4::process(), readBe16(), NetworkQueue::Packet::size, type, and Ethernet::Header::type.
Referenced by NetworkDevice::process().
|
virtual |
Set Ethernet address.
address | Input address |
Definition at line 55 of file Ethernet.cpp.
References MemoryBlock::copy(), m_address, NetworkProtocol::m_device, NetworkDevice::setAddress(), and FileSystem::Success.
void Ethernet::setARP | ( | ::ARP * | arp | ) |
Set ARP instance.
arp | ARP object instance |
Definition at line 66 of file Ethernet.cpp.
References m_arp.
Referenced by NetworkDevice::initialize().
void Ethernet::setIP | ( | ::IPV4 * | ip | ) |
Set IPV4 instance.
ip | IPV4 instance |
Definition at line 71 of file Ethernet.cpp.
References m_ipv4.
Referenced by NetworkDevice::initialize().
Convert address to string.
address | Input ethernet address |
Definition at line 76 of file Ethernet.cpp.
References Ethernet::Address::addr, and Number::Hex.
Referenced by NetCtl::showDevice().
|
static |
Size of the CRC checksum (which is set after the payload)
Definition at line 47 of file Ethernet.h.
|
private |
Current ethernet address.
Definition at line 176 of file Ethernet.h.
Referenced by Ethernet(), getAddress(), getTransmitPacket(), initialize(), and setAddress().
|
private |
ARP protocol.
Definition at line 179 of file Ethernet.h.
Referenced by Ethernet(), process(), and setARP().
|
private |
IPV4 protocol.
Definition at line 182 of file Ethernet.h.
Referenced by Ethernet(), process(), and setIP().