NetSim 1.0.0
An educational network simulation software for students
Loading...
Searching...
No Matches
package.h
Go to the documentation of this file.
1#ifndef PACKAGE_H
2#define PACKAGE_H
3
4#include "ipaddress.h"
5#include "macaddress.h"
6#include "port.h"
8#include <QList>
9
13
14namespace NetSim {
15
18
28class Package {
29public:
31 Package() = default;
32
34 explicit Package(const QString &info);
35
37 Package(const QString &info, const QString &content);
38
40 QString content() const;
41
43 QList<Header> headers() const;
44
46 QString info() const;
47
49 quint16 size() const;
50
52 void addHeader(const Header &header);
53
55 void setContent(const QString &content);
56
58 void changePortAndIP(const Port &number, const IPAddress &address, bool src);
59
61 void changeEthernetHeader(const MACAddress &srcAddress,
62 const MACAddress &destAddress);
63
66
68 Header operator[](const NetSim::HeaderType &type) const;
69
70private:
72 QList<Header> m_headers{};
73
75 QString m_info{"Basic Description"};
76
78 QString m_content{};
79};
80} // namespace NetSim
81
82#endif // PACKAGE_H
Class representing headers for different protocols.
Definition header.h:30
Represents an IPv4 address.
Definition ipaddress.h:27
Represents a Media Access Control (MAC) address.
Definition macaddress.h:26
Represents a network package.
Definition package.h:28
void changeEthernetHeader(const MACAddress &srcAddress, const MACAddress &destAddress)
Modifies the Ethernet header.
Definition package.cpp:90
QList< Header > headers() const
Returns the list of headers.
Definition package.cpp:13
QString info() const
Returns the package's information.
Definition package.cpp:17
Header & operator[](const NetSim::HeaderType &type)
Returns a reference to a specific header.
Definition package.cpp:114
void setContent(const QString &content)
Sets the package's content.
Definition package.cpp:19
Package()=default
Default constructor.
void changePortAndIP(const Port &number, const IPAddress &address, bool src)
Modifies the IP and port headers.
Definition package.cpp:31
QString content() const
Returns the package's content.
Definition package.cpp:11
void addHeader(const Header &header)
Adds a new header to the package.
Definition package.cpp:15
quint16 size() const
Returns the total size of the package.
Definition package.cpp:22
Represents a network port.
Definition port.h:24
Contains the Header class definition and related enumerations.
Contains the IPAddress class definition.
Contains the MACAddress class definition.
Definition logger.h:12
HeaderType
Definition header.h:23
Contains the Port class definition.