Ipv6NsHelper { public boolean transmitNeighborSolicitation(Uint64 dpnId, NodeConnectorRef nodeRef, MacAddress srcMacAddress, Ipv6Address srcIpv6Address, Ipv6Address targetIpv6Address) { byte[] txPayload = frameNeighborSolicitationRequest(srcMacAddress, srcIpv6Address, targetIpv6Address); NodeConnectorRef nodeConnectorRef = MDSALUtil.getNodeConnRef(dpnId, "0xfffffffd"); TransmitPacketInput input = new TransmitPacketInputBuilder().setPayload(txPayload) .setNode(new NodeRef(InstanceIdentifier.builder(Nodes.class) .child(Node.class, new NodeKey(new NodeId("openflow:" + dpnId))).build())) .setEgress(nodeRef).setIngress(nodeConnectorRef).build(); LOG.debug("Transmitting the Neighbor Solicitation packet out on {}", dpnId); LoggingFutures.addErrorLogging(packetService.transmitPacket(input), LOG, "transmitPacket"); return true; } @Inject  Ipv6NsHelper(final PacketProcessingService packetService); boolean transmitNeighborSolicitation(Uint64 dpnId, NodeConnectorRef nodeRef, MacAddress srcMacAddress,
            Ipv6Address srcIpv6Address, Ipv6Address targetIpv6Address); void transmitNeighborSolicitationToOfGroup(Uint64 dpId, MacAddress srcMacAddress,
            Ipv6Address srcIpv6Address, Ipv6Address targetIpv6Address, long ofGroupId);  }
@Test public void testTransmitNeighborSolicitation() { doReturn(RpcResultBuilder.status(true).buildFuture()).when(pktProcessService) .transmitPacket(any(TransmitPacketInput.class)); Uint64 dpnId = Uint64.ONE; String macAddr = "08:00:27:FE:8F:95"; boolean retValue; Ipv6Address srcIpv6Address = new Ipv6Address("2001:db8::1"); Ipv6Address targetIpv6Address = new Ipv6Address("2001:db8::2"); InstanceIdentifier<Node> ncId = InstanceIdentifier.builder(Nodes.class) .child(Node.class, new NodeKey(new NodeId("openflow:1"))).build(); NodeConnectorRef nodeRef = new NodeConnectorRef(ncId); retValue = instance.transmitNeighborSolicitation(dpnId, nodeRef, new MacAddress(macAddr), srcIpv6Address, targetIpv6Address); assertEquals(true, retValue); verify(pktProcessService, times(1)).transmitPacket(any(TransmitPacketInput.class)); byte[] expectedPayload = buildPacket( "33 33 00 00 00 02", "08 00 27 FE 8F 95", "86 DD", "60 00 00 00", "00 20", "3A", "FF", "20 01 0D B8 00 00 00 00 00 00 00 00 00 00 00 01", "FF 02 00 00 00 00 00 00 00 00 00 01 FF 00 00 02", "87", "00", "5E 94", "00 00 00 00", "20 01 0D B8 00 00 00 00 00 00 00 00 00 00 00 02", "01", "01", "08 00 27 FE 8F 95" ); NodeConnectorRef nodeConnectorRef = MDSALUtil.getNodeConnRef(dpnId, "0xfffffffd"); verify(pktProcessService).transmitPacket(new TransmitPacketInputBuilder().setPayload(expectedPayload) .setNode(new NodeRef(ncId)).setEgress(nodeRef).setIngress(nodeConnectorRef).build()); }
@Test public void testTransmitNeighborSolicitationWithInvalidPayload() { doReturn(RpcResultBuilder.status(true).buildFuture()).when(pktProcessService) .transmitPacket(any(TransmitPacketInput.class)); Uint64 dpnId = Uint64.ONE; String macAddr = "08:00:27:FE:8F:95"; boolean retValue; Ipv6Address srcIpv6Address = new Ipv6Address("2001:db8::1"); Ipv6Address targetIpv6Address = new Ipv6Address("2001:db8::2"); InstanceIdentifier<Node> ncId = InstanceIdentifier.builder(Nodes.class) .child(Node.class, new NodeKey(new NodeId("openflow:1"))).build(); NodeConnectorRef nodeRef = new NodeConnectorRef(ncId); retValue = instance.transmitNeighborSolicitation(dpnId, nodeRef, new MacAddress(macAddr), srcIpv6Address, targetIpv6Address); assertEquals(true, retValue); verify(pktProcessService, times(1)).transmitPacket(any(TransmitPacketInput.class)); byte[] expectedPayload = buildPacket( "33 33 00 00 00 02", "08 00 27 FE 8F 95", "86 DD", "60 00 00 00", "00 20", "3A", "FF", "20 01 0D B8 00 00 00 00 00 00 00 00 00 00 00 01", "FF 02 00 00 00 00 00 00 00 00 00 01 FF 00 00 02", "87", "00", "5E 95", "00 00 00 00", "20 01 0D B8 00 00 00 00 00 00 00 00 00 00 00 02", "01", "01", "08 00 27 FE 8F 95" ); NodeConnectorRef nodeConnectorRef = MDSALUtil.getNodeConnRef(dpnId, "0xfffffffd"); verify(pktProcessService, times(0)).transmitPacket(new TransmitPacketInputBuilder().setPayload(expectedPayload) .setNode(new NodeRef(ncId)).setEgress(nodeRef).setIngress(nodeConnectorRef).build()); expectedPayload = buildPacket( "33 33 00 00 00 02", "08 00 27 FE 8F 95", "86 DD", "60 00 00 00", "00 20", "3A", "FF", "20 01 0D B8 00 00 00 00 00 00 00 00 00 00 00 01", "FF 02 00 00 00 00 00 00 00 00 00 01 FF 00 00 02", "88", "00", "5E 94", "00 00 00 00", "20 01 0D B8 00 00 00 00 00 00 00 00 00 00 00 02", "01", "01", "08 00 27 FE 8F 95" ); verify(pktProcessService, times(0)).transmitPacket(new TransmitPacketInputBuilder().setPayload(expectedPayload) .setNode(new NodeRef(ncId)).setEgress(nodeRef).setIngress(nodeConnectorRef).build()); }