Esempio n. 1
0
        public void RemoveAcl(PhysicalAddress address)
        {
            this.m_AclLock.AcquireWriterLock(-1);

            try
            {
                if (this.m_Acl.ContainsKey(address))
                {
                    this.m_Acl.Remove(address);
                }
            }
            finally
            {
                this.m_AclLock.ReleaseLock();
            }
        }
Esempio n. 2
0
        public void AddAcl(PhysicalAddress address, Boolean deny)
        {
            this.m_AclLock.AcquireWriterLock(-1);

            try
            {
                if (this.m_Acl.ContainsKey(address))
                {
                    this.m_Acl[address] = !deny;
                }
                else
                {
                    this.m_Acl.Add(address, !deny);
                }
            }
            finally
            {
                this.m_AclLock.ReleaseLock();
            }
        }
Esempio n. 3
0
        private void SendAck(DhcpMessage message)
        {
            Trace.TraceInformation("{0} Sending Dhcp Acknowledge.", Thread.CurrentThread.ManagedThreadId);

            DhcpMessage response = new DhcpMessage();
            response.Operation = DhcpOperation.BootReply;
            response.Hardware = HardwareType.Ethernet;
            response.HardwareAddressLength = 6;
            response.SecondsElapsed = message.SecondsElapsed;
            response.SessionId = message.SessionId;

            Byte[] hardwareAddressData = new Byte[6];
            Array.Copy(message.ClientHardwareAddress, hardwareAddressData, 6);
            PhysicalAddress clientHardwareAddress = new PhysicalAddress(hardwareAddressData);

            if (this.m_Reservations.ContainsKey(clientHardwareAddress))
            {
                response.NextServerAddress = IPAddress.Parse(this.m_Reservations[clientHardwareAddress].ReserveNextServer).GetAddressBytes();
                response.BootFileName = Encoding.UTF8.GetBytes(this.m_Reservations[clientHardwareAddress].ReserveBootFile);
            }
            else
            {
                if (!string.IsNullOrEmpty(UserNextServer))
                    response.NextServerAddress = IPAddress.Parse(UserNextServer).GetAddressBytes();
                else
                    response.NextServerAddress = this.m_DhcpInterfaceAddress.GetAddressBytes();

                switch (message.ClientArchitecture)
                {

                    case "00000":
                        response.BootFileName = Encoding.UTF8.GetBytes(BiosBootFile);
                        break;
                    case "00006":
                        response.BootFileName = Encoding.UTF8.GetBytes(Efi32BootFile);
                        break;
                    case "00007":
                        response.BootFileName = Encoding.UTF8.GetBytes(Efi64BootFile);
                        break;
                    case "00009":
                        response.BootFileName = Encoding.UTF8.GetBytes(Efi64BootFile);
                        break;
                    default:
                        response.BootFileName = Encoding.UTF8.GetBytes(BiosBootFile);
                        break;
                }

            }
            
            response.ClientAddress = message.ClientAddress;
            response.ClientHardwareAddress = message.ClientHardwareAddress;
            response.AddOption(DhcpOption.DhcpMessageType, (Byte)DhcpMessageType.Ack);
            response.SourcePort = message.SourcePort;
            this.SendReply(response,true);
            Trace.TraceInformation("{0} Dhcp Acknowledge Sent.", Thread.CurrentThread.ManagedThreadId);
        }
Esempio n. 4
0
        private void DhcpRequest(DhcpMessage message)
        {
            Byte[] addressRequestData = message.GetOptionData(DhcpOption.AddressRequest);
            if (addressRequestData == null)
            {
                addressRequestData = message.ClientAddress;
            }

            InternetAddress addressRequest = new InternetAddress(addressRequestData);

            if (addressRequest.IsEmpty)
            {
                this.SendNak(message);
                return;
            }
            
            // Assume we're on an ethernet network
            Byte[] hardwareAddressData = new Byte[6];
            Array.Copy(message.ClientHardwareAddress, hardwareAddressData, 6);
            PhysicalAddress clientHardwareAddress = new PhysicalAddress(hardwareAddressData);
            
            // If this client is explicitly allowed, or they are not denied and the allow any flag is set
            if (this.m_Acl.ContainsKey(clientHardwareAddress) && this.m_Acl[clientHardwareAddress] ||
                !this.m_Acl.ContainsKey(clientHardwareAddress) && this.m_AllowAny)
            {
                this.SendAck(message);
            }
            else
            {
                this.SendNak(message);
            }
            
        }