}
@Test
public void testMarshall() throws UnknownHostException {
// test if serialized packet has the right parameters
DHCPPacket packet = refPacketFromHex;
assertEquals("foobar", packet.getComment());
assertEquals(BOOTREQUEST, packet.getOp());
assertEquals(HTYPE_ETHER, packet.getHtype());
assertEquals((byte) 6, packet.getHlen());
assertEquals((byte)0, packet.getHops());
assertEquals(0x11223344, packet.getXid());
assertEquals((short) 0x8000, packet.getFlags());
assertEquals((short) 0, packet.getSecs());
assertEquals(InetAddress.getByName("10.0.0.1"), packet.getCiaddr());
assertTrue(Arrays.equals(InetAddress.getByName("10.0.0.1").getAddress(), packet.getCiaddrRaw()));
assertEquals(InetAddress.getByName("10.0.0.2"), packet.getYiaddr());
assertTrue(Arrays.equals(InetAddress.getByName("10.0.0.2").getAddress(), packet.getYiaddrRaw()));
assertEquals(InetAddress.getByName("10.0.0.3"), packet.getSiaddr());
assertTrue(Arrays.equals(InetAddress.getByName("10.0.0.3").getAddress(), packet.getSiaddrRaw()));
assertEquals(InetAddress.getByName("10.0.0.4"), packet.getGiaddr());
assertTrue(Arrays.equals(InetAddress.getByName("10.0.0.4").getAddress(), packet.getGiaddrRaw()));
assertEquals("00112233445566778899aabbccddeeff".substring(0, 2*packet.getHlen()), packet.getChaddrAsHex());
assertTrue(Arrays.equals(HexUtils.hexToBytes("00112233445566778899AABBCCDDEEFF"), packet.getChaddr()));
assertEquals(STR200.substring(0, 64), packet.getSname());
assertEquals(STR200.substring(0, 128), packet.getFile());
assertTrue(Arrays.equals(new byte[256], packet.getPadding()));
assertTrue(packet.isDhcp());
assertFalse(packet.isTruncated());
assertEquals(DHCPDISCOVER, packet.getDHCPMessageType().byteValue());
assertEquals("12.34.56.68", packet.getOptionAsInetAddr(DHO_DHCP_SERVER_IDENTIFIER).getHostAddress());
assertEquals(86400, packet.getOptionAsInteger(DHO_DHCP_LEASE_TIME).intValue());
assertEquals("255.255.255.0", packet.getOptionAsInetAddr(DHO_SUBNET_MASK).getHostAddress());
assertEquals(1, packet.getOptionAsInetAddrs(DHO_ROUTERS).length);
assertEquals("10.0.0.254", packet.getOptionAsInetAddrs(DHO_ROUTERS)[0].getHostAddress());
assertEquals(2, packet.getOptionAsInetAddrs(DHO_STATIC_ROUTES).length);
assertEquals("22.33.44.55", packet.getOptionAsInetAddrs(DHO_STATIC_ROUTES)[0].getHostAddress());
assertEquals("10.0.0.254", packet.getOptionAsInetAddrs(DHO_STATIC_ROUTES)[1].getHostAddress());
assertEquals(1, packet.getOptionAsInetAddrs(DHO_WWW_SERVER).length);
assertEquals("10.0.0.6", packet.getOptionAsInetAddrs(DHO_WWW_SERVER)[0].getHostAddress());
assertEquals(null, packet.getOptionAsInetAddrs(DHO_IRC_SERVER));
assertFalse(packet.containsOption(DHO_BOOTFILE));
assertFalse(packet.containsOption(DHO_PAD));
assertFalse(packet.containsOption(DHO_END));
assertTrue(packet.containsOption(DHO_WWW_SERVER));
}