FreeNOS
ICMP.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_ICMP_H
19 #define __LIB_LIBNET_ICMP_H
20 
21 #include <Types.h>
22 #include <Index.h>
23 #include <String.h>
24 #include "NetworkProtocol.h"
25 #include "IPV4.h"
26 
27 class ICMPFactory;
28 class ICMPSocket;
29 class ARP;
30 
42 class ICMP : public NetworkProtocol
43 {
44  private:
45 
46  static const Size MaxIcmpSockets = 128u;
47 
48  public:
49 
53  enum Type
54  {
55  EchoReply = 0,
57  Redirect = 5,
59  };
60 
64  typedef struct Header
65  {
71  }
72  Header;
73 
74  public:
75 
83  ICMP(NetworkServer &server,
84  NetworkDevice &device,
85  NetworkProtocol &parent);
86 
90  virtual ~ICMP();
91 
95  void setIP(::IPV4 *ip);
96 
102  virtual FileSystem::Result initialize();
103 
109  ICMPSocket * createSocket(String & path,
110  const ProcessID pid);
111 
117  void unregisterSockets(const ProcessID pid);
118 
128  const Size offset);
129 
141  const Header *header,
142  const void *payload,
143  const Size payloadSize);
144 
145  private:
146 
148 
150 };
151 
157 #endif /* __LIB_LIBNET_ICMP_H */
ICMPFactory
Internet Control Message Protocol (ICMP) factory.
Definition: ICMPFactory.h:39
NetworkProtocol
Network protocol abstraction class.
Definition: NetworkProtocol.h:39
ICMP::setIP
void setIP(::IPV4 *ip)
Set IP object.
ICMP::Header::id
u16 id
Definition: ICMP.h:69
ICMP::Header
Packet header format.
Definition: ICMP.h:64
Types.h
Index.h
ICMP::DestinationUnreachable
@ DestinationUnreachable
Definition: ICMP.h:56
String
Abstraction of strings.
Definition: String.h:41
NetworkDevice
Network Device abstract class.
Definition: NetworkDevice.h:41
ICMP::Header::checksum
u16 checksum
Definition: ICMP.h:68
ICMP::MaxIcmpSockets
static const Size MaxIcmpSockets
Definition: ICMP.h:46
ICMP::createSocket
ICMPSocket * createSocket(String &path, const ProcessID pid)
Creates an ICMP socket.
Definition: ICMP.cpp:87
ICMP::m_factory
ICMPFactory * m_factory
Definition: ICMP.h:147
Index< ICMPSocket, MaxIcmpSockets >
ProcessID
u32 ProcessID
Process Identification Number.
Definition: Types.h:140
ICMP::Redirect
@ Redirect
Definition: ICMP.h:57
ICMP::process
virtual FileSystem::Result process(const NetworkQueue::Packet *pkt, const Size offset)
Process incoming network packet.
Definition: ICMP.cpp:48
ICMP::Header::code
u8 code
Definition: ICMP.h:67
ICMP::Header::type
u8 type
Definition: ICMP.h:66
NetworkProtocol.h
ICMP::sendPacket
FileSystem::Result sendPacket(const IPV4::Address ip, const Header *header, const void *payload, const Size payloadSize)
Send packet.
Definition: ICMP.cpp:148
ICMP::~ICMP
virtual ~ICMP()
Destructor.
Definition: ICMP.cpp:33
ICMP::EchoReply
@ EchoReply
Definition: ICMP.h:55
ICMP::initialize
virtual FileSystem::Result initialize()
Perform initialization.
Definition: ICMP.cpp:37
NetworkServer
Networking server.
Definition: NetworkServer.h:40
header
SystemDescriptorHeader header
Definition: IntelACPI.h:63
u16
unsigned short u16
Unsigned 16-bit number.
Definition: Types.h:56
ICMP::unregisterSockets
void unregisterSockets(const ProcessID pid)
Remove sockets for a process.
Definition: ICMP.cpp:126
Size
unsigned int Size
Any sane size indicator cannot go negative.
Definition: Types.h:128
IPV4::Address
u32 Address
IP-address.
Definition: IPV4.h:47
IPV4.h
IPV4
Internet Protocol Version 4.
Definition: IPV4.h:40
NetworkProtocol::ICMP
@ ICMP
Definition: NetworkProtocol.h:51
FileSystem::Result
Result
Result code for filesystem Actions.
Definition: FileSystem.h:52
u8
unsigned char u8
Unsigned 8-bit number.
Definition: Types.h:59
ICMP::EchoRequest
@ EchoRequest
Definition: ICMP.h:58
String.h
ICMP::Type
Type
Packet types.
Definition: ICMP.h:53
ICMP::m_sockets
Index< ICMPSocket, MaxIcmpSockets > m_sockets
Definition: ICMP.h:149
ICMP::Header::sequence
u16 sequence
Definition: ICMP.h:70
NetworkQueue::Packet
Represents a network packet.
Definition: NetworkQueue.h:50
ARP
Address Resolution Protocol.
Definition: ARP.h:42
ICMP::Header
struct ICMP::Header Header
Packet header format.
ICMPSocket
Internet Control Message Protocol (ICMP) socket.
Definition: ICMPSocket.h:42
ICMP
Internet Control Message Protocol (ICMP)
Definition: ICMP.h:42