Examples of DHCPPacket


Examples of org.dhcp4java.DHCPPacket

    @Test (timeout=1000)
    public void testDiscover() throws Exception {
      byte[] buf;
      DatagramPacket udp;
      DHCPPacket pac = new DHCPPacket();
      pac.setOp(BOOTREQUEST);
      buf = pac.serialize();
      udp = new DatagramPacket(buf, buf.length);
      udp.setAddress(InetAddress.getByName(SERVER_ADDR));
      udp.setPort(SERVER_PORT);
      socket.send(udp);
      udp = new DatagramPacket(new byte[1500], 1500);
View Full Code Here

Examples of org.dhcp4java.DHCPPacket

      throw new UnsupportedOperationException();
    }

    public static void main(String[] args) {
        // first send discover
        DHCPPacket discover = new DHCPPacket();

        discover.setOp(BOOTREQUEST);
        discover.setHtype(HTYPE_ETHER);
        discover.setHlen((byte) 6);
        discover.setHops((byte) 0);
        discover.setXid( (new Random()).nextInt() );
        discover.setSecs((short) 0);
        discover.setFlags((short) 0);
        discover.setChaddr(macAddress);
    }
View Full Code Here

Examples of org.dhcp4java.DHCPPacket

        try {
            DatagramSocket socket = new DatagramSocket(DHCPConstants.BOOTP_REQUEST_PORT);

            while (true) {
                DatagramPacket pac = new DatagramPacket(new byte[1500], 1500);
                DHCPPacket     dhcp;

                socket.receive(pac);
                dhcp = DHCPPacket.getPacket(pac);
                System.out.println(dhcp.toString());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
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.