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
27class ICMPFactory;
28class ICMPSocket;
29class ARP;
30
42class ICMP : public NetworkProtocol
43{
44 private:
45
46 static const Size MaxIcmpSockets = 128u;
47
48 public:
49
60
64 typedef struct Header
65 {
71 }
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
103
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 */
SystemDescriptorHeader header
Definition IntelACPI.h:0
Address Resolution Protocol.
Definition ARP.h:43
Internet Control Message Protocol (ICMP) factory.
Definition ICMPFactory.h:40
Internet Control Message Protocol (ICMP) socket.
Definition ICMPSocket.h:43
Internet Control Message Protocol (ICMP)
Definition ICMP.h:43
ICMPFactory * m_factory
Definition ICMP.h:147
Index< ICMPSocket, MaxIcmpSockets > m_sockets
Definition ICMP.h:149
ICMPSocket * createSocket(String &path, const ProcessID pid)
Creates an ICMP socket.
Definition ICMP.cpp:87
virtual ~ICMP()
Destructor.
Definition ICMP.cpp:33
FileSystem::Result sendPacket(const IPV4::Address ip, const Header *header, const void *payload, const Size payloadSize)
Send packet.
Definition ICMP.cpp:148
virtual FileSystem::Result process(const NetworkQueue::Packet *pkt, const Size offset)
Process incoming network packet.
Definition ICMP.cpp:48
void unregisterSockets(const ProcessID pid)
Remove sockets for a process.
Definition ICMP.cpp:126
struct ICMP::Header Header
Packet header format.
Type
Packet types.
Definition ICMP.h:54
@ Redirect
Definition ICMP.h:57
@ EchoRequest
Definition ICMP.h:58
@ EchoReply
Definition ICMP.h:55
@ DestinationUnreachable
Definition ICMP.h:56
static const Size MaxIcmpSockets
Definition ICMP.h:46
virtual FileSystem::Result initialize()
Perform initialization.
Definition ICMP.cpp:37
void setIP(::IPV4 *ip)
Set IP object.
Internet Protocol Version 4.
Definition IPV4.h:41
u32 Address
IP-address.
Definition IPV4.h:47
Index is a N-sized array of pointers to items of type T.
Definition Index.h:37
Network Device abstract class.
Network protocol abstraction class.
Networking server.
Abstraction of strings.
Definition String.h:42
u32 ProcessID
Process Identification Number.
Definition Types.h:140
unsigned short u16
Unsigned 16-bit number.
Definition Types.h:56
unsigned int Size
Any sane size indicator cannot go negative.
Definition Types.h:128
unsigned char u8
Unsigned 8-bit number.
Definition Types.h:59
Result
Result code for filesystem Actions.
Definition FileSystem.h:53
Packet header format.
Definition ICMP.h:65
u16 sequence
Definition ICMP.h:70
u16 id
Definition ICMP.h:69
u8 code
Definition ICMP.h:67
u16 checksum
Definition ICMP.h:68
u8 type
Definition ICMP.h:66
Represents a network packet.