public void HandleOptions(IDhcpServerPacket Packet, DhcpServerPacketOptions ServerOptions, ref bool StopPropagation) { try { var sb = new StringBuilder(); sb.AppendLine("HANDLE OPTIONS:"); sb.AppendLine($" Transaction Id: {Packet.TransactionId}"); sb.AppendLine($" Server Options:"); sb.AppendLine($" Message Type: {ServerOptions.MessageType}"); sb.AppendLine($" Subnet Mask: {ServerOptions.SubnetMask}"); sb.AppendLine($" Requested Address: {ServerOptions.RequestedAddress}"); sb.AppendLine($" Requested Lease Time: {ServerOptions.RequestedLeaseTime}"); sb.AppendLine($" Router Address: {ServerOptions.RouterAddress}"); sb.AppendLine($" Server: {ServerOptions.Server}"); sb.AppendLine($" Parameter Request List: {string.Join(", ", ServerOptions.ParameterRequestList)}"); sb.AppendLine($" Machine Name: {ServerOptions.MachineName}"); sb.AppendLine($" Client Hardware Address Type: {ServerOptions.ClientHardwareAddressType}"); sb.AppendLine($" Client Hardware Address: {ServerOptions.ClientHardwareAddress}"); sb.AppendLine($" Class Identifier: {ServerOptions.ClassIdentifier}"); sb.Append($" Vendor Class: "); foreach (var b in ServerOptions.VendorClass) { sb.Append(b.ToString("X2")); } sb.AppendLine(); sb.AppendLine($" Dns Name: {ServerOptions.DnsName}"); sb.AppendLine($" Ds Domain Name Requested: {ServerOptions.DsDomainNameRequested}"); sb.AppendLine($" Ds Domain Name: {ServerOptions.DsDomainName}"); sb.AppendLine($" Scope Id: {ServerOptions.ScopeId}"); sb.AppendLine("---------------------"); WriteLog(sb.ToString()); } catch (Exception ex) { WriteLog($"HANDLE OPTIONS ERROR: {ex.Message} [{ex.GetType().Name}]"); WriteLog(ex.StackTrace); throw; } }
private static uint HandleHandleOptionsHook(IntPtr Packet, uint PacketSize, IntPtr Reserved, IntPtr PktContext, IntPtr ServerOptions) { var stopPropagation = false; var packet = new DhcpServerPacket(Packet, (int)PacketSize); var serverOptions = new DhcpServerPacketOptions(ServerOptions); foreach (var consumer in Consumers) { if (consumer.SupportFlags.HasFlag(CalloutConsumerSupportFlags.HandleOptions)) { try { consumer.Proxy.HandleOptions(packet, serverOptions, ref stopPropagation); } catch (Win32Exception ex) { return((uint)ex.NativeErrorCode); } catch (Exception) { return(0x1U); //ERROR_INVALID_FUNCTION } // stop propagation if instructed if (stopPropagation) { return(ERROR_SUCCESS); } } } // chain if (!stopPropagation && ChainTable.DhcpHandleOptionsHook != null) { return(ChainTable.DhcpHandleOptionsHook(Packet, PacketSize, Reserved, PktContext, ServerOptions)); } return(ERROR_SUCCESS); }
public void HandleOptions(IDhcpServerPacket Packet, DhcpServerPacketOptions ServerOptions, ref bool StopPropagation) { handleOptionsHandler.HandleOptions(Packet, ServerOptions, ref StopPropagation); }