DEV9: Add IP_Address helpers to NetLib

This commit is contained in:
TheLastRar 2023-01-16 14:13:49 +00:00 committed by refractionpcsx2
parent 9b3b8aa4de
commit 095757044a
2 changed files with 16 additions and 0 deletions

View File

@ -23,6 +23,8 @@
#include <arpa/inet.h> #include <arpa/inet.h>
#endif #endif
using namespace PacketReader::IP;
namespace PacketReader::NetLib namespace PacketReader::NetLib
{ {
void WriteByte08(u8* data, int* index, u8 value) void WriteByte08(u8* data, int* index, u8 value)
@ -42,6 +44,11 @@ namespace PacketReader::NetLib
} }
//Special //Special
void WriteIPAddress(u8* data, int* index, IP_Address value)
{
*(IP_Address*)&data[*index] = value;
*index += sizeof(IP_Address);
}
void WriteByteArray(u8* data, int* index, int length, u8* value) void WriteByteArray(u8* data, int* index, int length, u8* value)
{ {
memcpy(&data[*index], value, length); memcpy(&data[*index], value, length);
@ -67,6 +74,11 @@ namespace PacketReader::NetLib
} }
//Special //Special
void ReadIPAddress(u8* data, int* index, IP_Address* value)
{
*value = *(IP_Address*)&data[*index];
*index += sizeof(IP_Address);
}
void ReadByteArray(u8* data, int* index, int length, u8* value) void ReadByteArray(u8* data, int* index, int length, u8* value)
{ {
memcpy(value, &data[*index], length); memcpy(value, &data[*index], length);

View File

@ -15,17 +15,21 @@
#pragma once #pragma once
#include "DEV9/PacketReader/IP/IP_Address.h"
namespace PacketReader::NetLib namespace PacketReader::NetLib
{ {
void WriteByte08(u8* data, int* index, u8 value); void WriteByte08(u8* data, int* index, u8 value);
void WriteUInt16(u8* data, int* index, u16 value); void WriteUInt16(u8* data, int* index, u16 value);
void WriteUInt32(u8* data, int* index, u32 value); void WriteUInt32(u8* data, int* index, u32 value);
void WriteIPAddress(u8* data, int* index, PacketReader::IP::IP_Address value);
void WriteByteArray(u8* data, int* index, int length, u8* value); void WriteByteArray(u8* data, int* index, int length, u8* value);
void ReadByte08(u8* data, int* index, u8* value); void ReadByte08(u8* data, int* index, u8* value);
void ReadUInt16(u8* data, int* index, u16* value); void ReadUInt16(u8* data, int* index, u16* value);
void ReadUInt32(u8* data, int* index, u32* value); void ReadUInt32(u8* data, int* index, u32* value);
void ReadIPAddress(u8* data, int* index, PacketReader::IP::IP_Address* value);
void ReadByteArray(u8* data, int* index, int length, u8* value); void ReadByteArray(u8* data, int* index, int length, u8* value);
} // namespace PacketReader::NetLib } // namespace PacketReader::NetLib