FreeNOS
ICMPSocket.h
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 #ifndef __LIB_LIBNET_ICMPSOCKET_H
19 #define __LIB_LIBNET_ICMPSOCKET_H
20 
21 #include "NetworkSocket.h"
22 #include "NetworkQueue.h"
23 #include "NetworkClient.h"
24 
25 class ICMP;
26 
42 class ICMPSocket : public NetworkSocket
43 {
44  public:
45 
53  ICMPSocket(const u32 inode,
54  ICMP *icmp,
55  const ProcessID pid);
56 
60  virtual ~ICMPSocket();
61 
67  const IPV4::Address getAddress() const;
68 
79  virtual FileSystem::Result read(IOBuffer & buffer,
80  Size & size,
81  const Size offset);
82 
93  virtual FileSystem::Result write(IOBuffer & buffer,
94  Size & size,
95  const Size offset);
96 
104  virtual FileSystem::Result process(const NetworkQueue::Packet *pkt);
105 
111  void setReply(const ICMP::Header *reply);
112 
113  private:
114 
117 
121 };
122 
128 #endif /* __LIB_LIBNET_ICMPSOCKET_H */
ICMP::Header
Packet header format.
Definition: ICMP.h:64
ICMPSocket::process
virtual FileSystem::Result process(const NetworkQueue::Packet *pkt)
Process incoming network packet.
Definition: ICMPSocket.cpp:82
ICMPSocket::m_reply
ICMP::Header m_reply
Reply.
Definition: ICMPSocket.h:119
ProcessID
u32 ProcessID
Process Identification Number.
Definition: Types.h:140
NetworkQueue.h
ICMPSocket::write
virtual FileSystem::Result write(IOBuffer &buffer, Size &size, const Size offset)
Send ICMP request.
Definition: ICMPSocket.cpp:61
ICMPSocket::m_gotReply
bool m_gotReply
Definition: ICMPSocket.h:120
ICMPSocket::setReply
void setReply(const ICMP::Header *reply)
Set ICMP reply.
Definition: ICMPSocket.cpp:89
ICMPSocket::getAddress
const IPV4::Address getAddress() const
Get associated IP host.
Definition: ICMPSocket.cpp:39
IOBuffer
Abstract Input/Output buffer.
Definition: IOBuffer.h:37
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
ICMPSocket::~ICMPSocket
virtual ~ICMPSocket()
Destructor.
Definition: ICMPSocket.cpp:35
IPV4::Address
u32 Address
IP-address.
Definition: IPV4.h:47
ICMPSocket::read
virtual FileSystem::Result read(IOBuffer &buffer, Size &size, const Size offset)
Read ICMP response.
Definition: ICMPSocket.cpp:44
NetworkSocket
Network socket represents a single logical connection on a protocol.
Definition: NetworkSocket.h:37
FileSystem::Result
Result
Result code for filesystem Actions.
Definition: FileSystem.h:52
ICMPSocket::ICMPSocket
ICMPSocket(const u32 inode, ICMP *icmp, const ProcessID pid)
Constructor.
Definition: ICMPSocket.cpp:25
NetworkClient.h
NetworkQueue::Packet
Represents a network packet.
Definition: NetworkQueue.h:50
ICMPSocket::m_icmp
ICMP * m_icmp
ICMP protocol instance.
Definition: ICMPSocket.h:116
ICMPSocket
Internet Control Message Protocol (ICMP) socket.
Definition: ICMPSocket.h:42
NetworkSocket.h
ICMP
Internet Control Message Protocol (ICMP)
Definition: ICMP.h:42