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
32
34 Size & size,
35 const Size offset)
36{
38 m_eth->getAddress(&addr);
39
40 if (offset >= m_size)
41 {
42 size = 0;
44 }
45
46 buffer.write(&addr, sizeof(addr));
47 size = sizeof(addr);
48
50}
51
53 Size & size,
54 const Size offset)
55{
57}
EthernetAddress(const u32 inode, Ethernet *eth)
Constructor.
virtual FileSystem::Result read(IOBuffer &buffer, Size &size, const Size offset)
Read Ethernet address.
virtual ~EthernetAddress()
Destructor.
Ethernet * m_eth
Ethernet object pointer.
virtual FileSystem::Result write(IOBuffer &buffer, Size &size, const Size offset)
Set new Ethernet address.
Ethernet networking protocol.
Definition Ethernet.h:43
virtual FileSystem::Result getAddress(Address *address)
Retrieve Ethernet address.
Definition Ethernet.cpp:49
Represents a file present on a FileSystem.
Definition File.h:40
Size m_size
Size of the file, in bytes.
Definition File.h:148
Abstract Input/Output buffer.
Definition IOBuffer.h:38
FileSystem::Result write(const void *buffer, const Size size, const Size offset=ZERO)
Write bytes to the I/O buffer.
Definition IOBuffer.cpp:180
unsigned int u32
Unsigned 32-bit number.
Definition Types.h:53
unsigned int Size
Any sane size indicator cannot go negative.
Definition Types.h:128
Result
Result code for filesystem Actions.
Definition FileSystem.h:53
Ethernet network address.
Definition Ethernet.h:53