@Test public void onIpv6PacketReceivedNullInputTest1() throws Exception { Ipv6PacketReceived ipv6PktReceived = new Ipv6PacketReceivedBuilder().setPacketChain(null).build(); AddressObserverUsingIpv6 addressObserverIpv6 = new AddressObserverUsingIpv6(addressObservationWriterMock); addressObserverIpv6.onIpv6PacketReceived(ipv6PktReceived); verify(addressObservationWriterMock, times(0)).addAddress(any(MacAddress.class), any(IpAddress.class), any(NodeConnectorRef.class)); }
@Override public void onIpv6PacketReceived(Ipv6PacketReceived packetReceived) { if (packetReceived == null || packetReceived.getPacketChain() == null) { return; } RawPacket rawPacket = null; EthernetPacket ethernetPacket = null; Ipv6Packet ipv6Packet = null; for (PacketChain packetChain : packetReceived.getPacketChain()) { if (packetChain.getPacket() instanceof RawPacket) { rawPacket = (RawPacket) packetChain.getPacket(); } else if (packetChain.getPacket() instanceof EthernetPacket) { ethernetPacket = (EthernetPacket) packetChain.getPacket(); } else if (packetChain.getPacket() instanceof Ipv6Packet) { ipv6Packet = (Ipv6Packet) packetChain.getPacket(); } } if (rawPacket == null || ethernetPacket == null || ipv6Packet == null) { return; } if (!IPV6_IP_TO_IGNORE.equals(ipv6Packet.getSourceIpv6().getValue())) { addressObservationWriter.addAddress(ethernetPacket.getSourceMac(), new IpAddress(ipv6Packet.getSourceIpv6().getValue().toCharArray()), rawPacket.getIngress()); } }
AddressObserverUsingIpv6 implements Ipv6PacketListener { @Override public void onIpv6PacketReceived(Ipv6PacketReceived packetReceived) { if (packetReceived == null || packetReceived.getPacketChain() == null) { return; } RawPacket rawPacket = null; EthernetPacket ethernetPacket = null; Ipv6Packet ipv6Packet = null; for (PacketChain packetChain : packetReceived.getPacketChain()) { if (packetChain.getPacket() instanceof RawPacket) { rawPacket = (RawPacket) packetChain.getPacket(); } else if (packetChain.getPacket() instanceof EthernetPacket) { ethernetPacket = (EthernetPacket) packetChain.getPacket(); } else if (packetChain.getPacket() instanceof Ipv6Packet) { ipv6Packet = (Ipv6Packet) packetChain.getPacket(); } } if (rawPacket == null || ethernetPacket == null || ipv6Packet == null) { return; } if (!IPV6_IP_TO_IGNORE.equals(ipv6Packet.getSourceIpv6().getValue())) { addressObservationWriter.addAddress(ethernetPacket.getSourceMac(), new IpAddress(ipv6Packet.getSourceIpv6().getValue().toCharArray()), rawPacket.getIngress()); } } }
AddressObserverUsingIpv6 implements Ipv6PacketListener { @Override public void onIpv6PacketReceived(Ipv6PacketReceived packetReceived) { if (packetReceived == null || packetReceived.getPacketChain() == null) { return; } RawPacket rawPacket = null; EthernetPacket ethernetPacket = null; Ipv6Packet ipv6Packet = null; for (PacketChain packetChain : packetReceived.getPacketChain()) { if (packetChain.getPacket() instanceof RawPacket) { rawPacket = (RawPacket) packetChain.getPacket(); } else if (packetChain.getPacket() instanceof EthernetPacket) { ethernetPacket = (EthernetPacket) packetChain.getPacket(); } else if (packetChain.getPacket() instanceof Ipv6Packet) { ipv6Packet = (Ipv6Packet) packetChain.getPacket(); } } if (rawPacket == null || ethernetPacket == null || ipv6Packet == null) { return; } if (!IPV6_IP_TO_IGNORE.equals(ipv6Packet.getSourceIpv6().getValue())) { addressObservationWriter.addAddress(ethernetPacket.getSourceMac(), new IpAddress(ipv6Packet.getSourceIpv6().getValue().toCharArray()), rawPacket.getIngress()); } } AddressObserverUsingIpv6(AddressObservationWriter addressObservationWriter); }
AddressObserverUsingIpv6 implements Ipv6PacketListener { @Override public void onIpv6PacketReceived(Ipv6PacketReceived packetReceived) { if (packetReceived == null || packetReceived.getPacketChain() == null) { return; } RawPacket rawPacket = null; EthernetPacket ethernetPacket = null; Ipv6Packet ipv6Packet = null; for (PacketChain packetChain : packetReceived.getPacketChain()) { if (packetChain.getPacket() instanceof RawPacket) { rawPacket = (RawPacket) packetChain.getPacket(); } else if (packetChain.getPacket() instanceof EthernetPacket) { ethernetPacket = (EthernetPacket) packetChain.getPacket(); } else if (packetChain.getPacket() instanceof Ipv6Packet) { ipv6Packet = (Ipv6Packet) packetChain.getPacket(); } } if (rawPacket == null || ethernetPacket == null || ipv6Packet == null) { return; } if (!IPV6_IP_TO_IGNORE.equals(ipv6Packet.getSourceIpv6().getValue())) { addressObservationWriter.addAddress(ethernetPacket.getSourceMac(), new IpAddress(ipv6Packet.getSourceIpv6().getValue().toCharArray()), rawPacket.getIngress()); } } AddressObserverUsingIpv6(AddressObservationWriter addressObservationWriter); @Override void onIpv6PacketReceived(Ipv6PacketReceived packetReceived); }
AddressObserverUsingIpv6 implements Ipv6PacketListener { @Override public void onIpv6PacketReceived(Ipv6PacketReceived packetReceived) { if (packetReceived == null || packetReceived.getPacketChain() == null) { return; } RawPacket rawPacket = null; EthernetPacket ethernetPacket = null; Ipv6Packet ipv6Packet = null; for (PacketChain packetChain : packetReceived.getPacketChain()) { if (packetChain.getPacket() instanceof RawPacket) { rawPacket = (RawPacket) packetChain.getPacket(); } else if (packetChain.getPacket() instanceof EthernetPacket) { ethernetPacket = (EthernetPacket) packetChain.getPacket(); } else if (packetChain.getPacket() instanceof Ipv6Packet) { ipv6Packet = (Ipv6Packet) packetChain.getPacket(); } } if (rawPacket == null || ethernetPacket == null || ipv6Packet == null) { return; } if (!IPV6_IP_TO_IGNORE.equals(ipv6Packet.getSourceIpv6().getValue())) { addressObservationWriter.addAddress(ethernetPacket.getSourceMac(), new IpAddress(ipv6Packet.getSourceIpv6().getValue().toCharArray()), rawPacket.getIngress()); } } AddressObserverUsingIpv6(AddressObservationWriter addressObservationWriter); @Override void onIpv6PacketReceived(Ipv6PacketReceived packetReceived);  }