Exemple #1
0
        internal static DHCPClient CreateFromMessage(DHCPMessage message)
        {
            DHCPClient result = new DHCPClient();

            result.m_HardwareAddress = message.ClientHardwareAddress;

            DHCPOptionHostName dhcpOptionHostName = (DHCPOptionHostName)message.GetOption(TDHCPOption.HostName);

            if (dhcpOptionHostName != null)
            {
                result.m_HostName = dhcpOptionHostName.HostName;
            }

            DHCPOptionClientIdentifier dhcpOptionClientIdentifier = (DHCPOptionClientIdentifier)message.GetOption(TDHCPOption.ClientIdentifier);

            if (dhcpOptionClientIdentifier != null)
            {
                result.m_Identifier = dhcpOptionClientIdentifier.Data;
            }
            else
            {
                result.m_Identifier = message.ClientHardwareAddress;
            }

            return(result);
        }
Exemple #2
0
        public bool Match(DHCPMessage message)
        {
            var client = DHCPClient.CreateFromMessage(message);

            if (!string.IsNullOrWhiteSpace(MacTaste) && m_Prefix != null)
            {
                return(MacMatch(client.HardwareAddress, m_Prefix, m_PrefixBits));
            }
            else if (!string.IsNullOrWhiteSpace(HostName))
            {
                if (!string.IsNullOrWhiteSpace(client.HostName))
                {
                    if (client.HostName.StartsWith(HostName, true, CultureInfo.InvariantCulture))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }