Fix bootp migration

This commit is contained in:
femsci 2023-06-14 22:25:27 +02:00
parent 0823cc25d3
commit 8ab872589c
Signed by: femsci
GPG key ID: 08F7911F0E650C67
2 changed files with 7 additions and 7 deletions

View file

@ -5,6 +5,7 @@ using System.Net;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using IPMeow.Lib; using IPMeow.Lib;
using IPMeow.Lib.Address;
namespace IPMeow.Dhcp.Server.Dhcp4; namespace IPMeow.Dhcp.Server.Dhcp4;
@ -31,7 +32,7 @@ public class BootpHeader
public override string ToString() public override string ToString()
{ {
return $"{Hops}\nXid: {Xid}, Seconds: {Seconds}, Flags: {Flags:x}\nci: {ClientAddress}\nyi: {YourAddress}, ns: {NextServerAddress}, ra: {RelayAgentAddress}\nhw: {MacAddress.Parse(GetMacAddress())}\nhost: {ServerHostName}\nboot: {BootFileName}"; return $"{Hops}\nXid: {Xid}, Seconds: {Seconds}, Flags: {Flags:x}\nci: {ClientAddress}\nyi: {YourAddress}, ns: {NextServerAddress}, ra: {RelayAgentAddress}\nhw: {MacAddress.Parse(GetMacAddress())}";
} }
public byte[] GetClientHwAddress() public byte[] GetClientHwAddress()
@ -110,7 +111,7 @@ public class BootpHeader
using MemoryStream buffer = new(); using MemoryStream buffer = new();
BinaryWriter writer = new(buffer); BinaryWriter writer = new(buffer);
writer.Write((byte)); writer.Write((byte)OpType);
writer.Write((byte)1); writer.Write((byte)1);
writer.Write((byte)6); writer.Write((byte)6);
writer.Write(Hops); writer.Write(Hops);
@ -122,8 +123,7 @@ public class BootpHeader
writer.Write(NextServerAddress.GetAddressBytes()); writer.Write(NextServerAddress.GetAddressBytes());
writer.Write(RelayAgentAddress.GetAddressBytes()); writer.Write(RelayAgentAddress.GetAddressBytes());
writer.Write(GetClientHwAddress()); writer.Write(GetClientHwAddress());
writer.Write(GetSnameBytes()); writer.Write(Enumerable.Repeat((byte)0, 64 + 128).ToArray());
writer.Write(GetBootFileBytes());
return buffer.GetBuffer(); return buffer.GetBuffer();
} }

View file

@ -49,8 +49,8 @@ public class Dhcp4Server : IDhcpServer, IDisposable
DhcpRequestedEvent.Invoke(this, new() DhcpRequestedEvent.Invoke(this, new()
{ {
IsV6 = false, IsV6 = false,
MacAddress = MacAddress.Parse(packet.GetMacAddress()), MacAddress = MacAddress.Parse(packet.Header.GetMacAddress()),
RequestOrigin = packet.ClientAddress RequestOrigin = packet.Header.ClientAddress
}); });
//TODO //TODO
} }
@ -71,7 +71,7 @@ public class Dhcp4Server : IDhcpServer, IDisposable
return false; return false;
} }
if (packet.NextServerAddress != IPAddress.Any) if (packet.Header.NextServerAddress != IPAddress.Any)
{ {
return false; return false;
} }