mirror of https://github.com/PCSX2/pcsx2.git
DEV9: Add PayloadData classes
This commit is contained in:
parent
b23873e0ed
commit
5ac9b5576a
|
@ -28,6 +28,42 @@ namespace PacketReader::IP
|
|||
virtual ~IP_Payload() {}
|
||||
};
|
||||
|
||||
class IP_PayloadData : public IP_Payload
|
||||
{
|
||||
public:
|
||||
std::unique_ptr<u8[]> data;
|
||||
|
||||
private:
|
||||
int length;
|
||||
u8 protocol;
|
||||
|
||||
public:
|
||||
IP_PayloadData(int len, u8 prot)
|
||||
{
|
||||
protocol = prot;
|
||||
length = len;
|
||||
|
||||
if (len != 0)
|
||||
data = std::make_unique<u8[]>(len);
|
||||
}
|
||||
virtual int GetLength()
|
||||
{
|
||||
return length;
|
||||
}
|
||||
virtual void WriteBytes(u8* buffer, int* offset)
|
||||
{
|
||||
if (length == 0)
|
||||
return;
|
||||
|
||||
memcpy(&buffer[*offset], data.get(), length);
|
||||
*offset += length;
|
||||
}
|
||||
virtual u8 GetProtocol()
|
||||
{
|
||||
return protocol;
|
||||
}
|
||||
};
|
||||
|
||||
//Pointer to bytes not owned by class
|
||||
class IP_PayloadPtr : public IP_Payload
|
||||
{
|
||||
|
|
|
@ -25,6 +25,37 @@ namespace PacketReader
|
|||
virtual ~Payload() {}
|
||||
};
|
||||
|
||||
//Data owned by class
|
||||
class PayloadData : public Payload
|
||||
{
|
||||
public:
|
||||
std::unique_ptr<u8[]> data;
|
||||
|
||||
private:
|
||||
int length;
|
||||
|
||||
public:
|
||||
PayloadData(int len)
|
||||
{
|
||||
length = len;
|
||||
|
||||
if (len != 0)
|
||||
data = std::make_unique<u8[]>(len);
|
||||
}
|
||||
virtual int GetLength()
|
||||
{
|
||||
return length;
|
||||
}
|
||||
virtual void WriteBytes(u8* buffer, int* offset)
|
||||
{
|
||||
if (length == 0)
|
||||
return;
|
||||
|
||||
memcpy(&buffer[*offset], data.get(), length);
|
||||
*offset += length;
|
||||
}
|
||||
};
|
||||
|
||||
//Pointer to bytes not owned by class
|
||||
class PayloadPtr : public Payload
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue