@Test public void getArpFromTest_notArpPacket() throws PacketException { byte[] payload = {0xb, 0xe, 0xe, 0xf}; PacketReceived packet = new PacketReceivedBuilder().setPayload(payload).build(); e.expect(PacketException.class); ArpResolverUtils.getArpFrom(packet); }
public static Arp getArpFrom(PacketReceived potentialArp) throws PacketException { byte[] payload = potentialArp.getPayload(); Ethernet ethPkt = new Ethernet(); ethPkt.deserialize(payload, 0, payload.length * NetUtils.NumBitsInAByte); if (ethPkt.getPayload() instanceof Arp) { return (Arp) ethPkt.getPayload(); } throw new PacketException("Packet is not ARP: " + potentialArp); }
ArpResolverUtils { public static Arp getArpFrom(PacketReceived potentialArp) throws PacketException { byte[] payload = potentialArp.getPayload(); Ethernet ethPkt = new Ethernet(); ethPkt.deserialize(payload, 0, payload.length * NetUtils.NumBitsInAByte); if (ethPkt.getPayload() instanceof Arp) { return (Arp) ethPkt.getPayload(); } throw new PacketException("Packet is not ARP: " + potentialArp); } }
ArpResolverUtils { public static Arp getArpFrom(PacketReceived potentialArp) throws PacketException { byte[] payload = potentialArp.getPayload(); Ethernet ethPkt = new Ethernet(); ethPkt.deserialize(payload, 0, payload.length * NetUtils.NumBitsInAByte); if (ethPkt.getPayload() instanceof Arp) { return (Arp) ethPkt.getPayload(); } throw new PacketException("Packet is not ARP: " + potentialArp); }  }
ArpResolverUtils { public static Arp getArpFrom(PacketReceived potentialArp) throws PacketException { byte[] payload = potentialArp.getPayload(); Ethernet ethPkt = new Ethernet(); ethPkt.deserialize(payload, 0, payload.length * NetUtils.NumBitsInAByte); if (ethPkt.getPayload() instanceof Arp) { return (Arp) ethPkt.getPayload(); } throw new PacketException("Packet is not ARP: " + potentialArp); }  static Arp getArpFrom(PacketReceived potentialArp); }
ArpResolverUtils { public static Arp getArpFrom(PacketReceived potentialArp) throws PacketException { byte[] payload = potentialArp.getPayload(); Ethernet ethPkt = new Ethernet(); ethPkt.deserialize(payload, 0, payload.length * NetUtils.NumBitsInAByte); if (ethPkt.getPayload() instanceof Arp) { return (Arp) ethPkt.getPayload(); } throw new PacketException("Packet is not ARP: " + potentialArp); }  static Arp getArpFrom(PacketReceived potentialArp);  }