Examples of DhcpOption


Examples of net.floodlightcontroller.packet.DHCPOption

        if (!(udp.getPayload() instanceof DHCP))
            return;
        DHCP dhcp = (DHCP) udp.getPayload();
        byte opcode = dhcp.getOpCode();
        if (opcode == DHCP.OPCODE_REQUEST) {
            DHCPOption dhcpOption = dhcp.getOption(
                    DHCPOptionCode.OptionCode_Hostname);
            if (dhcpOption != null) {
                cntDhcpClientNameSnooped.updateCounterNoFlush();
                srcDevice.dhcpClientName = new String(dhcpOption.getData());
            }
        }
    }
View Full Code Here

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

        {
            byte[] list = prl.getData();

            for ( Iterator i = options.iterator(); i.hasNext(); )
            {
                DhcpOption o = ( DhcpOption ) i.next();

                boolean found = false;

                for ( int j = 0; j < list.length; j++ )
                {
                    if ( list[j] == o.getTag() )
                    {
                        found = true;
                        break;
                    }
                }
View Full Code Here

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

    {
        message.put( VENDOR_MAGIC_COOKIE );

        for ( Iterator i = options.iterator(); i.hasNext(); )
        {
            DhcpOption option = ( DhcpOption ) i.next();
            option.writeTo( message );
        }

        // add end option
        message.put( ( byte ) 0xff );
    }
View Full Code Here

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

    {
        try
        {
            Class c = DhcpOption.getClassByTag( tag );

            DhcpOption o = null != c ? ( DhcpOption ) c.newInstance() : new UnrecognizedOption( ( byte ) tag );
            o.setData( value );

            return o;
        }
        catch ( Exception e )
        {
View Full Code Here

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

        final ParameterRequestList prl = (ParameterRequestList) request
                .getOptions().get(ParameterRequestList.class);
        if (null != prl) {
            final byte[] list = prl.getData();
            for (final Iterator i = options.iterator(); i.hasNext();) {
                final DhcpOption o = (DhcpOption) i.next();
                for (int j = 0; j < list.length; j++)
                    if (list[j] == o.getTag())
                        continue;
                i.remove();
            }
        }
    }
View Full Code Here

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

    {
        message.put( VENDOR_MAGIC_COOKIE );

        for ( Iterator i = options.iterator(); i.hasNext(); )
        {
            DhcpOption option = ( DhcpOption ) i.next();
            option.writeTo( message );
        }

        // add end option
        message.put( ( byte ) 0xff );
    }
View Full Code Here

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

    {
        try
        {
            Class c = DhcpOption.getClassByTag( tag );

            DhcpOption o = null != c ? ( DhcpOption ) c.newInstance() : new UnrecognizedOption( ( byte ) tag );
            o.setData( value );

            return o;
        }
        catch ( Exception e )
        {
View Full Code Here

Examples of org.dhcp4java.DHCPOption

    DHCPOption opt = new DHCPOption(DHO_DHCP_LEASE_TIME, new byte[3]);
    opt.getValueAsInt();
  }
  @Test (expected=DHCPBadPacketException.class)
  public void testGetValueAsIntBadSize5() {
    DHCPOption opt = new DHCPOption(DHO_DHCP_LEASE_TIME, new byte[5]);
    opt.getValueAsInt();
  }
View Full Code Here

Examples of org.dhcp4java.DHCPOption

  }
 
  // Num
  @Test
  public void testNewOptionAsIntGetValueAsNum() {
    DHCPOption opt;
    opt = DHCPOption.newOptionAsInt(DHO_DHCP_LEASE_TIME, 0x01FE02FC);
    assertEquals(Integer.valueOf(0x01FE02FC), opt.getValueAsNum());
    opt = DHCPOption.newOptionAsShort(DHO_INTERFACE_MTU, (short)1500);
    assertEquals(Integer.valueOf(1500), opt.getValueAsNum());
    opt = DHCPOption.newOptionAsByte(DHO_IP_FORWARDING, (byte)1);
    assertEquals(Integer.valueOf(1), opt.getValueAsNum());
    opt = DHCPOption.newOptionAsString(DHO_TFTP_SERVER, "foobar");
    assertNull(opt.getValueAsNum());
    opt = DHCPOption.newOptionAsString(DHO_TFTP_SERVER, null);
    assertNull(opt.getValueAsNum());
  }
View Full Code Here

Examples of org.dhcp4java.DHCPOption

  }
 
  // InetAddress
  @Test
  public void testNewOptionAsInetAddressGetValueAsInetAddress() throws Exception {
    DHCPOption opt = DHCPOption.newOptionAsInetAddress(DHO_SUBNET_MASK,
                      InetAddress.getByName("252.10.224.3"));
    assertEquals(opt.getCode(), DHO_SUBNET_MASK);
    assertTrue(Arrays.equals(opt.getValue(), HexUtils.hexToBytes("FC0AE003")));
   
    assertEquals(opt.getValueAsInetAddr(), InetAddress.getByName("252.10.224.3"));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.