use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reported.route.object.rro.Subobject in project bgpcep by opendaylight.
the class AbstractSrSubobjectParser method parseSrSubobject.
protected static SrSubobject parseSrSubobject(final ByteBuf buffer) throws PCEPDeserializerException {
final int sidTypeByte = buffer.readByte() >> SID_TYPE_BITS_OFFSET;
final SidType sidType = SidType.forValue(sidTypeByte);
final BitArray bitSet = BitArray.valueOf(buffer.readByte());
final boolean f = bitSet.get(F_FLAG_POSITION);
final boolean s = bitSet.get(S_FLAG_POSITION);
final boolean c = bitSet.get(C_FLAG_POSITION);
final boolean m = bitSet.get(M_FLAG_POSITION);
if (f && s) {
throw new PCEPDeserializerException("Both SID and NAI are absent in SR subobject.");
}
Long tmp = null;
if (!s) {
if (m) {
tmp = buffer.readUnsignedInt() >>> MPLS_LABEL_OFFSET;
} else {
tmp = buffer.readUnsignedInt();
}
}
final Long sid = tmp;
final Nai nai;
if (sidType != null && !f) {
nai = parseNai(sidType, buffer);
} else {
nai = null;
}
return new SrSubobjectImpl(m, c, sidType, sid, nai);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reported.route.object.rro.Subobject in project bgpcep by opendaylight.
the class SrEroSubobjectParser method serializeSubobject.
@Override
public void serializeSubobject(final Subobject subobject, final ByteBuf buffer) {
Preconditions.checkArgument(subobject.getSubobjectType() instanceof SrSubobject, "Unknown subobject instance. Passed %s. Needed SrSubobject.", subobject.getSubobjectType().getClass());
final SrSubobject srSubobject = (SrSubobject) subobject.getSubobjectType();
final ByteBuf body = serializeSubobject(srSubobject);
EROSubobjectUtil.formatSubobject(this.type, subobject.isLoose(), body, buffer);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reported.route.object.rro.Subobject in project bgpcep by opendaylight.
the class SrEroSubobjectParser method parseSubobject.
@Override
public Subobject parseSubobject(final ByteBuf buffer, final boolean loose) throws PCEPDeserializerException {
final SrEroTypeBuilder srEroSubobjectBuilder = new SrEroTypeBuilder(parseSrSubobject(buffer));
final SubobjectBuilder subobjectBuilder = new SubobjectBuilder();
subobjectBuilder.setLoose(loose);
subobjectBuilder.setSubobjectType(srEroSubobjectBuilder.build());
return subobjectBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reported.route.object.rro.Subobject in project bgpcep by opendaylight.
the class SrRroSubobjectParser method parseSubobject.
@Override
public Subobject parseSubobject(final ByteBuf buffer) throws PCEPDeserializerException {
final SrRroTypeBuilder srRroSubobjectBuilder = new SrRroTypeBuilder(parseSrSubobject(buffer));
final SubobjectBuilder subobjectBuilder = new SubobjectBuilder();
subobjectBuilder.setSubobjectType(srRroSubobjectBuilder.build());
return subobjectBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reported.route.object.rro.Subobject in project bgpcep by opendaylight.
the class TopologyProviderTest method testOnReportMessage.
@Test
public void testOnReportMessage() throws ReadFailedException {
this.listener.onSessionUp(this.session);
Pcrpt pcRptMsg = createSrPcRpt("1.1.1.1", "sr-path1", 1L, true);
this.listener.onMessage(this.session, pcRptMsg);
readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
// check sr-path
final List<ReportedLsp> reportedLsps = pcc.getReportedLsp();
assertNotNull(reportedLsps);
assertEquals(1, reportedLsps.size());
final ReportedLsp lsp = reportedLsps.get(0);
assertEquals("sr-path1", lsp.getName());
assertEquals(1, lsp.getPath().get(0).getAugmentation(Path1.class).getPathSetupType().getPst().intValue());
final List<Subobject> subobjects = lsp.getPath().get(0).getEro().getSubobject();
assertEquals(1, subobjects.size());
assertEquals("1.1.1.1", ((IpNodeId) ((SrEroType) subobjects.get(0).getSubobjectType()).getNai()).getIpAddress().getIpv4Address().getValue());
return pcc;
});
pcRptMsg = createSrPcRpt("1.1.1.3", "sr-path2", 2L, false);
this.listener.onMessage(this.session, pcRptMsg);
readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
// check second lsp sr-path
final List<ReportedLsp> reportedLsps = pcc.getReportedLsp();
assertNotNull(reportedLsps);
assertEquals(2, reportedLsps.size());
return pcc;
});
pcRptMsg = createSrPcRpt("1.1.1.2", "sr-path1", 1L, true);
this.listener.onMessage(this.session, pcRptMsg);
readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
// check updated sr-path
final List<ReportedLsp> reportedLsps = pcc.getReportedLsp();
assertNotNull(reportedLsps);
assertEquals(2, reportedLsps.size());
for (final ReportedLsp rlsp : reportedLsps) {
if (rlsp.getName().equals("sr-path1")) {
final List<Subobject> subobjects = rlsp.getPath().get(0).getEro().getSubobject();
assertEquals(1, subobjects.size());
assertEquals("1.1.1.2", ((IpNodeId) ((SrEroType) subobjects.get(0).getSubobjectType()).getNai()).getIpAddress().getIpv4Address().getValue());
}
}
return pcc;
});
}
Aggregations