use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.open.TlvsBuilder in project bgpcep by opendaylight.
the class PCEPObjectiveFunctionObjectParser method parseObject.
@Override
public Of parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
final Uint16 ofId = ByteBufUtils.readUint16(bytes);
bytes.skipBytes(RESERVED);
final TlvsBuilder tlvsBuilder = new TlvsBuilder();
parseTlvs(tlvsBuilder, bytes.slice());
return new OfBuilder().setIgnore(header.getIgnore()).setProcessingRule(header.getProcessingRule()).setCode(new OfId(ofId)).setTlvs(tlvsBuilder.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.open.TlvsBuilder in project bgpcep by opendaylight.
the class PCEPObjectParserTest method testErrorObjectWithTlv.
@Test
public void testErrorObjectWithTlv() throws PCEPDeserializerException, IOException {
final PCEPErrorObjectParser parser = new PCEPErrorObjectParser(this.tlvRegistry, this.viTlvRegistry);
final ErrorObjectBuilder builder = new ErrorObjectBuilder().setProcessingRule(true).setIgnore(true).setType(Uint8.ONE).setValue(Uint8.ONE);
ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPErrorObject1.bin"));
assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4)));
ByteBuf buf = Unpooled.buffer();
parser.serializeObject(builder.build(), buf);
assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPErrorObject3.bin"));
builder.setType(Uint8.valueOf(7)).setValue(Uint8.ZERO).setTlvs(new TlvsBuilder().setReqMissing(new ReqMissingBuilder().setRequestId(new RequestId(Uint32.valueOf(0x00001155L))).build()).build());
assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4)));
buf = Unpooled.buffer();
parser.serializeObject(builder.build(), buf);
assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
try {
parser.parseObject(new ObjectHeaderImpl(true, true), null);
fail();
} catch (final IllegalArgumentException e) {
assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
}
try {
parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
fail();
} catch (final IllegalArgumentException e) {
assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.open.TlvsBuilder in project bgpcep by opendaylight.
the class PCEPValidatorTest method testReqMesgWithLSP.
@Test
public void testReqMesgWithLSP() throws IOException, PCEPDeserializerException {
// Test PcRequest message with an LSP Object as per RFC8231
new StatefulActivator().start(ctx);
final Rp rp = new RpBuilder().setProcessingRule(true).setIgnore(false).setReoptimization(false).setBiDirectional(false).setLoose(true).setMakeBeforeBreak(false).setOrder(false).setPathKey(false).setSupplyOf(false).setFragmentation(false).setP2mp(false).setEroCompression(false).setPriority(Uint8.ONE).setRequestId(new RequestId(Uint32.TEN)).setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.rp.object.rp.TlvsBuilder().build()).build();
final Lsp lspReq = new LspBuilder().setIgnore(false).setProcessingRule(false).setAdministrative(false).setDelegate(false).setPlspId(new PlspId(Uint32.ZERO)).setOperational(OperationalStatus.Down).setSync(false).setRemove(false).setTlvs(new TlvsBuilder().build()).build();
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.object.EndpointsObjBuilder epBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.object.EndpointsObjBuilder().setIgnore(false).setProcessingRule(true).setAddressFamily(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.Ipv4CaseBuilder().setIpv4(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.ipv4._case.Ipv4Builder().setSourceIpv4Address(new Ipv4AddressNoZone("255.255.255.255")).setDestinationIpv4Address(new Ipv4AddressNoZone("255.255.255.255")).build()).build());
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.RequestsBuilder rBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.RequestsBuilder().setRp(rp).setSegmentComputation(new SegmentComputationBuilder().setP2p(new P2pBuilder().setEndpointsObj(epBuilder.build()).addAugmentation(new P2p1Builder().setLsp(lspReq).build()).build()).build());
final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.Requests> reqs = new ArrayList<>();
reqs.add(rBuilder.build());
final Pcreq pcReq = new PcreqBuilder().setPcreqMessage(new PcreqMessageBuilder().setRequests(reqs).build()).build();
final StatefulPCRequestMessageParser parser = new StatefulPCRequestMessageParser(this.ctx.getObjectHandlerRegistry());
ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCReq.1.bin"));
assertEquals(pcReq, parser.parseMessage(result.slice(4, result.readableBytes() - 4), Collections.emptyList()));
ByteBuf buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(pcReq, buf);
assertArrayEquals(result.array(), buf.array());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.open.TlvsBuilder in project bgpcep by opendaylight.
the class PCEPValidatorTest method setUp.
@Before
public void setUp() {
this.ctx = new SimplePCEPExtensionProviderContext();
this.act = new BaseParserExtensionActivator();
this.act.start(this.ctx);
this.lspa = new LspaBuilder().setProcessingRule(false).setIgnore(false).setLocalProtectionDesired(false).setHoldPriority(Uint8.ZERO).setSetupPriority(Uint8.ZERO).setExcludeAny(new AttributeFilter(Uint32.ZERO)).setIncludeAll(new AttributeFilter(Uint32.ZERO)).setIncludeAny(new AttributeFilter(Uint32.ZERO)).setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lspa.object.lspa.TlvsBuilder().build()).build();
this.metrics = new MetricsBuilder().setMetric(new MetricBuilder().setIgnore(false).setProcessingRule(false).setComputed(false).setBound(false).setMetricType(Uint8.ONE).setValue(new Float32(new byte[4])).build()).build();
this.eroASSubobject = new AsNumberCaseBuilder().setAsNumber(new AsNumberBuilder().setAsNumber(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber(Uint32.valueOf(0xFFFF))).build()).build();
this.rroUnnumberedSub = new UnnumberedCaseBuilder().setUnnumbered(new UnnumberedBuilder().setRouterId(Uint32.valueOf(0x00112233L)).setInterfaceId(Uint32.valueOf(0x00ff00ffL)).build()).build();
final IroBuilder iroBuilder = new IroBuilder().setIgnore(false).setProcessingRule(false);
final List<Subobject> iroSubs = new ArrayList<>();
iroSubs.add(new SubobjectBuilder().setSubobjectType(this.eroASSubobject).setLoose(false).build());
iroBuilder.setSubobject(iroSubs);
this.iro = iroBuilder.build();
final EroBuilder eroBuilder = new EroBuilder();
eroBuilder.setIgnore(false);
eroBuilder.setProcessingRule(false);
final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.ero.Subobject> eroSubs = new ArrayList<>();
eroSubs.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.ero.SubobjectBuilder().setSubobjectType(this.eroASSubobject).setLoose(false).build());
eroBuilder.setSubobject(eroSubs);
this.ero = eroBuilder.build();
final RroBuilder rroBuilder = new RroBuilder();
rroBuilder.setIgnore(false);
rroBuilder.setProcessingRule(false);
final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reported.route.object.rro.Subobject> rroSubs = new ArrayList<>();
rroSubs.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reported.route.object.rro.SubobjectBuilder().setSubobjectType(this.rroUnnumberedSub).setProtectionAvailable(false).setProtectionInUse(false).build());
rroBuilder.setSubobject(rroSubs);
this.rro = rroBuilder.build();
this.srp = new SrpBuilder().setIgnore(false).setProcessingRule(false).setOperationId(new SrpIdNumber(Uint32.ONE)).addAugmentation(new Srp1Builder().setRemove(false).build()).setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.srp.object.srp.TlvsBuilder().build()).build();
final LspBuilder lspBuilder = new LspBuilder().setIgnore(false).setProcessingRule(false).setAdministrative(false).setDelegate(false).setPlspId(new PlspId(Uint32.ZERO)).setOperational(OperationalStatus.Down).setSync(false).setRemove(false).setTlvs(new TlvsBuilder().build()).addAugmentation(new Lsp1Builder().setCreate(false).build());
this.lspSrp = lspBuilder.build();
this.lsp = lspBuilder.setTlvs(new TlvsBuilder().setLspIdentifiers(new LspIdentifiersBuilder().setAddressFamily(new Ipv4CaseBuilder().setIpv4(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.identifiers.tlv.lsp.identifiers.address.family.ipv4._case.Ipv4Builder().setIpv4TunnelSenderAddress(new Ipv4AddressNoZone("127.0.1.1")).setIpv4ExtendedTunnelId(new Ipv4ExtendedTunnelId(new Ipv4AddressNoZone("127.0.1.2"))).setIpv4TunnelEndpointAddress(new Ipv4AddressNoZone("127.0.1.3")).build()).build()).setLspId(new LspId(Uint32.ONE)).setTunnelId(new TunnelId(Uint16.ONE)).build()).build()).build();
final Ipv4Builder afi = new Ipv4Builder().setSourceIpv4Address(new Ipv4AddressNoZone("255.255.255.255")).setDestinationIpv4Address(new Ipv4AddressNoZone("255.255.255.255"));
this.bandwidth = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.bandwidth.object.BandwidthBuilder().setIgnore(false).setProcessingRule(false).setBandwidth(new Bandwidth(new byte[] { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 })).build();
this.reoptimizationBandwidth = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reoptimization.bandwidth.object.ReoptimizationBandwidthBuilder().setIgnore(false).setProcessingRule(false).setBandwidth(new Bandwidth(new byte[] { (byte) 0x47, (byte) 0x74, (byte) 0x24, (byte) 0x00 })).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.open.TlvsBuilder in project bgpcep by opendaylight.
the class BasePCEPSessionProposalFactory method getSessionProposal.
@Override
public Open getSessionProposal(final InetSocketAddress address, final int sessionId, final PCEPPeerProposal peerProposal) {
final OpenBuilder oBuilder = new OpenBuilder().setSessionId(Uint8.valueOf(sessionId)).setKeepalive(Uint8.valueOf(BasePCEPSessionProposalFactory.this.keepAlive));
if (BasePCEPSessionProposalFactory.this.keepAlive == 0) {
oBuilder.setDeadTimer(Uint8.ZERO);
} else {
oBuilder.setDeadTimer(Uint8.valueOf(BasePCEPSessionProposalFactory.this.deadTimer));
}
final TlvsBuilder builder = new TlvsBuilder();
addTlvs(address, builder);
if (peerProposal != null) {
peerProposal.setPeerSpecificProposal(address, builder);
}
return oBuilder.setTlvs(builder.build()).build();
}
Aggregations