FreeNOS
EthernetAddress.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Niek Linnenbank
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #include <Log.h>
19 #include "EthernetAddress.h"
20 
22  Ethernet *eth)
23  : File(inode)
24  , m_eth(eth)
25 {
26  m_size = sizeof(Ethernet::Address);
27 }
28 
30 {
31 }
32 
34  Size & size,
35  const Size offset)
36 {
37  Ethernet::Address addr;
38  m_eth->getAddress(&addr);
39 
40  if (offset >= m_size)
41  {
42  size = 0;
43  return FileSystem::Success;
44  }
45 
46  buffer.write(&addr, sizeof(addr));
47  size = sizeof(addr);
48 
49  return FileSystem::Success;
50 }
51 
53  Size & size,
54  const Size offset)
55 {
57 }
Ethernet::getAddress
virtual FileSystem::Result getAddress(Address *address)
Retrieve Ethernet address.
Definition: Ethernet.cpp:49
EthernetAddress::m_eth
Ethernet * m_eth
Ethernet object pointer.
Definition: EthernetAddress.h:85
EthernetAddress::EthernetAddress
EthernetAddress(const u32 inode, Ethernet *eth)
Constructor.
Definition: EthernetAddress.cpp:21
EthernetAddress::~EthernetAddress
virtual ~EthernetAddress()
Destructor.
Definition: EthernetAddress.cpp:29
FileSystem::Success
@ Success
Definition: FileSystem.h:54
File
Represents a file present on a FileSystem.
Definition: File.h:39
Ethernet
Ethernet networking protocol.
Definition: Ethernet.h:42
Log.h
FileSystem::NotSupported
@ NotSupported
Definition: FileSystem.h:61
EthernetAddress.h
Ethernet::Address
Ethernet network address.
Definition: Ethernet.h:52
File::m_size
Size m_size
Size of the file, in bytes.
Definition: File.h:148
IOBuffer
Abstract Input/Output buffer.
Definition: IOBuffer.h:37
EthernetAddress::write
virtual FileSystem::Result write(IOBuffer &buffer, Size &size, const Size offset)
Set new Ethernet address.
Definition: EthernetAddress.cpp:52
u32
unsigned int u32
Unsigned 32-bit number.
Definition: Types.h:53
Size
unsigned int Size
Any sane size indicator cannot go negative.
Definition: Types.h:128
EthernetAddress::read
virtual FileSystem::Result read(IOBuffer &buffer, Size &size, const Size offset)
Read Ethernet address.
Definition: EthernetAddress.cpp:33
FileSystem::Result
Result
Result code for filesystem Actions.
Definition: FileSystem.h:52
IOBuffer::write
FileSystem::Result write(const void *buffer, const Size size, const Size offset=ZERO)
Write bytes to the I/O buffer.
Definition: IOBuffer.cpp:180
Ethernet::Address
struct Ethernet::Address Address
Ethernet network address.