| 9 | namespace PacketReader::IP::UDP::DHCP |
| 10 | { |
| 11 | DHCP_Packet::DHCP_Packet(const u8* buffer, int bufferSize) |
| 12 | { |
| 13 | int offset = 0; |
| 14 | //Bits 0-31 //Bytes 0-3 |
| 15 | NetLib::ReadByte08(buffer, &offset, &op); |
| 16 | NetLib::ReadByte08(buffer, &offset, &hardwareType); |
| 17 | NetLib::ReadByte08(buffer, &offset, &hardwareAddressLength); |
| 18 | NetLib::ReadByte08(buffer, &offset, &hops); |
| 19 | |
| 20 | //Bits 32-63 //Bytes 4-7 |
| 21 | NetLib::ReadUInt32(buffer, &offset, &transactionID); |
| 22 | |
| 23 | //Bits 64-95 //Bytes 8-11 |
| 24 | NetLib::ReadUInt16(buffer, &offset, &seconds); |
| 25 | NetLib::ReadUInt16(buffer, &offset, &flags); |
| 26 | |
| 27 | //Bits 96-127 //Bytes 12-15 |
| 28 | NetLib::ReadIPAddress(buffer, &offset, &clientIP); |
| 29 | |
| 30 | //Bits 128-159 //Bytes 16-19 |
| 31 | NetLib::ReadIPAddress(buffer, &offset, &yourIP); |
| 32 | |
| 33 | //Bits 160-191 //Bytes 20-23 |
| 34 | NetLib::ReadIPAddress(buffer, &offset, &serverIP); |
| 35 | |
| 36 | //Bits 192-223 //Bytes 24-27 |
| 37 | NetLib::ReadIPAddress(buffer, &offset, &gatewayIP); |
| 38 | |
| 39 | //Bits 192+ //Bytes 28-43 |
| 40 | NetLib::ReadByteArray(buffer, &offset, 16, clientHardwareAddress); |
| 41 | |
| 42 | //Bytes 44-235 |
| 43 | //Assume BOOTP unused |
| 44 | offset += 192; |
| 45 | |
| 46 | //Bytes 236-239 |
| 47 | NetLib::ReadUInt32(buffer, &offset, &magicCookie); |
| 48 | bool opReadFin = false; |
| 49 | |
| 50 | do |
| 51 | { |
| 52 | const u8 opKind = buffer[offset]; |
| 53 | if (opKind == 255) |
| 54 | { |
| 55 | options.push_back(new DHCPopEND()); |
| 56 | opReadFin = true; |
| 57 | offset += 1; |
| 58 | continue; |
| 59 | } |
| 60 | if ((offset + 1) >= bufferSize) |
| 61 | { |
| 62 | Console.Error("DEV9: DHCP_Packet: Unexpected end of packet"); |
| 63 | options.push_back(new DHCPopEND()); |
| 64 | opReadFin = true; |
| 65 | continue; |
| 66 | } |
| 67 | const u8 opLen = buffer[offset + 1]; |
| 68 | switch (opKind) |
nothing calls this directly
no test coverage detected