use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.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());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.replies.result.success._case.SuccessBuilder in project bgpcep by opendaylight.
the class PCEPReplyMessageParser method handleEros.
private Result handleEros(final Queue<Object> objects) {
final SuccessBuilder builder = new SuccessBuilder();
final List<Paths> paths = new ArrayList<>();
for (Object obj = objects.peek(); obj != null && !(obj instanceof PceId); obj = objects.peek()) {
final PathsBuilder pBuilder = new PathsBuilder();
if (obj instanceof Ero) {
pBuilder.setEro((Ero) obj);
objects.remove();
}
final List<VendorInformationObject> vendorInfoObjects = addVendorInformationObjects(objects);
if (!vendorInfoObjects.isEmpty()) {
builder.setVendorInformationObject(vendorInfoObjects);
}
this.parsePath(pBuilder, objects);
paths.add(pBuilder.build());
}
builder.setPaths(paths);
return new SuccessCaseBuilder().setSuccess(builder.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.replies.result.success._case.SuccessBuilder in project bgpcep by opendaylight.
the class PCEPValidatorTest method testReplyMsgWithTwoEros.
@Test
public void testReplyMsgWithTwoEros() throws IOException, PCEPDeserializerException {
// Success Reply with two EROs: the first one is followed by Bandwidth Object and one Metric Object
final PCEPReplyMessageParser parser = new PCEPReplyMessageParser(this.objectRegistry);
final PcrepMessageBuilder builder = new PcrepMessageBuilder();
final List<Replies> replies = new ArrayList<>();
final BandwidthBuilder bwBuilder = new BandwidthBuilder();
bwBuilder.setIgnore(false);
bwBuilder.setProcessingRule(false);
bwBuilder.setBandwidth(new Bandwidth(new byte[] { (byte) 0x47, (byte) 0x74, (byte) 0x24, (byte) 0x00 }));
RepliesBuilder repliesBuilder = new RepliesBuilder();
repliesBuilder = new RepliesBuilder();
repliesBuilder.setRp(this.rpTrue);
final List<Paths> paths = new ArrayList<>();
final PathsBuilder paBuilder1 = new PathsBuilder().setEro(this.ero).setBandwidth(bwBuilder.build()).setMetrics(Lists.newArrayList(this.metrics));
paths.add(paBuilder1.build());
final PathsBuilder paBuilder2 = new PathsBuilder();
paBuilder2.setEro(this.ero);
paths.add(paBuilder2.build());
repliesBuilder.setResult(new SuccessCaseBuilder().setSuccess(new SuccessBuilder().setPaths(paths).build()).build()).build();
replies.add(repliesBuilder.build());
builder.setReplies(replies);
ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCRep.7.bin"));
assertEquals(new PcrepBuilder().setPcrepMessage(builder.build()).build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4), Collections.emptyList()));
ByteBuf buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(new PcrepBuilder().setPcrepMessage(builder.build()).build(), buf);
assertArrayEquals(result.array(), buf.array());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.replies.result.success._case.SuccessBuilder in project bgpcep by opendaylight.
the class PCEPValidatorTest method testRepWithMonitoring.
@Test
public void testRepWithMonitoring() throws IOException, PCEPDeserializerException {
final PCEPReplyMessageParser parser = new PCEPReplyMessageParser(this.objectRegistry);
final PcrepMessageBuilder builder = new PcrepMessageBuilder();
RepliesBuilder repliesBuilder = new RepliesBuilder();
final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCRepMon.5.bin"));
final List<Replies> replies4 = new ArrayList<>();
repliesBuilder = new RepliesBuilder().setRp(this.rpTrue).setMonitoring(this.monitoring).setPccIdReq(this.pccIdReq).setMetricPce(Lists.newArrayList(new MetricPceBuilder().setPceId(this.pceId).build()));
final List<Paths> paths = new ArrayList<>();
final PathsBuilder paBuilder = new PathsBuilder().setEro(this.ero).setLspa(this.lspa).setMetrics(Lists.newArrayList(this.metrics)).setIro(this.iro).setOf(this.of);
paths.add(paBuilder.build());
repliesBuilder.setResult(new SuccessCaseBuilder().setSuccess(new SuccessBuilder().setPaths(paths).build()).build()).build();
replies4.add(repliesBuilder.build());
builder.setReplies(replies4);
assertEquals(new PcrepBuilder().setPcrepMessage(builder.build()).build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4), Collections.emptyList()));
final ByteBuf buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(new PcrepBuilder().setPcrepMessage(builder.build()).build(), buf);
assertArrayEquals(result.array(), buf.array());
}
Aggregations