NetSim 1.0.0
An educational network simulation software for students
Loading...
Searching...
No Matches
ipv4.h
Go to the documentation of this file.
1#ifndef IPV4_H
2#define IPV4_H
3
6#include <QDebug>
7#include <QList>
8#include <QString>
9#include <QVector>
10
14
15namespace NetSim {
16
19
21enum IPFlag { MF = 0, DF = 1 };
22
33class IPv4 {
34public:
48 static void initHeader(quint16 id, bool DF, bool MF, quint16 fragmentOffset,
49 quint8 ttl, quint8 protocol,
50 const IPAddress &sourceAddress,
51 const IPAddress &destinationAdress, Package &data);
52
53private:
69 static quint16 getIPv4Checksum(quint16 totalLength, quint16 id, quint8 flags,
70 quint16 fragOffset, quint8 ttl,
71 quint8 protocol,
72 const QVector<quint8> &srcAddress,
73 const QVector<quint8> &destAddress,
74 const char *data, quint16 dataLength);
75
84 static void setFlag(quint8 *flags, bool set, quint8 position);
85};
86} // namespace NetSim
87
88#endif // IPV4_H
Represents an IPv4 address.
Definition ipaddress.h:27
A static class that provides methods to handle IPv4 headers and their checksum.
Definition ipv4.h:33
static void initHeader(quint16 id, bool DF, bool MF, quint16 fragmentOffset, quint8 ttl, quint8 protocol, const IPAddress &sourceAddress, const IPAddress &destinationAdress, Package &data)
Initializes an IPv4 header.
Definition ipv4.cpp:6
Represents a network package.
Definition package.h:28
Contains the IPAddress class definition.
Definition logger.h:12
IPFlag
Enumeration representing IP Flags.
Definition ipv4.h:21
@ DF
Definition ipv4.h:21
@ MF
Definition ipv4.h:21
Contains the Package class definition.