Package net.floodlightcontroller.packet

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


    public static Ethernet DhcpDiscoveryRequestEthernet(MACAddress hostMac) {
        List<DHCPOption> optionList = new ArrayList<DHCPOption>();
       
        byte[] requestValue = new byte[4];
        requestValue[0] = requestValue[1] = requestValue[2] = requestValue[3] = 0;
        DHCPOption requestOption =
                new DHCPOption()
                    .setCode(DHCP.DHCPOptionCode.OptionCode_RequestedIP.
                             getValue())
                    .setLength((byte)4)
                    .setData(requestValue);
       
        byte[] msgTypeValue = new byte[1];
        msgTypeValue[0] = 1;    // DHCP request
        DHCPOption msgTypeOption =
                new DHCPOption()
                    .setCode(DHCP.DHCPOptionCode.OptionCode_MessageType.
                             getValue())
                    .setLength((byte)1)
                    .setData(msgTypeValue);
       
        byte[] reqParamValue = new byte[4];
        reqParamValue[0] = 1;   // subnet mask
        reqParamValue[1] = 3;   // Router
        reqParamValue[2] = 6;   // Domain Name Server
        reqParamValue[3] = 42// NTP Server
        DHCPOption reqParamOption =
                new DHCPOption()
                    .setCode(DHCP.DHCPOptionCode.OptionCode_RequestedParameters.
                             getValue())
                    .setLength((byte)4)
                    .setData(reqParamValue);
       
        byte[] clientIdValue = new byte[7];
        clientIdValue[0] = 1;   // Ethernet
        System.arraycopy(hostMac.toBytes(), 0,
                         clientIdValue, 1, 6);
        DHCPOption clientIdOption =
                new DHCPOption()
                    .setCode(DHCP.DHCPOptionCode.OptionCode_ClientID.
                             getValue())
                             .setLength((byte)7)
                             .setData(clientIdValue);
       
        DHCPOption endOption =
                new DHCPOption()
                    .setCode(DHCP.DHCPOptionCode.OptionCode_END.
                             getValue())
                             .setLength((byte)0)
                             .setData(null);
                                   
View Full Code Here

TOP

Related Classes of net.floodlightcontroller.packet.DHCPOption

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.