use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.association.object.AssociationObject in project bgpcep by opendaylight.
the class AbstractAssociationParser method localSerializeObject.
@Override
protected final void localSerializeObject(final RsvpTeObject teLspObject, final ByteBuf output) {
Preconditions.checkArgument(teLspObject instanceof AssociationObject, "AssociationObject is mandatory.");
final AssociationObject assObject = (AssociationObject) teLspObject;
if (assObject.getIpAddress().getIpv4Address() != null) {
serializeAttributeHeader(BODY_SIZE_IPV4, CLASS_NUM, CTYPE_IPV4, output);
output.writeShort(assObject.getAssociationType().getIntValue());
output.writeShort(assObject.getAssociationId());
output.writeBytes(Ipv4Util.byteBufForAddress(assObject.getIpAddress().getIpv4Address()));
} else {
serializeAttributeHeader(BODY_SIZE_IPV6, CLASS_NUM, CTYPE_IPV6, output);
output.writeShort(assObject.getAssociationType().getIntValue());
output.writeShort(assObject.getAssociationId());
output.writeBytes(Ipv6Util.byteBufForAddress(assObject.getIpAddress().getIpv6Address()));
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.association.object.AssociationObject in project bgpcep by opendaylight.
the class TeLspAttributesParser method serializeLspAttributes.
static void serializeLspAttributes(final RSVPTeObjectRegistry registry, final TeLspAttributesCase linkState, final ByteBuf output) {
LOG.trace("Started serializing TE LSP Objects");
final ByteBuf byteBuf = Unpooled.buffer();
final TeLspAttributes teLspAttribute = linkState.getTeLspAttributes();
final TspecObject tSpec = teLspAttribute.getTspecObject();
registry.serializeRSPVTe(tSpec, byteBuf);
final FlowSpecObject flow = teLspAttribute.getFlowSpecObject();
registry.serializeRSPVTe(flow, byteBuf);
final SessionAttributeObject sao = teLspAttribute.getSessionAttributeObject();
if (sao instanceof BasicSessionAttributeObject) {
registry.serializeRSPVTe((BasicSessionAttributeObject) sao, byteBuf);
} else if (sao instanceof SessionAttributeObjectWithResourcesAffinities) {
registry.serializeRSPVTe((SessionAttributeObjectWithResourcesAffinities) sao, byteBuf);
}
final ExplicitRouteObject ero = teLspAttribute.getExplicitRouteObject();
registry.serializeRSPVTe(ero, byteBuf);
final RecordRouteObject rro = teLspAttribute.getRecordRouteObject();
registry.serializeRSPVTe(rro, byteBuf);
final FastRerouteObject fro = teLspAttribute.getFastRerouteObject();
if (fro instanceof BasicFastRerouteObject) {
registry.serializeRSPVTe((BasicFastRerouteObject) fro, byteBuf);
} else if (fro instanceof LegacyFastRerouteObject) {
registry.serializeRSPVTe((LegacyFastRerouteObject) fro, byteBuf);
}
final DetourObject dto = teLspAttribute.getDetourObject();
if (dto instanceof Ipv4DetourObject) {
registry.serializeRSPVTe((Ipv4DetourObject) dto, byteBuf);
} else if (dto instanceof Ipv6DetourObject) {
registry.serializeRSPVTe((Ipv6DetourObject) dto, byteBuf);
}
final ExcludeRouteObject exro = teLspAttribute.getExcludeRouteObject();
registry.serializeRSPVTe(exro, byteBuf);
final SecondaryExplicitRouteObject sero = teLspAttribute.getSecondaryExplicitRouteObject();
registry.serializeRSPVTe(sero, byteBuf);
final SecondaryRecordRouteObject srro = teLspAttribute.getSecondaryRecordRouteObject();
registry.serializeRSPVTe(srro, byteBuf);
final LspAttributesObject lspAtt = teLspAttribute.getLspAttributesObject();
registry.serializeRSPVTe(lspAtt, byteBuf);
final LspRequiredAttributesObject rao = teLspAttribute.getLspRequiredAttributesObject();
registry.serializeRSPVTe(rao, byteBuf);
final ProtectionObject po = teLspAttribute.getProtectionObject();
if (po instanceof DynamicControlProtectionObject) {
registry.serializeRSPVTe((DynamicControlProtectionObject) po, byteBuf);
} else if (po instanceof BasicProtectionObject) {
registry.serializeRSPVTe((BasicProtectionObject) po, byteBuf);
}
final AssociationObject aso = teLspAttribute.getAssociationObject();
registry.serializeRSPVTe(aso, byteBuf);
final PrimaryPathRouteObject ppr = teLspAttribute.getPrimaryPathRouteObject();
registry.serializeRSPVTe(ppr, byteBuf);
final AdminStatusObject adso = teLspAttribute.getAdminStatusObject();
registry.serializeRSPVTe(adso, byteBuf);
final BandwidthObject bo = teLspAttribute.getBandwidthObject();
if (bo instanceof BasicBandwidthObject) {
registry.serializeRSPVTe((BasicBandwidthObject) bo, byteBuf);
} else if (bo instanceof ReoptimizationBandwidthObject) {
registry.serializeRSPVTe((ReoptimizationBandwidthObject) bo, byteBuf);
}
final MetricObject mo = teLspAttribute.getMetricObject();
registry.serializeRSPVTe(mo, byteBuf);
output.writeShort(MAGIC_NUMBER);
output.writeShort(byteBuf.readableBytes());
output.writeBytes(byteBuf);
LOG.trace("Finished serializing TE LSP Objects");
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.association.object.AssociationObject in project bgpcep by opendaylight.
the class AdminStatusObjectParser method localSerializeObject.
@Override
protected void localSerializeObject(final RsvpTeObject teLspObject, final ByteBuf output) {
Preconditions.checkArgument(teLspObject instanceof AdminStatusObject, "AssociationObject is mandatory.");
final AdminStatusObject addObject = (AdminStatusObject) teLspObject;
serializeAttributeHeader(BODY_SIZE, CLASS_NUM, CTYPE, output);
final BitArray reflect = new BitArray(FLAGS_SIZE);
reflect.set(REFLECT, addObject.isReflect());
reflect.toByteBuf(output);
output.writeZero(ByteBufWriteUtil.SHORT_BYTES_LENGTH);
final BitArray flags = new BitArray(FLAGS_SIZE);
flags.set(TESTING, addObject.isTesting());
flags.set(DOWN, addObject.isAdministrativelyDown());
flags.set(DELETION, addObject.isDeletionInProgress());
flags.toByteBuf(output);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.association.object.AssociationObject in project bgpcep by opendaylight.
the class LinkstateAttributeParserTest method testPositiveTELspAttribute.
@Test
public void testPositiveTELspAttribute() throws BGPParsingException {
final AttributesBuilder builder = createBuilder(new TeLspCaseBuilder().build());
this.parser.parseAttribute(Unpooled.copiedBuffer(TE_LSP_ATTR), builder);
final Attributes1 attrs = builder.getAugmentation(Attributes1.class);
final TeLspAttributes teLspAttributes = ((TeLspAttributesCase) attrs.getLinkStateAttribute()).getTeLspAttributes();
assertNotNull(teLspAttributes);
final TspecObject tSpec = teLspAttributes.getTspecObject();
assertNotNull(tSpec);
assertEquals(new Float32(new byte[] { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01 }), tSpec.getTokenBucketRate());
assertEquals(new Float32(new byte[] { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x02 }), teLspAttributes.getTspecObject().getTokenBucketSize());
assertEquals(new Float32(new byte[] { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x03 }), tSpec.getPeakDataRate());
assertEquals(new Long("4"), tSpec.getMinimumPolicedUnit());
assertEquals(new Long("5"), tSpec.getMaximumPacketSize());
final AssociationObject associationObject = teLspAttributes.getAssociationObject();
assertEquals(AssociationType.Recovery, associationObject.getAssociationType());
final IpAddress ipv4 = new IpAddress(Ipv4Util.addressForByteBuf(Unpooled.copiedBuffer(new byte[] { 0x01, 0x02, 0x03, 0x04 })));
assertEquals(ipv4, associationObject.getIpAddress());
final short associationId = 2;
assertEquals(associationId, associationObject.getAssociationId().shortValue());
// serialization
final ByteBuf buff = Unpooled.buffer();
this.parser.serializeAttribute(builder.build(), buff);
assertArrayEquals(TE_LSP_ATTR, ByteArray.getAllBytes(buff));
assertTrue(Arrays.equals(TE_LSP_ATTR, ByteArray.getAllBytes(buff)));
}
Aggregations