FreeNOS
ICMPFactory.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 "ICMPFactory.h"
19#include "ICMPSocket.h"
20
22 ICMP *icmp)
23 : File(inode)
24{
25 m_icmp = icmp;
26}
27
31
33 Size & size,
34 const Size offset)
35{
36 DEBUG("");
37
38 String path;
39 ICMPSocket *sock;
40 const FileSystemMessage *msg = buffer.getMessage();
41
42 if (offset > 0)
43 {
44 size = 0;
46 }
47
48 sock = m_icmp->createSocket(path, msg->from);
49 if (!sock)
50 {
51 ERROR("failed to create ICMP socket");
53 }
54
55 buffer.write(*path, path.length() + 1);
56 size = path.length() + 1;
58}
ProcessID from
Source process of the message.
Represents a file present on a FileSystem.
Definition File.h:40
virtual ~ICMPFactory()
Destructor.
ICMP * m_icmp
ICMP protocol instance.
Definition ICMPFactory.h:74
virtual FileSystem::Result read(IOBuffer &buffer, Size &size, const Size offset)
Create ICMP socket.
ICMPFactory(const u32 inode, ICMP *icmp)
Constructor.
Internet Control Message Protocol (ICMP) socket.
Definition ICMPSocket.h:43
Internet Control Message Protocol (ICMP)
Definition ICMP.h:43
ICMPSocket * createSocket(String &path, const ProcessID pid)
Creates an ICMP socket.
Definition ICMP.cpp:87
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
const FileSystemMessage * getMessage() const
Get filesystem message.
Definition IOBuffer.cpp:120
Abstraction of strings.
Definition String.h:42
Size length() const
Same as count().
Definition String.cpp:105
unsigned int u32
Unsigned 32-bit number.
Definition Types.h:53
#define ERROR(msg)
Output an error message.
Definition Log.h:61
unsigned int Size
Any sane size indicator cannot go negative.
Definition Types.h:128
#define DEBUG(msg)
Output a debug message to standard output.
Definition Log.h:89
Result
Result code for filesystem Actions.
Definition FileSystem.h:53
FileSystem IPC message.