mirror of https://github.com/PCSX2/pcsx2.git
DEV9: Apply const within in PacketReader
This commit is contained in:
parent
a8a170ebe6
commit
5de1c60d50
|
@ -16,7 +16,7 @@ namespace PacketReader::ARP
|
|||
{
|
||||
}
|
||||
|
||||
ARP_Packet::ARP_Packet(u8* buffer, int bufferSize)
|
||||
ARP_Packet::ARP_Packet(const u8* buffer, int bufferSize)
|
||||
{
|
||||
int offset = 0;
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace PacketReader::ARP
|
|||
std::unique_ptr<u8[]> targetProtocolAddress;
|
||||
|
||||
ARP_Packet(u8 hwAddrLen, u8 procAddrLen);
|
||||
ARP_Packet(u8* buffer, int bufferSize);
|
||||
ARP_Packet(const u8* buffer, int bufferSize);
|
||||
ARP_Packet(const ARP_Packet&);
|
||||
|
||||
virtual int GetLength();
|
||||
|
|
|
@ -16,54 +16,54 @@ namespace PacketReader::ARP
|
|||
{
|
||||
}
|
||||
|
||||
u16 ARP_PacketEditor::GetHardwareType()
|
||||
u16 ARP_PacketEditor::GetHardwareType() const
|
||||
{
|
||||
return ntohs(*(u16*)&basePkt->data[0]);
|
||||
}
|
||||
|
||||
u16 ARP_PacketEditor::GetProtocol()
|
||||
u16 ARP_PacketEditor::GetProtocol() const
|
||||
{
|
||||
return ntohs(*(u16*)&basePkt->data[2]);
|
||||
}
|
||||
|
||||
u8 ARP_PacketEditor::GetHardwareAddressLength()
|
||||
u8 ARP_PacketEditor::GetHardwareAddressLength() const
|
||||
{
|
||||
return basePkt->data[4];
|
||||
}
|
||||
u8 ARP_PacketEditor::GetProtocolAddressLength()
|
||||
u8 ARP_PacketEditor::GetProtocolAddressLength() const
|
||||
{
|
||||
return basePkt->data[5];
|
||||
}
|
||||
|
||||
u16 ARP_PacketEditor::GetOp()
|
||||
u16 ARP_PacketEditor::GetOp() const
|
||||
{
|
||||
return ntohs(*(u16*)&basePkt->data[6]);
|
||||
}
|
||||
|
||||
u8* ARP_PacketEditor::SenderHardwareAddress()
|
||||
u8* ARP_PacketEditor::SenderHardwareAddress() const
|
||||
{
|
||||
return &basePkt->data[8];
|
||||
}
|
||||
|
||||
u8* ARP_PacketEditor::SenderProtocolAddress()
|
||||
u8* ARP_PacketEditor::SenderProtocolAddress() const
|
||||
{
|
||||
int offset = 8 + GetHardwareAddressLength();
|
||||
const int offset = 8 + GetHardwareAddressLength();
|
||||
return &basePkt->data[offset];
|
||||
}
|
||||
|
||||
u8* ARP_PacketEditor::TargetHardwareAddress()
|
||||
u8* ARP_PacketEditor::TargetHardwareAddress() const
|
||||
{
|
||||
int offset = 8 + GetHardwareAddressLength() + GetProtocolAddressLength();
|
||||
const int offset = 8 + GetHardwareAddressLength() + GetProtocolAddressLength();
|
||||
return &basePkt->data[offset];
|
||||
}
|
||||
|
||||
u8* ARP_PacketEditor::TargetProtocolAddress()
|
||||
u8* ARP_PacketEditor::TargetProtocolAddress() const
|
||||
{
|
||||
int offset = 8 + 2 * GetHardwareAddressLength() + GetProtocolAddressLength();
|
||||
const int offset = 8 + 2 * GetHardwareAddressLength() + GetProtocolAddressLength();
|
||||
return &basePkt->data[offset];
|
||||
}
|
||||
|
||||
int ARP_PacketEditor::GetLength()
|
||||
int ARP_PacketEditor::GetLength() const
|
||||
{
|
||||
return 8 + 2 * GetHardwareAddressLength() + 2 * GetProtocolAddressLength();
|
||||
}
|
||||
|
|
|
@ -15,17 +15,17 @@ namespace PacketReader::ARP
|
|||
public:
|
||||
ARP_PacketEditor(PayloadPtrEditor* pkt);
|
||||
|
||||
u16 GetHardwareType();
|
||||
u16 GetProtocol();
|
||||
u8 GetHardwareAddressLength();
|
||||
u8 GetProtocolAddressLength();
|
||||
u16 GetOp();
|
||||
u16 GetHardwareType() const;
|
||||
u16 GetProtocol() const;
|
||||
u8 GetHardwareAddressLength() const;
|
||||
u8 GetProtocolAddressLength() const;
|
||||
u16 GetOp() const;
|
||||
|
||||
u8* SenderHardwareAddress();
|
||||
u8* SenderProtocolAddress();
|
||||
u8* TargetHardwareAddress();
|
||||
u8* TargetProtocolAddress();
|
||||
u8* SenderHardwareAddress() const;
|
||||
u8* SenderProtocolAddress() const;
|
||||
u8* TargetHardwareAddress() const;
|
||||
u8* TargetProtocolAddress() const;
|
||||
|
||||
int GetLength();
|
||||
int GetLength() const;
|
||||
};
|
||||
} // namespace PacketReader::ARP
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace PacketReader
|
|||
payload = std::make_unique<PayloadPtrEditor>((u8*)&basePkt->buffer[14], pkt->size - headerLength);
|
||||
}
|
||||
|
||||
MAC_Address EthernetFrameEditor::GetDestinationMAC()
|
||||
MAC_Address EthernetFrameEditor::GetDestinationMAC() const
|
||||
{
|
||||
return *(MAC_Address*)&basePkt->buffer[0];
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ namespace PacketReader
|
|||
*(MAC_Address*)&basePkt->buffer[0] = value;
|
||||
}
|
||||
|
||||
MAC_Address EthernetFrameEditor::GetSourceMAC()
|
||||
MAC_Address EthernetFrameEditor::GetSourceMAC() const
|
||||
{
|
||||
return *(MAC_Address*)&basePkt->buffer[6];
|
||||
}
|
||||
|
@ -40,12 +40,12 @@ namespace PacketReader
|
|||
*(MAC_Address*)&basePkt->buffer[6] = value;
|
||||
}
|
||||
|
||||
u16 EthernetFrameEditor::GetProtocol()
|
||||
u16 EthernetFrameEditor::GetProtocol() const
|
||||
{
|
||||
return ntohs(*(u16*)&basePkt->buffer[12]);
|
||||
}
|
||||
|
||||
PayloadPtrEditor* EthernetFrameEditor::GetPayload()
|
||||
PayloadPtrEditor* EthernetFrameEditor::GetPayload() const
|
||||
{
|
||||
return payload.get();
|
||||
}
|
||||
|
|
|
@ -21,13 +21,13 @@ namespace PacketReader
|
|||
public:
|
||||
EthernetFrameEditor(NetPacket* pkt);
|
||||
|
||||
MAC_Address GetDestinationMAC();
|
||||
MAC_Address GetDestinationMAC() const;
|
||||
void SetDestinationMAC(MAC_Address value);
|
||||
MAC_Address GetSourceMAC();
|
||||
MAC_Address GetSourceMAC() const;
|
||||
void SetSourceMAC(MAC_Address value);
|
||||
|
||||
u16 GetProtocol();
|
||||
u16 GetProtocol() const;
|
||||
|
||||
PayloadPtrEditor* GetPayload();
|
||||
PayloadPtrEditor* GetPayload() const;
|
||||
};
|
||||
} // namespace PacketReader
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace PacketReader::IP::ICMP
|
|||
memcpy(headerData, original.headerData, 4);
|
||||
}
|
||||
|
||||
Payload* ICMP_Packet::GetPayload()
|
||||
Payload* ICMP_Packet::GetPayload() const
|
||||
{
|
||||
return payload.get();
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ namespace PacketReader::IP::ICMP
|
|||
return new ICMP_Packet(*this);
|
||||
}
|
||||
|
||||
u8 ICMP_Packet::GetProtocol()
|
||||
u8 ICMP_Packet::GetProtocol() const
|
||||
{
|
||||
return (u8)protocol;
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ namespace PacketReader::IP::ICMP
|
|||
if (counter != pHeaderLen)
|
||||
NetLib::WriteByte08(segment, &counter, 0);
|
||||
|
||||
u16 csumCal = IP_Packet::InternetChecksum(segment, pHeaderLen);
|
||||
const u16 csumCal = IP_Packet::InternetChecksum(segment, pHeaderLen);
|
||||
delete[] segment;
|
||||
|
||||
return (csumCal == 0);
|
||||
|
|
|
@ -30,13 +30,13 @@ namespace PacketReader::IP::ICMP
|
|||
ICMP_Packet(const u8* buffer, int bufferSize);
|
||||
ICMP_Packet(const ICMP_Packet&);
|
||||
|
||||
Payload* GetPayload();
|
||||
Payload* GetPayload() const;
|
||||
|
||||
virtual int GetLength();
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual ICMP_Packet* Clone() const;
|
||||
|
||||
virtual u8 GetProtocol();
|
||||
virtual u8 GetProtocol() const;
|
||||
|
||||
virtual bool VerifyChecksum(IP_Address srcIP, IP_Address dstIP);
|
||||
virtual void CalculateChecksum(IP_Address srcIP, IP_Address dstIP);
|
||||
|
|
|
@ -6,20 +6,20 @@
|
|||
|
||||
namespace PacketReader::IP
|
||||
{
|
||||
bool IPOption::IsCopyOnFragment()
|
||||
bool IPOption::IsCopyOnFragment() const
|
||||
{
|
||||
return ((GetCode() & (1 << 0x7)) != 0);
|
||||
}
|
||||
u8 IPOption::GetClass()
|
||||
u8 IPOption::GetClass() const
|
||||
{
|
||||
return (GetCode() >> 5) & 0x3;
|
||||
}
|
||||
u8 IPOption::GetNumber()
|
||||
u8 IPOption::GetNumber() const
|
||||
{
|
||||
return GetCode() & 0x1F;
|
||||
}
|
||||
|
||||
IPopUnk::IPopUnk(u8* data, int offset)
|
||||
IPopUnk::IPopUnk(const u8* data, int offset)
|
||||
{
|
||||
NetLib::ReadByte08(data, &offset, &code);
|
||||
NetLib::ReadByte08(data, &offset, &length);
|
||||
|
@ -27,7 +27,7 @@ namespace PacketReader::IP
|
|||
value.resize(length - 2);
|
||||
NetLib::ReadByteArray(data, &offset, length - 2, &value[0]);
|
||||
}
|
||||
void IPopUnk::WriteBytes(u8* buffer, int* offset)
|
||||
void IPopUnk::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, code);
|
||||
NetLib::WriteByte08(buffer, offset, length);
|
||||
|
@ -38,12 +38,12 @@ namespace PacketReader::IP
|
|||
: value{parValue}
|
||||
{
|
||||
}
|
||||
IPopRouterAlert::IPopRouterAlert(u8* data, int offset)
|
||||
IPopRouterAlert::IPopRouterAlert(const u8* data, int offset)
|
||||
{
|
||||
offset += 2;
|
||||
NetLib::ReadUInt16(data, &offset, &value);
|
||||
}
|
||||
void IPopRouterAlert::WriteBytes(u8* buffer, int* offset)
|
||||
void IPopRouterAlert::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength());
|
||||
|
|
|
@ -12,9 +12,9 @@ namespace PacketReader::IP
|
|||
class BaseOption
|
||||
{
|
||||
public:
|
||||
virtual u8 GetLength() = 0;
|
||||
virtual u8 GetCode() = 0;
|
||||
virtual void WriteBytes(u8* buffer, int* offset) = 0;
|
||||
virtual u8 GetLength() const = 0;
|
||||
virtual u8 GetCode() const = 0;
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const = 0;
|
||||
virtual BaseOption* Clone() const = 0;
|
||||
virtual ~BaseOption() {}
|
||||
};
|
||||
|
@ -22,9 +22,9 @@ namespace PacketReader::IP
|
|||
class IPOption : public BaseOption
|
||||
{
|
||||
public:
|
||||
bool IsCopyOnFragment();
|
||||
u8 GetClass(); //0 = control, 2 = debugging and measurement
|
||||
u8 GetNumber();
|
||||
bool IsCopyOnFragment() const;
|
||||
u8 GetClass() const; //0 = control, 2 = debugging and measurement
|
||||
u8 GetNumber() const;
|
||||
virtual IPOption* Clone() const = 0;
|
||||
};
|
||||
|
||||
|
@ -35,12 +35,12 @@ namespace PacketReader::IP
|
|||
std::vector<u8> value;
|
||||
|
||||
public:
|
||||
IPopUnk(u8* data, int offset);
|
||||
IPopUnk(const u8* data, int offset);
|
||||
|
||||
virtual u8 GetLength() { return length; }
|
||||
virtual u8 GetCode() { return code; }
|
||||
virtual u8 GetLength() const { return length; }
|
||||
virtual u8 GetCode() const { return code; }
|
||||
|
||||
void WriteBytes(u8* buffer, int* offset);
|
||||
void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual IPopUnk* Clone() const
|
||||
{
|
||||
|
@ -51,10 +51,10 @@ namespace PacketReader::IP
|
|||
class IPopNOP : public IPOption
|
||||
{
|
||||
public:
|
||||
virtual u8 GetLength() { return 1; }
|
||||
virtual u8 GetCode() { return 1; }
|
||||
virtual u8 GetLength() const { return 1; }
|
||||
virtual u8 GetCode() const { return 1; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset)
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
buffer[*offset] = GetCode();
|
||||
(*offset)++;
|
||||
|
@ -73,12 +73,12 @@ namespace PacketReader::IP
|
|||
u16 value;
|
||||
|
||||
IPopRouterAlert(u16 parValue);
|
||||
IPopRouterAlert(u8* data, int offset);
|
||||
IPopRouterAlert(const u8* data, int offset);
|
||||
|
||||
virtual u8 GetLength() { return 4; }
|
||||
virtual u8 GetCode() { return 148; }
|
||||
virtual u8 GetLength() const { return 4; }
|
||||
virtual u8 GetCode() const { return 148; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual IPopRouterAlert* Clone() const
|
||||
{
|
||||
|
|
|
@ -9,12 +9,12 @@
|
|||
|
||||
namespace PacketReader::IP
|
||||
{
|
||||
int IP_Packet::GetHeaderLength()
|
||||
int IP_Packet::GetHeaderLength() const
|
||||
{
|
||||
return headerLength;
|
||||
}
|
||||
|
||||
u8 IP_Packet::GetDscpValue()
|
||||
u8 IP_Packet::GetDscpValue() const
|
||||
{
|
||||
return (dscp >> 2) & 0x3F;
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ namespace PacketReader::IP
|
|||
dscp = (dscp & ~(0x3F << 2)) | ((value & 0x3F) << 2);
|
||||
}
|
||||
|
||||
u8 IP_Packet::GetDscpECN()
|
||||
u8 IP_Packet::GetDscpECN() const
|
||||
{
|
||||
return dscp & 0x3;
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ namespace PacketReader::IP
|
|||
dscp = (dscp & ~0x3) | (value & 0x3);
|
||||
}
|
||||
|
||||
bool IP_Packet::GetDoNotFragment()
|
||||
bool IP_Packet::GetDoNotFragment() const
|
||||
{
|
||||
return (fragmentFlags1 & (1 << 6)) != 0;
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ namespace PacketReader::IP
|
|||
fragmentFlags1 = (fragmentFlags1 & ~(0x1 << 6)) | ((value & 0x1) << 6);
|
||||
}
|
||||
|
||||
bool IP_Packet::GetMoreFragments()
|
||||
bool IP_Packet::GetMoreFragments() const
|
||||
{
|
||||
return (fragmentFlags1 & (1 << 5)) != 0;
|
||||
}
|
||||
|
@ -50,11 +50,11 @@ namespace PacketReader::IP
|
|||
fragmentFlags1 = (fragmentFlags1 & ~(0x1 << 5)) | ((value & 0x1) << 5);
|
||||
}
|
||||
|
||||
u16 IP_Packet::GetFragmentOffset()
|
||||
u16 IP_Packet::GetFragmentOffset() const
|
||||
{
|
||||
int x = 0;
|
||||
u8 fF1masked = fragmentFlags1 & 0x1F;
|
||||
u8 data[2] = {fF1masked, fragmentFlags2};
|
||||
const u8 fF1masked = fragmentFlags1 & 0x1F;
|
||||
const u8 data[2] = {fF1masked, fragmentFlags2};
|
||||
u16 offset;
|
||||
NetLib::ReadUInt16(data, &x, &offset);
|
||||
return offset;
|
||||
|
@ -106,8 +106,8 @@ namespace PacketReader::IP
|
|||
bool opReadFin = false;
|
||||
do
|
||||
{
|
||||
u8 opKind = buffer[offset];
|
||||
u8 opLen = buffer[offset + 1];
|
||||
const u8 opKind = buffer[offset];
|
||||
const u8 opLen = buffer[offset + 1];
|
||||
switch (opKind)
|
||||
{
|
||||
case 0:
|
||||
|
@ -154,7 +154,7 @@ namespace PacketReader::IP
|
|||
options.push_back(original.options[i]->Clone());
|
||||
}
|
||||
|
||||
IP_Payload* IP_Packet::GetPayload()
|
||||
IP_Payload* IP_Packet::GetPayload() const
|
||||
{
|
||||
return payload.get();
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ namespace PacketReader::IP
|
|||
|
||||
void IP_Packet::WriteBytes(u8* buffer, int* offset)
|
||||
{
|
||||
int startOff = *offset;
|
||||
const int startOff = *offset;
|
||||
CalculateChecksum(); //ReComputeHeaderLen called in CalculateChecksum
|
||||
payload->CalculateChecksum(sourceIP, destinationIP);
|
||||
|
||||
|
@ -290,7 +290,7 @@ namespace PacketReader::IP
|
|||
delete options[i];
|
||||
}
|
||||
|
||||
u16 IP_Packet::InternetChecksum(u8* buffer, int length)
|
||||
u16 IP_Packet::InternetChecksum(const u8* buffer, int length)
|
||||
{
|
||||
//source http://stackoverflow.com/a/2201090
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ namespace PacketReader::IP
|
|||
std::unique_ptr<IP_Payload> payload;
|
||||
|
||||
public:
|
||||
int GetHeaderLength();
|
||||
int GetHeaderLength() const;
|
||||
|
||||
//DSCP/TOS Flags
|
||||
|
||||
|
@ -85,7 +85,7 @@ namespace PacketReader::IP
|
|||
* Class 5, Expedited Forwarding, 3
|
||||
* bit0: Set to zero
|
||||
*/
|
||||
u8 GetDscpValue();
|
||||
u8 GetDscpValue() const;
|
||||
void SetDscpValue(u8 value);
|
||||
|
||||
/* 2 bits
|
||||
|
@ -97,34 +97,34 @@ namespace PacketReader::IP
|
|||
* 1,2 ECN Supported
|
||||
* 3 = Congestion Encountered
|
||||
*/
|
||||
u8 GetDscpECN();
|
||||
u8 GetDscpECN() const;
|
||||
void SetDscpECN(u8 value);
|
||||
|
||||
//Fragment Flags
|
||||
//bit 0, reserverd
|
||||
|
||||
bool GetDoNotFragment();
|
||||
bool GetDoNotFragment() const;
|
||||
void SetDoNotFragment(bool value);
|
||||
|
||||
bool GetMoreFragments();
|
||||
bool GetMoreFragments() const;
|
||||
void SetMoreFragments(bool value);
|
||||
|
||||
//Untested
|
||||
u16 GetFragmentOffset();
|
||||
u16 GetFragmentOffset() const;
|
||||
|
||||
//Takes ownership of payload
|
||||
IP_Packet(IP_Payload* data);
|
||||
IP_Packet(const u8* buffer, int bufferSize, bool fromICMP = false);
|
||||
IP_Packet(const IP_Packet&);
|
||||
|
||||
IP_Payload* GetPayload();
|
||||
IP_Payload* GetPayload() const;
|
||||
|
||||
virtual int GetLength();
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual IP_Packet* Clone() const;
|
||||
|
||||
bool VerifyChecksum();
|
||||
static u16 InternetChecksum(u8* buffer, int length);
|
||||
static u16 InternetChecksum(const u8* buffer, int length);
|
||||
|
||||
~IP_Packet();
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace PacketReader::IP
|
|||
public: //Nedd GetProtocol
|
||||
virtual int GetLength() = 0;
|
||||
virtual void WriteBytes(u8* buffer, int* offset) = 0;
|
||||
virtual u8 GetProtocol() = 0;
|
||||
virtual u8 GetProtocol() const = 0;
|
||||
virtual bool VerifyChecksum(IP_Address srcIP, IP_Address dstIP) { return false; }
|
||||
virtual void CalculateChecksum(IP_Address srcIP, IP_Address dstIP) {}
|
||||
virtual IP_Payload* Clone() const = 0;
|
||||
|
@ -58,7 +58,7 @@ namespace PacketReader::IP
|
|||
memcpy(&buffer[*offset], data.get(), length);
|
||||
*offset += length;
|
||||
}
|
||||
virtual u8 GetProtocol()
|
||||
virtual u8 GetProtocol() const
|
||||
{
|
||||
return protocol;
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ namespace PacketReader::IP
|
|||
memcpy(ret->data.get(), data, length);
|
||||
return ret;
|
||||
}
|
||||
virtual u8 GetProtocol()
|
||||
virtual u8 GetProtocol() const
|
||||
{
|
||||
return protocol;
|
||||
}
|
||||
|
|
|
@ -10,12 +10,12 @@ namespace PacketReader::IP::TCP
|
|||
: maxSegmentSize{mss}
|
||||
{
|
||||
}
|
||||
TCPopMSS::TCPopMSS(u8* data, int offset)
|
||||
TCPopMSS::TCPopMSS(const u8* data, int offset)
|
||||
{
|
||||
offset += 2;
|
||||
NetLib::ReadUInt16(data, &offset, &maxSegmentSize);
|
||||
}
|
||||
void TCPopMSS::WriteBytes(u8* buffer, int* offset)
|
||||
void TCPopMSS::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength());
|
||||
|
@ -27,12 +27,12 @@ namespace PacketReader::IP::TCP
|
|||
: windowScale{ws}
|
||||
{
|
||||
}
|
||||
TCPopWS::TCPopWS(u8* data, int offset)
|
||||
TCPopWS::TCPopWS(const u8* data, int offset)
|
||||
{
|
||||
offset += 2;
|
||||
NetLib::ReadByte08(data, &offset, &windowScale);
|
||||
}
|
||||
void TCPopWS::WriteBytes(u8* buffer, int* offset)
|
||||
void TCPopWS::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength());
|
||||
|
@ -45,13 +45,13 @@ namespace PacketReader::IP::TCP
|
|||
, echoTimeStamp{echoTS}
|
||||
{
|
||||
}
|
||||
TCPopTS::TCPopTS(u8* data, int offset)
|
||||
TCPopTS::TCPopTS(const u8* data, int offset)
|
||||
{
|
||||
offset += 2;
|
||||
NetLib::ReadUInt32(data, &offset, &senderTimeStamp);
|
||||
NetLib::ReadUInt32(data, &offset, &echoTimeStamp);
|
||||
}
|
||||
void TCPopTS::WriteBytes(u8* buffer, int* offset)
|
||||
void TCPopTS::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength());
|
||||
|
|
|
@ -9,10 +9,10 @@ namespace PacketReader::IP::TCP
|
|||
{
|
||||
class TCPopNOP : public BaseOption
|
||||
{
|
||||
virtual u8 GetLength() { return 1; }
|
||||
virtual u8 GetCode() { return 1; }
|
||||
virtual u8 GetLength() const { return 1; }
|
||||
virtual u8 GetCode() const { return 1; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset)
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
buffer[*offset] = GetCode();
|
||||
(*offset)++;
|
||||
|
@ -30,12 +30,12 @@ namespace PacketReader::IP::TCP
|
|||
u16 maxSegmentSize;
|
||||
|
||||
TCPopMSS(u16 mss);
|
||||
TCPopMSS(u8* data, int offset); //Offset will include Kind and Len
|
||||
TCPopMSS(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 4; }
|
||||
virtual u8 GetCode() { return 2; }
|
||||
virtual u8 GetLength() const { return 4; }
|
||||
virtual u8 GetCode() const { return 2; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual TCPopMSS* Clone() const
|
||||
{
|
||||
|
@ -49,12 +49,12 @@ namespace PacketReader::IP::TCP
|
|||
u8 windowScale;
|
||||
|
||||
TCPopWS(u8 ws);
|
||||
TCPopWS(u8* data, int offset); //Offset will include Kind and Len
|
||||
TCPopWS(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 3; }
|
||||
virtual u8 GetCode() { return 3; }
|
||||
virtual u8 GetLength() const { return 3; }
|
||||
virtual u8 GetCode() const { return 3; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual TCPopWS* Clone() const
|
||||
{
|
||||
|
@ -69,12 +69,12 @@ namespace PacketReader::IP::TCP
|
|||
u32 echoTimeStamp;
|
||||
|
||||
TCPopTS(u32 senderTS, u32 echoTS);
|
||||
TCPopTS(u8* data, int offset); //Offset will include Kind and Len
|
||||
TCPopTS(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 10; }
|
||||
virtual u8 GetCode() { return 8; }
|
||||
virtual u8 GetLength() const { return 10; }
|
||||
virtual u8 GetCode() const { return 8; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual TCPopTS* Clone() const
|
||||
{
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
namespace PacketReader::IP::TCP
|
||||
{
|
||||
//Need flags
|
||||
bool TCP_Packet::GetNS()
|
||||
bool TCP_Packet::GetNS() const
|
||||
{
|
||||
return (dataOffsetAndNS_Flag & 1);
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ namespace PacketReader::IP::TCP
|
|||
dataOffsetAndNS_Flag = (dataOffsetAndNS_Flag & ~0x1) | (value & 0x1);
|
||||
}
|
||||
|
||||
bool TCP_Packet::GetCWR()
|
||||
bool TCP_Packet::GetCWR() const
|
||||
{
|
||||
return (flags & (1 << 7));
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ namespace PacketReader::IP::TCP
|
|||
flags = (flags & ~(0x1 << 7)) | ((value & 0x1) << 7);
|
||||
}
|
||||
|
||||
bool TCP_Packet::GetECE()
|
||||
bool TCP_Packet::GetECE() const
|
||||
{
|
||||
return (flags & (1 << 6));
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ namespace PacketReader::IP::TCP
|
|||
flags = (flags & ~(0x1 << 6)) | ((value & 0x1) << 6);
|
||||
}
|
||||
|
||||
bool TCP_Packet::GetURG()
|
||||
bool TCP_Packet::GetURG() const
|
||||
{
|
||||
return (flags & (1 << 5));
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ namespace PacketReader::IP::TCP
|
|||
flags = (flags & ~(0x1 << 5)) | ((value & 0x1) << 5);
|
||||
}
|
||||
|
||||
bool TCP_Packet::GetACK()
|
||||
bool TCP_Packet::GetACK() const
|
||||
{
|
||||
return (flags & (1 << 4));
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ namespace PacketReader::IP::TCP
|
|||
flags = (flags & ~(0x1 << 4)) | ((value & 0x1) << 4);
|
||||
}
|
||||
|
||||
bool TCP_Packet::GetPSH()
|
||||
bool TCP_Packet::GetPSH() const
|
||||
{
|
||||
return (flags & (1 << 3));
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ namespace PacketReader::IP::TCP
|
|||
flags = (flags & ~(0x1 << 3)) | ((value & 0x1) << 3);
|
||||
}
|
||||
|
||||
bool TCP_Packet::GetRST()
|
||||
bool TCP_Packet::GetRST() const
|
||||
{
|
||||
return (flags & (1 << 2));
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ namespace PacketReader::IP::TCP
|
|||
flags = (flags & ~(0x1 << 2)) | ((value & 0x1) << 2);
|
||||
}
|
||||
|
||||
bool TCP_Packet::GetSYN()
|
||||
bool TCP_Packet::GetSYN() const
|
||||
{
|
||||
return (flags & (1 << 1));
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ namespace PacketReader::IP::TCP
|
|||
flags = (flags & ~(0x1 << 1)) | ((value & 0x1) << 1);
|
||||
}
|
||||
|
||||
bool TCP_Packet::GetFIN()
|
||||
bool TCP_Packet::GetFIN() const
|
||||
{
|
||||
return (flags & 1);
|
||||
}
|
||||
|
@ -125,8 +125,8 @@ namespace PacketReader::IP::TCP
|
|||
bool opReadFin = false;
|
||||
do
|
||||
{
|
||||
u8 opKind = buffer[offset];
|
||||
u8 opLen = buffer[offset + 1];
|
||||
const u8 opKind = buffer[offset];
|
||||
const u8 opLen = buffer[offset + 1];
|
||||
switch (opKind)
|
||||
{
|
||||
case 0:
|
||||
|
@ -180,7 +180,7 @@ namespace PacketReader::IP::TCP
|
|||
options.push_back(original.options[i]->Clone());
|
||||
}
|
||||
|
||||
Payload* TCP_Packet::GetPayload()
|
||||
Payload* TCP_Packet::GetPayload() const
|
||||
{
|
||||
return payload.get();
|
||||
}
|
||||
|
@ -193,7 +193,7 @@ namespace PacketReader::IP::TCP
|
|||
|
||||
void TCP_Packet::WriteBytes(u8* buffer, int* offset)
|
||||
{
|
||||
int startOff = *offset;
|
||||
const int startOff = *offset;
|
||||
NetLib::WriteUInt16(buffer, offset, sourcePort);
|
||||
NetLib::WriteUInt16(buffer, offset, destinationPort);
|
||||
NetLib::WriteUInt32(buffer, offset, sequenceNumber);
|
||||
|
@ -222,7 +222,7 @@ namespace PacketReader::IP::TCP
|
|||
return new TCP_Packet(*this);
|
||||
}
|
||||
|
||||
u8 TCP_Packet::GetProtocol()
|
||||
u8 TCP_Packet::GetProtocol() const
|
||||
{
|
||||
return (u8)protocol;
|
||||
}
|
||||
|
@ -237,7 +237,7 @@ namespace PacketReader::IP::TCP
|
|||
headerLength = Common::AlignUpPow2(opOffset, 4);
|
||||
|
||||
//Also write into dataOffsetAndNS_Flag
|
||||
u8 ns = dataOffsetAndNS_Flag & 1;
|
||||
const u8 ns = dataOffsetAndNS_Flag & 1;
|
||||
dataOffsetAndNS_Flag = (headerLength >> 2) << 4;
|
||||
dataOffsetAndNS_Flag |= ns;
|
||||
}
|
||||
|
@ -294,7 +294,7 @@ namespace PacketReader::IP::TCP
|
|||
if (counter != pHeaderLen)
|
||||
NetLib::WriteByte08(headerSegment, &counter, 0);
|
||||
|
||||
u16 csumCal = IP_Packet::InternetChecksum(headerSegment, pHeaderLen);
|
||||
const u16 csumCal = IP_Packet::InternetChecksum(headerSegment, pHeaderLen);
|
||||
delete[] headerSegment;
|
||||
|
||||
return (csumCal == 0);
|
||||
|
|
|
@ -38,31 +38,31 @@ namespace PacketReader::IP::TCP
|
|||
|
||||
public:
|
||||
//Flags
|
||||
bool GetNS();
|
||||
bool GetNS() const;
|
||||
void SetNS(bool value);
|
||||
|
||||
bool GetCWR();
|
||||
bool GetCWR() const;
|
||||
void SetCWR(bool value);
|
||||
|
||||
bool GetECE();
|
||||
bool GetECE() const;
|
||||
void SetECE(bool value);
|
||||
|
||||
bool GetURG();
|
||||
bool GetURG() const;
|
||||
void SetURG(bool value);
|
||||
|
||||
bool GetACK();
|
||||
bool GetACK() const;
|
||||
void SetACK(bool value);
|
||||
|
||||
bool GetPSH();
|
||||
bool GetPSH() const;
|
||||
void SetPSH(bool value);
|
||||
|
||||
bool GetRST();
|
||||
bool GetRST() const;
|
||||
void SetRST(bool value);
|
||||
|
||||
bool GetSYN();
|
||||
bool GetSYN() const;
|
||||
void SetSYN(bool value);
|
||||
|
||||
bool GetFIN();
|
||||
bool GetFIN() const;
|
||||
void SetFIN(bool value);
|
||||
|
||||
//Takes ownership of payload
|
||||
|
@ -70,13 +70,13 @@ namespace PacketReader::IP::TCP
|
|||
TCP_Packet(const u8* buffer, int bufferSize);
|
||||
TCP_Packet(const TCP_Packet&);
|
||||
|
||||
Payload* GetPayload();
|
||||
Payload* GetPayload() const;
|
||||
|
||||
virtual int GetLength();
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual TCP_Packet* Clone() const;
|
||||
|
||||
virtual u8 GetProtocol();
|
||||
virtual u8 GetProtocol() const;
|
||||
|
||||
virtual bool VerifyChecksum(IP_Address srcIP, IP_Address dstIP);
|
||||
virtual void CalculateChecksum(IP_Address srcIP, IP_Address dstIP);
|
||||
|
|
|
@ -12,12 +12,12 @@ namespace PacketReader::IP::UDP::DHCP
|
|||
: subnetMask{mask}
|
||||
{
|
||||
}
|
||||
DHCPopSubnet::DHCPopSubnet(u8* data, int offset)
|
||||
DHCPopSubnet::DHCPopSubnet(const u8* data, int offset)
|
||||
{
|
||||
offset += 2;
|
||||
NetLib::ReadIPAddress(data, &offset, &subnetMask);
|
||||
}
|
||||
void DHCPopSubnet::WriteBytes(u8* buffer, int* offset)
|
||||
void DHCPopSubnet::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength() - 2);
|
||||
|
@ -28,7 +28,7 @@ namespace PacketReader::IP::UDP::DHCP
|
|||
: routers{routerIPs}
|
||||
{
|
||||
}
|
||||
DHCPopRouter::DHCPopRouter(u8* data, int offset)
|
||||
DHCPopRouter::DHCPopRouter(const u8* data, int offset)
|
||||
{
|
||||
offset += 1;
|
||||
u8 len;
|
||||
|
@ -37,7 +37,7 @@ namespace PacketReader::IP::UDP::DHCP
|
|||
routers = {(IP_Address*)&data[offset], (IP_Address*)&data[offset + len]};
|
||||
//offset += len;
|
||||
}
|
||||
void DHCPopRouter::WriteBytes(u8* buffer, int* offset)
|
||||
void DHCPopRouter::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength() - 2);
|
||||
|
@ -49,7 +49,7 @@ namespace PacketReader::IP::UDP::DHCP
|
|||
: dnsServers{dnsIPs}
|
||||
{
|
||||
}
|
||||
DHCPopDNS::DHCPopDNS(u8* data, int offset)
|
||||
DHCPopDNS::DHCPopDNS(const u8* data, int offset)
|
||||
{
|
||||
offset += 1;
|
||||
u8 len;
|
||||
|
@ -58,7 +58,7 @@ namespace PacketReader::IP::UDP::DHCP
|
|||
dnsServers = {(IP_Address*)&data[offset], (IP_Address*)&data[offset + len]};
|
||||
//offset += len;
|
||||
}
|
||||
void DHCPopDNS::WriteBytes(u8* buffer, int* offset)
|
||||
void DHCPopDNS::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength() - 2);
|
||||
|
@ -76,7 +76,7 @@ namespace PacketReader::IP::UDP::DHCP
|
|||
else
|
||||
hostName = name;
|
||||
}
|
||||
DHCPopHostName::DHCPopHostName(u8* data, int offset)
|
||||
DHCPopHostName::DHCPopHostName(const u8* data, int offset)
|
||||
{
|
||||
offset += 1;
|
||||
u8 len;
|
||||
|
@ -84,7 +84,7 @@ namespace PacketReader::IP::UDP::DHCP
|
|||
hostName = std::string((char*)&data[offset], len);
|
||||
//offset += len;
|
||||
}
|
||||
void DHCPopHostName::WriteBytes(u8* buffer, int* offset)
|
||||
void DHCPopHostName::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength() - 2);
|
||||
|
@ -92,7 +92,7 @@ namespace PacketReader::IP::UDP::DHCP
|
|||
NetLib::WriteByteArray(buffer, offset, hostName.size(), (u8*)hostName.c_str());
|
||||
}
|
||||
|
||||
DHCPopDnsName::DHCPopDnsName(std::string name)
|
||||
DHCPopDnsName::DHCPopDnsName(const std::string& name)
|
||||
{
|
||||
if (name.size() > 255)
|
||||
{
|
||||
|
@ -102,7 +102,7 @@ namespace PacketReader::IP::UDP::DHCP
|
|||
else
|
||||
domainName = name;
|
||||
}
|
||||
DHCPopDnsName::DHCPopDnsName(u8* data, int offset)
|
||||
DHCPopDnsName::DHCPopDnsName(const u8* data, int offset)
|
||||
{
|
||||
offset += 1;
|
||||
u8 len;
|
||||
|
@ -110,7 +110,7 @@ namespace PacketReader::IP::UDP::DHCP
|
|||
domainName = std::string((char*)&data[offset], len);
|
||||
//offset += len;
|
||||
}
|
||||
void DHCPopDnsName::WriteBytes(u8* buffer, int* offset)
|
||||
void DHCPopDnsName::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength() - 2);
|
||||
|
@ -122,12 +122,12 @@ namespace PacketReader::IP::UDP::DHCP
|
|||
: broadcastIP{data}
|
||||
{
|
||||
}
|
||||
DHCPopBCIP::DHCPopBCIP(u8* data, int offset)
|
||||
DHCPopBCIP::DHCPopBCIP(const u8* data, int offset)
|
||||
{
|
||||
offset += 2;
|
||||
NetLib::ReadIPAddress(data, &offset, &broadcastIP);
|
||||
}
|
||||
void DHCPopBCIP::WriteBytes(u8* buffer, int* offset)
|
||||
void DHCPopBCIP::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength() - 2);
|
||||
|
@ -135,7 +135,7 @@ namespace PacketReader::IP::UDP::DHCP
|
|||
NetLib::WriteIPAddress(buffer, offset, broadcastIP);
|
||||
}
|
||||
|
||||
bool DHCPopNBIOSType::GetHNode()
|
||||
bool DHCPopNBIOSType::GetHNode() const
|
||||
{
|
||||
return ((type & (1 << 3)) != 0);
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ namespace PacketReader::IP::UDP::DHCP
|
|||
type &= ~(1 << 3);
|
||||
}
|
||||
}
|
||||
bool DHCPopNBIOSType::GetMNode()
|
||||
bool DHCPopNBIOSType::GetMNode() const
|
||||
{
|
||||
return ((type & (1 << 2)) != 0);
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ namespace PacketReader::IP::UDP::DHCP
|
|||
type &= ~(1 << 2);
|
||||
}
|
||||
}
|
||||
bool DHCPopNBIOSType::GetPNode()
|
||||
bool DHCPopNBIOSType::GetPNode() const
|
||||
{
|
||||
return ((type & (1 << 1)) != 0);
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ namespace PacketReader::IP::UDP::DHCP
|
|||
type &= ~(1 << 1);
|
||||
}
|
||||
}
|
||||
bool DHCPopNBIOSType::GetBNode()
|
||||
bool DHCPopNBIOSType::GetBNode() const
|
||||
{
|
||||
return ((type & 1) != 0);
|
||||
}
|
||||
|
@ -196,12 +196,12 @@ namespace PacketReader::IP::UDP::DHCP
|
|||
}
|
||||
}
|
||||
//
|
||||
DHCPopNBIOSType::DHCPopNBIOSType(u8* data, int offset)
|
||||
DHCPopNBIOSType::DHCPopNBIOSType(const u8* data, int offset)
|
||||
{
|
||||
offset += 2;
|
||||
NetLib::ReadByte08(data, &offset, &type);
|
||||
}
|
||||
void DHCPopNBIOSType::WriteBytes(u8* buffer, int* offset)
|
||||
void DHCPopNBIOSType::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength() - 2);
|
||||
|
@ -213,12 +213,12 @@ namespace PacketReader::IP::UDP::DHCP
|
|||
: requestedIP{data}
|
||||
{
|
||||
}
|
||||
DHCPopREQIP::DHCPopREQIP(u8* data, int offset)
|
||||
DHCPopREQIP::DHCPopREQIP(const u8* data, int offset)
|
||||
{
|
||||
offset += 2;
|
||||
NetLib::ReadIPAddress(data, &offset, &requestedIP);
|
||||
}
|
||||
void DHCPopREQIP::WriteBytes(u8* buffer, int* offset)
|
||||
void DHCPopREQIP::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength() - 2);
|
||||
|
@ -230,12 +230,12 @@ namespace PacketReader::IP::UDP::DHCP
|
|||
: ipLeaseTime{LeaseTime}
|
||||
{
|
||||
}
|
||||
DHCPopIPLT::DHCPopIPLT(u8* data, int offset)
|
||||
DHCPopIPLT::DHCPopIPLT(const u8* data, int offset)
|
||||
{
|
||||
offset += 2;
|
||||
NetLib::ReadUInt32(data, &offset, &ipLeaseTime);
|
||||
}
|
||||
void DHCPopIPLT::WriteBytes(u8* buffer, int* offset)
|
||||
void DHCPopIPLT::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength() - 2);
|
||||
|
@ -247,12 +247,12 @@ namespace PacketReader::IP::UDP::DHCP
|
|||
: message{msg}
|
||||
{
|
||||
}
|
||||
DHCPopMSG::DHCPopMSG(u8* data, int offset)
|
||||
DHCPopMSG::DHCPopMSG(const u8* data, int offset)
|
||||
{
|
||||
offset += 2;
|
||||
NetLib::ReadByte08(data, &offset, &message);
|
||||
}
|
||||
void DHCPopMSG::WriteBytes(u8* buffer, int* offset)
|
||||
void DHCPopMSG::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength() - 2);
|
||||
|
@ -264,12 +264,12 @@ namespace PacketReader::IP::UDP::DHCP
|
|||
: serverIP{data}
|
||||
{
|
||||
}
|
||||
DHCPopSERVIP::DHCPopSERVIP(u8* data, int offset)
|
||||
DHCPopSERVIP::DHCPopSERVIP(const u8* data, int offset)
|
||||
{
|
||||
offset += 2;
|
||||
NetLib::ReadIPAddress(data, &offset, &serverIP);
|
||||
}
|
||||
void DHCPopSERVIP::WriteBytes(u8* buffer, int* offset)
|
||||
void DHCPopSERVIP::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength() - 2);
|
||||
|
@ -281,7 +281,7 @@ namespace PacketReader::IP::UDP::DHCP
|
|||
: requests{requestList}
|
||||
{
|
||||
}
|
||||
DHCPopREQLIST::DHCPopREQLIST(u8* data, int offset)
|
||||
DHCPopREQLIST::DHCPopREQLIST(const u8* data, int offset)
|
||||
{
|
||||
offset += 1;
|
||||
u8 len;
|
||||
|
@ -290,7 +290,7 @@ namespace PacketReader::IP::UDP::DHCP
|
|||
requests = {&data[offset], &data[offset + len]};
|
||||
//offset += len;
|
||||
}
|
||||
void DHCPopREQLIST::WriteBytes(u8* buffer, int* offset)
|
||||
void DHCPopREQLIST::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength() - 2);
|
||||
|
@ -308,7 +308,7 @@ namespace PacketReader::IP::UDP::DHCP
|
|||
else
|
||||
message = msg;
|
||||
}
|
||||
DHCPopMSGStr::DHCPopMSGStr(u8* data, int offset)
|
||||
DHCPopMSGStr::DHCPopMSGStr(const u8* data, int offset)
|
||||
{
|
||||
offset += 1;
|
||||
u8 len;
|
||||
|
@ -316,7 +316,7 @@ namespace PacketReader::IP::UDP::DHCP
|
|||
message = std::string((char*)&data[offset], len);
|
||||
//offset += len;
|
||||
}
|
||||
void DHCPopMSGStr::WriteBytes(u8* buffer, int* offset)
|
||||
void DHCPopMSGStr::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength() - 2);
|
||||
|
@ -328,12 +328,12 @@ namespace PacketReader::IP::UDP::DHCP
|
|||
: maxMessageSize{mms}
|
||||
{
|
||||
}
|
||||
DHCPopMMSGS::DHCPopMMSGS(u8* data, int offset)
|
||||
DHCPopMMSGS::DHCPopMMSGS(const u8* data, int offset)
|
||||
{
|
||||
offset += 2;
|
||||
NetLib::ReadUInt16(data, &offset, &maxMessageSize);
|
||||
}
|
||||
void DHCPopMMSGS::WriteBytes(u8* buffer, int* offset)
|
||||
void DHCPopMMSGS::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength() - 2);
|
||||
|
@ -345,12 +345,12 @@ namespace PacketReader::IP::UDP::DHCP
|
|||
: ipRenewalTimeT1{t1}
|
||||
{
|
||||
}
|
||||
DHCPopT1::DHCPopT1(u8* data, int offset)
|
||||
DHCPopT1::DHCPopT1(const u8* data, int offset)
|
||||
{
|
||||
offset += 2;
|
||||
NetLib::ReadUInt32(data, &offset, &ipRenewalTimeT1);
|
||||
}
|
||||
void DHCPopT1::WriteBytes(u8* buffer, int* offset)
|
||||
void DHCPopT1::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength() - 2);
|
||||
|
@ -362,12 +362,12 @@ namespace PacketReader::IP::UDP::DHCP
|
|||
: ipRebindingTimeT2{t2}
|
||||
{
|
||||
}
|
||||
DHCPopT2::DHCPopT2(u8* data, int offset)
|
||||
DHCPopT2::DHCPopT2(const u8* data, int offset)
|
||||
{
|
||||
offset += 2;
|
||||
NetLib::ReadUInt32(data, &offset, &ipRebindingTimeT2);
|
||||
}
|
||||
void DHCPopT2::WriteBytes(u8* buffer, int* offset)
|
||||
void DHCPopT2::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength() - 2);
|
||||
|
@ -385,7 +385,7 @@ namespace PacketReader::IP::UDP::DHCP
|
|||
else
|
||||
classID = id;
|
||||
}
|
||||
DHCPopClassID::DHCPopClassID(u8* data, int offset)
|
||||
DHCPopClassID::DHCPopClassID(const u8* data, int offset)
|
||||
{
|
||||
offset += 1;
|
||||
u8 len;
|
||||
|
@ -393,7 +393,7 @@ namespace PacketReader::IP::UDP::DHCP
|
|||
classID = std::string((char*)&data[offset], len);
|
||||
//offset += len;
|
||||
}
|
||||
void DHCPopClassID::WriteBytes(u8* buffer, int* offset)
|
||||
void DHCPopClassID::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength() - 2);
|
||||
|
@ -405,7 +405,7 @@ namespace PacketReader::IP::UDP::DHCP
|
|||
: clientID{value}
|
||||
{
|
||||
}
|
||||
DHCPopClientID::DHCPopClientID(u8* data, int offset)
|
||||
DHCPopClientID::DHCPopClientID(const u8* data, int offset)
|
||||
{
|
||||
offset += 1;
|
||||
u8 len;
|
||||
|
@ -414,7 +414,7 @@ namespace PacketReader::IP::UDP::DHCP
|
|||
clientID = {&data[offset], &data[offset + len]};
|
||||
//offset += len;
|
||||
}
|
||||
void DHCPopClientID::WriteBytes(u8* buffer, int* offset)
|
||||
void DHCPopClientID::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength() - 2);
|
||||
|
|
|
@ -14,10 +14,10 @@ namespace PacketReader::IP::UDP::DHCP
|
|||
//GetLength(), howver, includes the option header
|
||||
class DHCPopNOP : public BaseOption
|
||||
{
|
||||
virtual u8 GetLength() { return 1; }
|
||||
virtual u8 GetCode() { return 0; }
|
||||
virtual u8 GetLength() const { return 1; }
|
||||
virtual u8 GetCode() const { return 0; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset)
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
buffer[*offset] = GetCode();
|
||||
(*offset)++;
|
||||
|
@ -35,12 +35,12 @@ namespace PacketReader::IP::UDP::DHCP
|
|||
IP_Address subnetMask{};
|
||||
|
||||
DHCPopSubnet(IP_Address mask);
|
||||
DHCPopSubnet(u8* data, int offset); //Offset will include Kind and Len
|
||||
DHCPopSubnet(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 6; }
|
||||
virtual u8 GetCode() { return 1; }
|
||||
virtual u8 GetLength() const { return 6; }
|
||||
virtual u8 GetCode() const { return 1; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual DHCPopSubnet* Clone() const
|
||||
{
|
||||
|
@ -53,12 +53,12 @@ namespace PacketReader::IP::UDP::DHCP
|
|||
public:
|
||||
std::vector<IP_Address> routers;
|
||||
DHCPopRouter(const std::vector<IP_Address>& routerIPs);
|
||||
DHCPopRouter(u8* data, int offset); //Offset will include Kind and Len
|
||||
DHCPopRouter(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 2 + 4 * routers.size(); }
|
||||
virtual u8 GetCode() { return 3; }
|
||||
virtual u8 GetLength() const { return 2 + 4 * routers.size(); }
|
||||
virtual u8 GetCode() const { return 3; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual DHCPopRouter* Clone() const
|
||||
{
|
||||
|
@ -71,12 +71,12 @@ namespace PacketReader::IP::UDP::DHCP
|
|||
public:
|
||||
std::vector<IP_Address> dnsServers;
|
||||
DHCPopDNS(const std::vector<IP_Address>& dnsIPs);
|
||||
DHCPopDNS(u8* data, int offset); //Offset will include Kind and Len
|
||||
DHCPopDNS(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 2 + 4 * dnsServers.size(); }
|
||||
virtual u8 GetCode() { return 6; }
|
||||
virtual u8 GetLength() const { return 2 + 4 * dnsServers.size(); }
|
||||
virtual u8 GetCode() const { return 6; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual DHCPopDNS* Clone() const
|
||||
{
|
||||
|
@ -91,12 +91,12 @@ namespace PacketReader::IP::UDP::DHCP
|
|||
std::string hostName;
|
||||
|
||||
DHCPopHostName(const std::string& name);
|
||||
DHCPopHostName(u8* data, int offset); //Offset will include Kind and Len
|
||||
DHCPopHostName(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 2 + hostName.size(); }
|
||||
virtual u8 GetCode() { return 12; }
|
||||
virtual u8 GetLength() const { return 2 + hostName.size(); }
|
||||
virtual u8 GetCode() const { return 12; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual DHCPopHostName* Clone() const
|
||||
{
|
||||
|
@ -110,13 +110,13 @@ namespace PacketReader::IP::UDP::DHCP
|
|||
//ASCII encoding
|
||||
std::string domainName;
|
||||
|
||||
DHCPopDnsName(std::string name);
|
||||
DHCPopDnsName(u8* data, int offset); //Offset will include Kind and Len
|
||||
DHCPopDnsName(const std::string& name);
|
||||
DHCPopDnsName(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 2 + domainName.size(); }
|
||||
virtual u8 GetCode() { return 15; }
|
||||
virtual u8 GetLength() const { return 2 + domainName.size(); }
|
||||
virtual u8 GetCode() const { return 15; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual DHCPopDnsName* Clone() const
|
||||
{
|
||||
|
@ -130,12 +130,12 @@ namespace PacketReader::IP::UDP::DHCP
|
|||
IP_Address broadcastIP{};
|
||||
|
||||
DHCPopBCIP(IP_Address data);
|
||||
DHCPopBCIP(u8* data, int offset); //Offset will include Kind and Len
|
||||
DHCPopBCIP(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 6; }
|
||||
virtual u8 GetCode() { return 28; }
|
||||
virtual u8 GetLength() const { return 6; }
|
||||
virtual u8 GetCode() const { return 28; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual DHCPopBCIP* Clone() const
|
||||
{
|
||||
|
@ -151,24 +151,24 @@ namespace PacketReader::IP::UDP::DHCP
|
|||
|
||||
public:
|
||||
//Getters/Setters
|
||||
bool GetHNode();
|
||||
bool GetHNode() const;
|
||||
void SetHNode(bool value);
|
||||
|
||||
bool GetMNode();
|
||||
bool GetMNode() const;
|
||||
void SetMNode(bool value);
|
||||
|
||||
bool GetPNode();
|
||||
bool GetPNode() const;
|
||||
void SetPNode(bool value);
|
||||
|
||||
bool GetBNode();
|
||||
bool GetBNode() const;
|
||||
void SetBNode(bool value);
|
||||
|
||||
DHCPopNBIOSType(u8* data, int offset); //Offset will include Kind and Len
|
||||
DHCPopNBIOSType(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 3; }
|
||||
virtual u8 GetCode() { return 46; }
|
||||
virtual u8 GetLength() const { return 3; }
|
||||
virtual u8 GetCode() const { return 46; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual DHCPopNBIOSType* Clone() const
|
||||
{
|
||||
|
@ -182,12 +182,12 @@ namespace PacketReader::IP::UDP::DHCP
|
|||
IP_Address requestedIP{};
|
||||
|
||||
DHCPopREQIP(IP_Address data);
|
||||
DHCPopREQIP(u8* data, int offset); //Offset will include Kind and Len
|
||||
DHCPopREQIP(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 6; }
|
||||
virtual u8 GetCode() { return 50; }
|
||||
virtual u8 GetLength() const { return 6; }
|
||||
virtual u8 GetCode() const { return 50; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual DHCPopREQIP* Clone() const
|
||||
{
|
||||
|
@ -201,12 +201,12 @@ namespace PacketReader::IP::UDP::DHCP
|
|||
u32 ipLeaseTime;
|
||||
|
||||
DHCPopIPLT(u32 LeaseTime);
|
||||
DHCPopIPLT(u8* data, int offset); //Offset will include Kind and Len
|
||||
DHCPopIPLT(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 6; }
|
||||
virtual u8 GetCode() { return 51; }
|
||||
virtual u8 GetLength() const { return 6; }
|
||||
virtual u8 GetCode() const { return 51; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual DHCPopIPLT* Clone() const
|
||||
{
|
||||
|
@ -219,12 +219,12 @@ namespace PacketReader::IP::UDP::DHCP
|
|||
public:
|
||||
u8 message;
|
||||
DHCPopMSG(u8 msg);
|
||||
DHCPopMSG(u8* data, int offset); //Offset will include Kind and Len
|
||||
DHCPopMSG(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 3; }
|
||||
virtual u8 GetCode() { return 53; }
|
||||
virtual u8 GetLength() const { return 3; }
|
||||
virtual u8 GetCode() const { return 53; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual DHCPopMSG* Clone() const
|
||||
{
|
||||
|
@ -238,12 +238,12 @@ namespace PacketReader::IP::UDP::DHCP
|
|||
IP_Address serverIP{};
|
||||
|
||||
DHCPopSERVIP(IP_Address data);
|
||||
DHCPopSERVIP(u8* data, int offset); //Offset will include Kind and Len
|
||||
DHCPopSERVIP(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 6; }
|
||||
virtual u8 GetCode() { return 54; }
|
||||
virtual u8 GetLength() const { return 6; }
|
||||
virtual u8 GetCode() const { return 54; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual DHCPopSERVIP* Clone() const
|
||||
{
|
||||
|
@ -257,12 +257,12 @@ namespace PacketReader::IP::UDP::DHCP
|
|||
std::vector<u8> requests;
|
||||
|
||||
DHCPopREQLIST(const std::vector<u8>& requestList);
|
||||
DHCPopREQLIST(u8* data, int offset); //Offset will include Kind and Len
|
||||
DHCPopREQLIST(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 2 + requests.size(); }
|
||||
virtual u8 GetCode() { return 55; }
|
||||
virtual u8 GetLength() const { return 2 + requests.size(); }
|
||||
virtual u8 GetCode() const { return 55; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual DHCPopREQLIST* Clone() const
|
||||
{
|
||||
|
@ -277,12 +277,12 @@ namespace PacketReader::IP::UDP::DHCP
|
|||
std::string message;
|
||||
|
||||
DHCPopMSGStr(const std::string& msg);
|
||||
DHCPopMSGStr(u8* data, int offset); //Offset will include Kind and Len
|
||||
DHCPopMSGStr(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 2 + message.size(); }
|
||||
virtual u8 GetCode() { return 56; }
|
||||
virtual u8 GetLength() const { return 2 + message.size(); }
|
||||
virtual u8 GetCode() const { return 56; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual DHCPopMSGStr* Clone() const
|
||||
{
|
||||
|
@ -296,12 +296,12 @@ namespace PacketReader::IP::UDP::DHCP
|
|||
u16 maxMessageSize;
|
||||
|
||||
DHCPopMMSGS(u16 mms);
|
||||
DHCPopMMSGS(u8* data, int offset); //Offset will include Kind and Len
|
||||
DHCPopMMSGS(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 4; }
|
||||
virtual u8 GetCode() { return 57; }
|
||||
virtual u8 GetLength() const { return 4; }
|
||||
virtual u8 GetCode() const { return 57; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual DHCPopMMSGS* Clone() const
|
||||
{
|
||||
|
@ -315,12 +315,12 @@ namespace PacketReader::IP::UDP::DHCP
|
|||
u32 ipRenewalTimeT1;
|
||||
|
||||
DHCPopT1(u32 t1);
|
||||
DHCPopT1(u8* data, int offset); //Offset will include Kind and Len
|
||||
DHCPopT1(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 6; }
|
||||
virtual u8 GetCode() { return 58; }
|
||||
virtual u8 GetLength() const { return 6; }
|
||||
virtual u8 GetCode() const { return 58; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual DHCPopT1* Clone() const
|
||||
{
|
||||
|
@ -334,12 +334,12 @@ namespace PacketReader::IP::UDP::DHCP
|
|||
u32 ipRebindingTimeT2;
|
||||
|
||||
DHCPopT2(u32 t2);
|
||||
DHCPopT2(u8* data, int offset); //Offset will include Kind and Len
|
||||
DHCPopT2(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 6; }
|
||||
virtual u8 GetCode() { return 59; }
|
||||
virtual u8 GetLength() const { return 6; }
|
||||
virtual u8 GetCode() const { return 59; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual DHCPopT2* Clone() const
|
||||
{
|
||||
|
@ -354,12 +354,12 @@ namespace PacketReader::IP::UDP::DHCP
|
|||
std::string classID;
|
||||
|
||||
DHCPopClassID(const std::string& id);
|
||||
DHCPopClassID(u8* data, int offset); //Offset will include Kind and Len
|
||||
DHCPopClassID(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 2 + classID.size(); }
|
||||
virtual u8 GetCode() { return 60; }
|
||||
virtual u8 GetLength() const { return 2 + classID.size(); }
|
||||
virtual u8 GetCode() const { return 60; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual DHCPopClassID* Clone() const
|
||||
{
|
||||
|
@ -373,12 +373,12 @@ namespace PacketReader::IP::UDP::DHCP
|
|||
std::vector<u8> clientID;
|
||||
|
||||
DHCPopClientID(const std::vector<u8>& value);
|
||||
DHCPopClientID(u8* data, int offset); //Offset will include Kind and Len
|
||||
DHCPopClientID(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 2 + clientID.size(); }
|
||||
virtual u8 GetCode() { return 61; }
|
||||
virtual u8 GetLength() const { return 2 + clientID.size(); }
|
||||
virtual u8 GetCode() const { return 61; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual DHCPopClientID* Clone() const
|
||||
{
|
||||
|
@ -391,10 +391,10 @@ namespace PacketReader::IP::UDP::DHCP
|
|||
public:
|
||||
DHCPopEND() {}
|
||||
|
||||
virtual u8 GetLength() { return 1; }
|
||||
virtual u8 GetCode() { return 255; }
|
||||
virtual u8 GetLength() const { return 1; }
|
||||
virtual u8 GetCode() const { return 255; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset)
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
buffer[*offset] = GetCode();
|
||||
(*offset)++;
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
namespace PacketReader::IP::UDP::DHCP
|
||||
{
|
||||
DHCP_Packet::DHCP_Packet(u8* buffer, int bufferSize)
|
||||
DHCP_Packet::DHCP_Packet(const u8* buffer, int bufferSize)
|
||||
{
|
||||
int offset = 0;
|
||||
//Bits 0-31 //Bytes 0-3
|
||||
|
@ -49,7 +49,7 @@ namespace PacketReader::IP::UDP::DHCP
|
|||
|
||||
do
|
||||
{
|
||||
u8 opKind = buffer[offset];
|
||||
const u8 opKind = buffer[offset];
|
||||
if (opKind == 255)
|
||||
{
|
||||
options.push_back(new DHCPopEND());
|
||||
|
@ -64,7 +64,7 @@ namespace PacketReader::IP::UDP::DHCP
|
|||
opReadFin = true;
|
||||
continue;
|
||||
}
|
||||
u8 opLen = buffer[offset + 1];
|
||||
const u8 opLen = buffer[offset + 1];
|
||||
switch (opKind)
|
||||
{
|
||||
case 0:
|
||||
|
@ -172,7 +172,7 @@ namespace PacketReader::IP::UDP::DHCP
|
|||
|
||||
void DHCP_Packet::WriteBytes(u8* buffer, int* offset)
|
||||
{
|
||||
int start = *offset;
|
||||
const int start = *offset;
|
||||
NetLib::WriteByte08(buffer, offset, op);
|
||||
NetLib::WriteByte08(buffer, offset, hardwareType);
|
||||
NetLib::WriteByte08(buffer, offset, hardwareAddressLength);
|
||||
|
@ -210,7 +210,7 @@ namespace PacketReader::IP::UDP::DHCP
|
|||
if (len == maxLength)
|
||||
{
|
||||
i -= 1;
|
||||
int pastLength = options[i]->GetLength();
|
||||
const int pastLength = options[i]->GetLength();
|
||||
len -= pastLength;
|
||||
*offset -= pastLength;
|
||||
}
|
||||
|
@ -221,8 +221,8 @@ namespace PacketReader::IP::UDP::DHCP
|
|||
}
|
||||
}
|
||||
|
||||
int end = start + GetLength();
|
||||
int delta = end - *offset;
|
||||
const int end = start + GetLength();
|
||||
const int delta = end - *offset;
|
||||
|
||||
memset(&buffer[*offset], 0, delta);
|
||||
*offset = start + GetLength();
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace PacketReader::IP::UDP::DHCP
|
|||
int maxLength = 576;
|
||||
|
||||
DHCP_Packet() {}
|
||||
DHCP_Packet(u8* buffer, int bufferSize);
|
||||
DHCP_Packet(const u8* buffer, int bufferSize);
|
||||
DHCP_Packet(const DHCP_Packet&);
|
||||
|
||||
virtual int GetLength();
|
||||
|
|
|
@ -12,20 +12,20 @@ namespace PacketReader::IP::UDP::DNS
|
|||
, entryClass{qClass}
|
||||
{
|
||||
}
|
||||
DNS_QuestionEntry::DNS_QuestionEntry(u8* buffer, int* offset)
|
||||
DNS_QuestionEntry::DNS_QuestionEntry(const u8* buffer, int* offset)
|
||||
{
|
||||
ReadDNS_String(buffer, offset, &name);
|
||||
NetLib::ReadUInt16(buffer, offset, &entryType);
|
||||
NetLib::ReadUInt16(buffer, offset, &entryClass);
|
||||
}
|
||||
|
||||
void DNS_QuestionEntry::ReadDNS_String(u8* buffer, int* offset, std::string* value)
|
||||
void DNS_QuestionEntry::ReadDNS_String(const u8* buffer, int* offset, std::string* value) const
|
||||
{
|
||||
*value = "";
|
||||
|
||||
while (buffer[*offset] != 0)
|
||||
{
|
||||
int len = buffer[*offset];
|
||||
const int len = buffer[*offset];
|
||||
|
||||
if (len >= 192)
|
||||
{
|
||||
|
@ -57,7 +57,7 @@ namespace PacketReader::IP::UDP::DNS
|
|||
//null char
|
||||
*offset += 1;
|
||||
}
|
||||
void DNS_QuestionEntry::WriteDNS_String(u8* buffer, int* offset, const std::string& value)
|
||||
void DNS_QuestionEntry::WriteDNS_String(u8* buffer, int* offset, const std::string& value) const
|
||||
{
|
||||
int segmentLength = 0;
|
||||
int segmentStart = 0;
|
||||
|
@ -86,12 +86,12 @@ namespace PacketReader::IP::UDP::DNS
|
|||
NetLib::WriteByte08(buffer, offset, 0);
|
||||
}
|
||||
|
||||
int DNS_QuestionEntry::GetLength()
|
||||
int DNS_QuestionEntry::GetLength() const
|
||||
{
|
||||
return 1 + name.size() + 1 + 4;
|
||||
}
|
||||
|
||||
void DNS_QuestionEntry::WriteBytes(u8* buffer, int* offset)
|
||||
void DNS_QuestionEntry::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
WriteDNS_String(buffer, offset, name);
|
||||
NetLib::WriteUInt16(buffer, offset, entryType);
|
||||
|
@ -105,7 +105,7 @@ namespace PacketReader::IP::UDP::DNS
|
|||
{
|
||||
}
|
||||
|
||||
DNS_ResponseEntry::DNS_ResponseEntry(u8* buffer, int* offset)
|
||||
DNS_ResponseEntry::DNS_ResponseEntry(const u8* buffer, int* offset)
|
||||
: DNS_QuestionEntry(buffer, offset)
|
||||
{
|
||||
u16 dataLen;
|
||||
|
@ -116,12 +116,12 @@ namespace PacketReader::IP::UDP::DNS
|
|||
*offset += dataLen;
|
||||
}
|
||||
|
||||
int DNS_ResponseEntry::GetLength()
|
||||
int DNS_ResponseEntry::GetLength() const
|
||||
{
|
||||
return DNS_QuestionEntry::GetLength() + 4 + 2 + data.size();
|
||||
}
|
||||
|
||||
void DNS_ResponseEntry::WriteBytes(u8* buffer, int* offset)
|
||||
void DNS_ResponseEntry::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
DNS_QuestionEntry::WriteBytes(buffer, offset);
|
||||
NetLib::WriteUInt32(buffer, offset, timeToLive);
|
||||
|
|
|
@ -18,16 +18,16 @@ namespace PacketReader::IP::UDP::DNS
|
|||
u16 entryClass;
|
||||
|
||||
DNS_QuestionEntry(const std::string& qName, u16 qType, u16 qClass);
|
||||
DNS_QuestionEntry(u8* buffer, int* offset);
|
||||
DNS_QuestionEntry(const u8* buffer, int* offset);
|
||||
|
||||
virtual int GetLength();
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual int GetLength() const;
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual ~DNS_QuestionEntry(){};
|
||||
|
||||
private:
|
||||
void ReadDNS_String(u8* buffer, int* offset, std::string* value);
|
||||
void WriteDNS_String(u8* buffer, int* offset, const std::string& value);
|
||||
void ReadDNS_String(const u8* buffer, int* offset, std::string* value) const;
|
||||
void WriteDNS_String(u8* buffer, int* offset, const std::string& value) const;
|
||||
};
|
||||
|
||||
class DNS_ResponseEntry : public DNS_QuestionEntry
|
||||
|
@ -37,10 +37,10 @@ namespace PacketReader::IP::UDP::DNS
|
|||
std::vector<u8> data;
|
||||
|
||||
DNS_ResponseEntry(const std::string& rName, u16 rType, u16 rClass, const std::vector<u8>& rData, u32 rTTL);
|
||||
DNS_ResponseEntry(u8* buffer, int* offset);
|
||||
DNS_ResponseEntry(const u8* buffer, int* offset);
|
||||
|
||||
virtual int GetLength();
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual int GetLength() const;
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual ~DNS_ResponseEntry(){};
|
||||
};
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
namespace PacketReader::IP::UDP::DNS
|
||||
{
|
||||
bool DNS_Packet::GetQR()
|
||||
bool DNS_Packet::GetQR() const
|
||||
{
|
||||
return (flags1 & (1 << 7)) != 0;
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ namespace PacketReader::IP::UDP::DNS
|
|||
flags1 = (flags1 & ~(0x1 << 7)) | ((value & 0x1) << 7);
|
||||
}
|
||||
|
||||
u8 DNS_Packet::GetOpCode()
|
||||
u8 DNS_Packet::GetOpCode() const
|
||||
{
|
||||
return (flags1 >> 3) & 0xF;
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ namespace PacketReader::IP::UDP::DNS
|
|||
flags1 = (flags1 & ~(0xF << 3)) | ((value & 0xF) << 3);
|
||||
}
|
||||
|
||||
bool DNS_Packet::GetAA()
|
||||
bool DNS_Packet::GetAA() const
|
||||
{
|
||||
return (flags1 & (1 << 2)) != 0;
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ namespace PacketReader::IP::UDP::DNS
|
|||
flags1 = (flags1 & ~(0x1 << 2)) | ((value & 0x1) << 2);
|
||||
}
|
||||
|
||||
bool DNS_Packet::GetTC()
|
||||
bool DNS_Packet::GetTC() const
|
||||
{
|
||||
return (flags1 & (1 << 1)) != 0;
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ namespace PacketReader::IP::UDP::DNS
|
|||
flags1 = (flags1 & ~(0x1 << 1)) | ((value & 0x1) << 1);
|
||||
}
|
||||
|
||||
bool DNS_Packet::GetRD()
|
||||
bool DNS_Packet::GetRD() const
|
||||
{
|
||||
return (flags1 & 1) != 0;
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ namespace PacketReader::IP::UDP::DNS
|
|||
flags1 = (flags1 & ~0x1) | (value & 0x1);
|
||||
}
|
||||
|
||||
bool DNS_Packet::GetRA()
|
||||
bool DNS_Packet::GetRA() const
|
||||
{
|
||||
return (flags2 & (1 << 7)) != 0;
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ namespace PacketReader::IP::UDP::DNS
|
|||
flags2 = (flags2 & ~(0x1 << 7)) | ((value & 0x1) << 7);
|
||||
}
|
||||
|
||||
u8 DNS_Packet::GetZ0()
|
||||
u8 DNS_Packet::GetZ0() const
|
||||
{
|
||||
return (flags2 & (1 << 6)) != 0;
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ namespace PacketReader::IP::UDP::DNS
|
|||
flags1 = (flags2 & ~(0x1 << 6)) | ((value & 0x1) << 6);
|
||||
}
|
||||
|
||||
bool DNS_Packet::GetAD()
|
||||
bool DNS_Packet::GetAD() const
|
||||
{
|
||||
return (flags2 & (1 << 5)) != 0;
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ namespace PacketReader::IP::UDP::DNS
|
|||
flags2 = (flags2 & ~(0x1 << 5)) | ((value & 0x1) << 5);
|
||||
}
|
||||
|
||||
bool DNS_Packet::GetCD()
|
||||
bool DNS_Packet::GetCD() const
|
||||
{
|
||||
return (flags2 & (1 << 4)) != 0;
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ namespace PacketReader::IP::UDP::DNS
|
|||
flags2 = (flags2 & ~(0x1 << 4)) | ((value & 0x1) << 4);
|
||||
}
|
||||
|
||||
u8 DNS_Packet::GetRCode()
|
||||
u8 DNS_Packet::GetRCode() const
|
||||
{
|
||||
return flags2 & 0xF;
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ namespace PacketReader::IP::UDP::DNS
|
|||
flags2 = (flags2 & ~(0xF)) | ((value & 0xF));
|
||||
}
|
||||
|
||||
DNS_Packet::DNS_Packet(u8* buffer, int bufferSize)
|
||||
DNS_Packet::DNS_Packet(const u8* buffer, int bufferSize)
|
||||
{
|
||||
int offset = 0;
|
||||
//Bits 0-31 //Bytes 0-3
|
||||
|
|
|
@ -33,38 +33,38 @@ namespace PacketReader::IP::UDP::DNS
|
|||
std::vector<DNS_ResponseEntry> authorities;
|
||||
std::vector<DNS_ResponseEntry> additional;
|
||||
|
||||
bool GetQR();
|
||||
bool GetQR() const;
|
||||
void SetQR(bool value);
|
||||
|
||||
u8 GetOpCode();
|
||||
u8 GetOpCode() const;
|
||||
void SetOpCode(u8 value);
|
||||
|
||||
bool GetAA();
|
||||
bool GetAA() const;
|
||||
void SetAA(bool value);
|
||||
|
||||
bool GetTC();
|
||||
bool GetTC() const;
|
||||
void SetTC(bool value);
|
||||
|
||||
bool GetRD();
|
||||
bool GetRD() const;
|
||||
void SetRD(bool value);
|
||||
|
||||
bool GetRA();
|
||||
bool GetRA() const;
|
||||
void SetRA(bool value);
|
||||
|
||||
u8 GetZ0();
|
||||
u8 GetZ0() const;
|
||||
void SetZ0(u8 value);
|
||||
|
||||
bool GetAD();
|
||||
bool GetAD() const;
|
||||
void SetAD(bool value);
|
||||
|
||||
bool GetCD();
|
||||
bool GetCD() const;
|
||||
void SetCD(bool value);
|
||||
|
||||
u8 GetRCode();
|
||||
u8 GetRCode() const;
|
||||
void SetRCode(u8 value);
|
||||
|
||||
DNS_Packet() {}
|
||||
DNS_Packet(u8* buffer, int bufferSize);
|
||||
DNS_Packet(const u8* buffer, int bufferSize);
|
||||
|
||||
virtual int GetLength();
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
|
|
|
@ -42,7 +42,7 @@ namespace PacketReader::IP::UDP
|
|||
{
|
||||
}
|
||||
|
||||
Payload* UDP_Packet::GetPayload()
|
||||
Payload* UDP_Packet::GetPayload() const
|
||||
{
|
||||
return payload.get();
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ namespace PacketReader::IP::UDP
|
|||
return new UDP_Packet(*this);
|
||||
}
|
||||
|
||||
u8 UDP_Packet::GetProtocol()
|
||||
u8 UDP_Packet::GetProtocol() const
|
||||
{
|
||||
return (u8)protocol;
|
||||
}
|
||||
|
|
|
@ -27,13 +27,13 @@ namespace PacketReader::IP::UDP
|
|||
UDP_Packet(const u8* buffer, int bufferSize);
|
||||
UDP_Packet(const UDP_Packet&);
|
||||
|
||||
Payload* GetPayload();
|
||||
Payload* GetPayload() const;
|
||||
|
||||
virtual int GetLength();
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual UDP_Packet* Clone() const;
|
||||
|
||||
virtual u8 GetProtocol();
|
||||
virtual u8 GetProtocol() const;
|
||||
|
||||
virtual bool VerifyChecksum(IP_Address srcIP, IP_Address dstIP);
|
||||
virtual void CalculateChecksum(IP_Address srcIP, IP_Address dstIP);
|
||||
|
|
|
@ -45,41 +45,41 @@ namespace PacketReader::NetLib
|
|||
*(PacketReader::IP::IP_Address*)&data[*index] = value;
|
||||
*index += sizeof(PacketReader::IP::IP_Address);
|
||||
}
|
||||
inline void WriteByteArray(u8* data, int* index, int length, u8* value)
|
||||
inline void WriteByteArray(u8* data, int* index, int length, const u8* value)
|
||||
{
|
||||
memcpy(&data[*index], value, length);
|
||||
*index += length;
|
||||
}
|
||||
|
||||
// Read.
|
||||
inline void ReadByte08(u8* data, int* index, u8* value)
|
||||
inline void ReadByte08(const u8* data, int* index, u8* value)
|
||||
{
|
||||
*value = data[*index];
|
||||
*index += sizeof(u8);
|
||||
}
|
||||
inline void ReadUInt16(u8* data, int* index, u16* value)
|
||||
inline void ReadUInt16(const u8* data, int* index, u16* value)
|
||||
{
|
||||
*value = ntohs(*(u16*)&data[*index]);
|
||||
*index += sizeof(u16);
|
||||
}
|
||||
inline void ReadUInt32(u8* data, int* index, u32* value)
|
||||
inline void ReadUInt32(const u8* data, int* index, u32* value)
|
||||
{
|
||||
*value = ntohl(*(u32*)&data[*index]);
|
||||
*index += sizeof(u32);
|
||||
}
|
||||
|
||||
// Special read.
|
||||
inline void ReadMACAddress(u8* data, int* index, PacketReader::MAC_Address* value)
|
||||
inline void ReadMACAddress(const u8* data, int* index, PacketReader::MAC_Address* value)
|
||||
{
|
||||
*value = *(PacketReader::MAC_Address*)&data[*index];
|
||||
*index += sizeof(PacketReader::MAC_Address);
|
||||
}
|
||||
inline void ReadIPAddress(u8* data, int* index, PacketReader::IP::IP_Address* value)
|
||||
inline void ReadIPAddress(const u8* data, int* index, PacketReader::IP::IP_Address* value)
|
||||
{
|
||||
*value = *(PacketReader::IP::IP_Address*)&data[*index];
|
||||
*index += sizeof(PacketReader::IP::IP_Address);
|
||||
}
|
||||
inline void ReadByteArray(u8* data, int* index, int length, u8* value)
|
||||
inline void ReadByteArray(const u8* data, int* index, int length, u8* value)
|
||||
{
|
||||
memcpy(value, &data[*index], length);
|
||||
*index += length;
|
||||
|
|
Loading…
Reference in New Issue