Package org.apache.directory.server.dhcp.options

Examples of org.apache.directory.server.dhcp.options.OptionsField


                lease.setHardwareAddress( hardwareAddress );
                lease.setState( Lease.STATE_NEW );
                lease.setClientAddress( host.getAddress() );

                // set lease options
                OptionsField o = lease.getOptions();

                // set (client) host name
                o.add( new HostName( host.getName() ) );

                // add subnet settings
                o.add( new SubnetMask( subnet.getNetmask() ) );
                o.merge( subnet.getOptions() );

                // add the host's options. they override existing
                // subnet options as they take the precedence.
                o.merge( host.getOptions() );
            }
        }

        if ( null == lease )
        {
View Full Code Here


        // build properties map
        Map properties = getProperties( subnet );

        // update lease options
        OptionsField o = lease.getOptions();
        o.clear();

        // add subnet settings
        o.add( new SubnetMask( subnet.getNetmask() ) );
        o.merge( subnet.getOptions() );

        // check whether there is a designated host.
        Host host = findDesignatedHost( hardwareAddress );
        if ( null != host )
        {
            // check whether the host matches the address (using a fixed
            // host address is mandatory).
            if ( host.getAddress() != null && !host.getAddress().equals( lease.getClientAddress() ) )
            {
                logger.warn( "Existing fixed address for " + hardwareAddress + " conflicts with existing lease "
                    + lease );
                return null;
            }

            properties.putAll( getProperties( host ) );

            // set (client) host name
            o.add( new HostName( host.getName() ) );

            // add the host's options
            o.merge( host.getOptions() );
        }

        // update other lease fields
        long leaseTime = determineLeaseTime( requestedLeaseTime, properties );
        lease.setExpires( System.currentTimeMillis() + leaseTime );
View Full Code Here

            reply.setAssignedClientAddress( lease.getClientAddress() );
            reply.setNextServerAddress( lease.getNextServerAddress() );

            // fix options
            OptionsField options = reply.getOptions();

            // these options must not be present
            options.remove( RequestedIpAddress.class );
            options.remove( ParameterRequestList.class );
            options.remove( ClientIdentifier.class );
            options.remove( MaximumDhcpMessageSize.class );

            // these options must be present
            options.add( new IpAddressLeaseTime( ( lease.getExpires() - System.currentTimeMillis() ) / 1000L ) );

            stripUnwantedOptions( request, options );
        }

        return reply;
View Full Code Here

        reply.setAssignedClientAddress( lease.getClientAddress() );
        reply.setNextServerAddress( lease.getNextServerAddress() );

        // fix options
        OptionsField options = reply.getOptions();

        // these options must not be present
        options.remove( RequestedIpAddress.class );
        options.remove( ParameterRequestList.class );
        options.remove( ClientIdentifier.class );
        options.remove( MaximumDhcpMessageSize.class );

        // these options must be present
        options.add( new IpAddressLeaseTime( ( lease.getExpires() - System.currentTimeMillis() ) / 1000L ) );

        stripUnwantedOptions( request, options );

        return reply;
    }
View Full Code Here

            {} ), 16 );

        writeString( byteBuffer, message.getServerHostname(), 64 );
        writeString( byteBuffer, message.getBootFileName(), 128 );

        OptionsField options = message.getOptions();

        // update message type option (if set)
        if ( null != message.getMessageType() )
        {
            options.add( new DhcpMessageType( message.getMessageType() ) );
        }

        encodeOptions( options, byteBuffer );
    }
View Full Code Here

            reply.setAssignedClientAddress( lease.getClientAddress() );
            reply.setNextServerAddress( lease.getNextServerAddress() );

            // fix options
            OptionsField options = reply.getOptions();

            // these options must not be present
            options.remove( RequestedIpAddress.class );
            options.remove( ParameterRequestList.class );
            options.remove( ClientIdentifier.class );
            options.remove( MaximumDhcpMessageSize.class );

            // these options must be present
            options.add( new IpAddressLeaseTime( ( lease.getExpires() - System.currentTimeMillis() ) / 1000L ) );

            stripUnwantedOptions( request, options );
        }
        return reply;
    }
View Full Code Here

        byte[] chaddr = decodeBytes( buffer, 16 );

        String sname = decodeString( buffer, 64 );
        String file = decodeString( buffer, 128 );

        OptionsField options = decodeOptions( buffer );

        // message type option: may be null if option isn't set (BOOTP)
        DhcpMessageType mto = ( DhcpMessageType ) options.get( DhcpMessageType.class );

        return new DhcpMessage( null != mto ? mto.getType() : null, op, new HardwareAddress( htype, hlen, chaddr ),
            hops, xid, secs, flags, ciaddr, yiaddr, siaddr, giaddr, sname, file, options );
    }
View Full Code Here

        byte code;
        byte length;
        byte value[];

        OptionsField options = new OptionsField();

        while ( true )
        {
            code = message.get();

            if ( code == 0 ) // pad option
            {
                continue;
            }

            if ( code == -1 ) // end option
            {
                break;
            }

            length = message.get();
            value = new byte[length];
            message.get( value );

            options.add( getOptionInstance( code, value ) );
        }

        return options;
    }
View Full Code Here

                lease.setHardwareAddress( hardwareAddress );
                lease.setState( Lease.STATE_NEW );
                lease.setClientAddress( host.getAddress() );

                // set lease options
                OptionsField o = lease.getOptions();

                // set (client) host name
                o.add( new HostName( host.getName() ) );

                // add subnet settings
                o.add( new SubnetMask( subnet.getNetmask() ) );
                o.merge( subnet.getOptions() );

                // add the host's options. they override existing
                // subnet options as they take the precedence.
                o.merge( host.getOptions() );
            }
        }

        if ( null == lease )
        {
View Full Code Here

        // build properties map
        Map properties = getProperties( subnet );

        // update lease options
        OptionsField o = lease.getOptions();
        o.clear();

        // add subnet settings
        o.add( new SubnetMask( subnet.getNetmask() ) );
        o.merge( subnet.getOptions() );

        // check whether there is a designated host.
        Host host = findDesignatedHost( hardwareAddress );
        if ( null != host )
        {
            // check whether the host matches the address (using a fixed
            // host address is mandatory).
            if ( host.getAddress() != null && !host.getAddress().equals( lease.getClientAddress() ) )
            {
                logger.warn( "Existing fixed address for " + hardwareAddress + " conflicts with existing lease "
                    + lease );
                return null;
            }

            properties.putAll( getProperties( host ) );

            // set (client) host name
            o.add( new HostName( host.getName() ) );

            // add the host's options
            o.merge( host.getOptions() );
        }

        // update other lease fields
        long leaseTime = determineLeaseTime( requestedLeaseTime, properties );
        lease.setExpires( System.currentTimeMillis() + leaseTime );
View Full Code Here

TOP

Related Classes of org.apache.directory.server.dhcp.options.OptionsField

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.