use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.success._case.SuccessBuilder in project netvirt by opendaylight.
the class Ipv6NdUtilServiceImpl method sendNeighborSolicitation.
@Override
public Future<RpcResult<Void>> sendNeighborSolicitation(SendNeighborSolicitationInput ndInput) {
RpcResultBuilder<Void> failureBuilder = RpcResultBuilder.failed();
RpcResultBuilder<Void> successBuilder = RpcResultBuilder.success();
Ipv6Address targetIpv6Address = null;
Ipv6Address srcIpv6Address;
String interfaceName = null;
String macAddr = null;
BigInteger dpnId;
int localErrorCount = 0;
targetIpv6Address = ndInput.getTargetIpAddress();
for (InterfaceAddress interfaceAddress : ndInput.getInterfaceAddress()) {
try {
interfaceName = interfaceAddress.getInterface();
srcIpv6Address = interfaceAddress.getSrcIpAddress();
GetPortFromInterfaceOutput portResult = getPortFromInterface(interfaceName);
checkNotNull(portResult);
dpnId = portResult.getDpid();
Long portid = portResult.getPortno();
checkArgument(null != dpnId && BigInteger.ZERO != dpnId, DPN_NOT_FOUND_ERROR, interfaceName);
NodeConnectorRef nodeRef = MDSALUtil.getNodeConnRef(dpnId, portid.toString());
checkNotNull(nodeRef, NODE_CONNECTOR_NOT_FOUND_ERROR, interfaceName);
if (interfaceAddress.getSrcMacAddress() != null) {
macAddr = interfaceAddress.getSrcMacAddress().getValue();
}
checkNotNull(macAddr, FAILED_TO_GET_SRC_MAC_FOR_INTERFACE, interfaceName, nodeRef.getValue());
ipv6NeighborSolicitation.transmitNeighborSolicitation(dpnId, nodeRef, new MacAddress(macAddr), srcIpv6Address, targetIpv6Address);
} catch (NullPointerException | IllegalArgumentException e) {
LOG.trace("Failed to send Neighbor Solicitation for {} on interface {}", ndInput.getTargetIpAddress(), interfaceName);
failureBuilder.withError(RpcError.ErrorType.APPLICATION, FAILED_TO_SEND_NS_FOR_INTERFACE + interfaceName, e);
successBuilder.withError(RpcError.ErrorType.APPLICATION, FAILED_TO_SEND_NS_FOR_INTERFACE + interfaceName, e);
localErrorCount++;
}
}
if (localErrorCount == ndInput.getInterfaceAddress().size()) {
// Failed to send IPv6 Neighbor Solicitation on all the interfaces, return failure.
return Futures.immediateFuture(failureBuilder.build());
}
return Futures.immediateFuture(successBuilder.build());
}
Aggregations