use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.ErrorSpec.Flags in project bgpcep by opendaylight.
the class UnnumberedEroParser method parseUnnumberedEroCase.
static UnnumberedInterfaceIdEroCase parseUnnumberedEroCase(final ByteBuf buffer) {
final UnnumberedInterfaceIdEroCaseBuilder builder = new UnnumberedInterfaceIdEroCaseBuilder();
final BitArray flags = BitArray.valueOf(buffer, Ipv4EroParser.FLAGS_SIZE);
builder.setLoose(flags.get(Ipv4EroParser.LOOSE));
buffer.skipBytes(Ipv4EroParser.RESERVED_ERO);
builder.setRouterId(buffer.readUnsignedInt());
builder.setInterfaceId(buffer.readUnsignedInt());
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.ErrorSpec.Flags in project bgpcep by opendaylight.
the class SrLinkAttributesParser method parseAdjacencySegmentIdentifier.
public static SrAdjIds parseAdjacencySegmentIdentifier(final ByteBuf buffer, final ProtocolId protocolId) {
final Flags adjFlags;
final Weight weight;
final SidLabelIndex sidValue;
if (buffer.isReadable()) {
final BitArray flags = BitArray.valueOf(buffer, FLAGS_BITS_SIZE);
adjFlags = parseFlags(flags, protocolId);
weight = new Weight(buffer.readUnsignedByte());
buffer.skipBytes(RESERVED);
sidValue = SidLabelIndexParser.parseSidLabelIndex(Size.forValue(buffer.readableBytes()), buffer);
} else {
adjFlags = null;
weight = null;
sidValue = null;
}
return new SrAdjIdsBuilder().setFlags(adjFlags).setSidLabelIndex(sidValue).setWeight(weight).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.ErrorSpec.Flags in project bgpcep by opendaylight.
the class SrLinkAttributesParser method serializeAdjFlags.
private static BitArray serializeAdjFlags(final Flags flags, final SidLabelIndex sidLabelIndex) {
final BitArray bitFlags = new BitArray(FLAGS_BITS_SIZE);
if (flags instanceof OspfAdjFlagsCase) {
final OspfAdjFlagsCase ospfFlags = (OspfAdjFlagsCase) flags;
bitFlags.set(BACKUP_OSPF, ospfFlags.isBackup());
bitFlags.set(SET_OSPF, ospfFlags.isSet());
SidLabelIndexParser.setFlags(sidLabelIndex, bitFlags, VALUE_OSPF, LOCAL_OSPF);
} else if (flags instanceof IsisAdjFlagsCase) {
final IsisAdjFlagsCase isisFlags = (IsisAdjFlagsCase) flags;
bitFlags.set(ADDRESS_FAMILY_FLAG, isisFlags.isAddressFamily());
bitFlags.set(BACKUP_ISIS, isisFlags.isBackup());
bitFlags.set(SET_ISIS, isisFlags.isSet());
SidLabelIndexParser.setFlags(sidLabelIndex, bitFlags, VALUE_ISIS, LOCAL_ISIS);
} else if (flags == null) {
SidLabelIndexParser.setFlags(sidLabelIndex, bitFlags, VALUE_EPE, LOCAL_EPE);
}
return bitFlags;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.ErrorSpec.Flags in project bgpcep by opendaylight.
the class LinkstateAttributeParserTest method testPositiveLinks.
@Test
public void testPositiveLinks() throws BGPParsingException {
final AttributesBuilder builder = createBuilder(new LinkCaseBuilder().build());
this.parser.parseAttribute(Unpooled.copiedBuffer(LINK_ATTR), builder);
final Attributes1 attrs = builder.getAugmentation(Attributes1.class);
final LinkAttributes ls = ((LinkAttributesCase) attrs.getLinkStateAttribute()).getLinkAttributes();
assertNotNull(ls);
assertEquals("42.42.42.42", ls.getLocalIpv4RouterId().getValue());
assertEquals("43.43.43.43", ls.getRemoteIpv4RouterId().getValue());
assertEquals(Long.valueOf(0L), ls.getAdminGroup().getValue());
assertArrayEquals(new byte[] { (byte) 0x49, (byte) 0x98, (byte) 0x96, (byte) 0x80 }, ls.getMaxLinkBandwidth().getValue());
assertArrayEquals(new byte[] { (byte) 0x46, (byte) 0x43, (byte) 0x50, (byte) 0x00 }, ls.getMaxReservableBandwidth().getValue());
assertNotNull(ls.getUnreservedBandwidth());
assertEquals(8, ls.getUnreservedBandwidth().size());
assertEquals(LinkProtectionType.Dedicated1to1, ls.getLinkProtection());
assertTrue(ls.getMplsProtocol().isLdp());
assertTrue(ls.getMplsProtocol().isRsvpte());
assertEquals(new Long(10), ls.getMetric().getValue());
assertEquals(2, ls.getSharedRiskLinkGroups().size());
assertEquals(305419896, ls.getSharedRiskLinkGroups().get(0).getValue().intValue());
assertEquals("12K-2", ls.getLinkName());
final IsisAdjFlagsCase flags = new IsisAdjFlagsCaseBuilder().setAddressFamily(Boolean.TRUE).setBackup(Boolean.FALSE).setSet(Boolean.FALSE).build();
assertEquals(flags, ls.getSrAdjIds().get(0).getFlags());
assertEquals(flags, ls.getSrAdjIds().get(1).getFlags());
assertEquals(new Long(1048575L), ((LocalLabelCase) ls.getSrAdjIds().get(0).getSidLabelIndex()).getLocalLabel().getValue());
assertEquals(new Long(1048559L), ((LocalLabelCase) ls.getSrAdjIds().get(1).getSidLabelIndex()).getLocalLabel().getValue());
assertEquals(new Long(168496141L), ((SidCase) ls.getPeerNodeSid().getSidLabelIndex()).getSid());
assertEquals(new Short("5"), ls.getPeerNodeSid().getWeight().getValue());
assertEquals(new Long(168496142L), ((SidCase) ls.getPeerSetSids().get(0).getSidLabelIndex()).getSid());
assertEquals(new Short("5"), ls.getPeerSetSids().get(0).getWeight().getValue());
assertEquals(new Long(168496143L), ((SidCase) ls.getPeerAdjSid().getSidLabelIndex()).getSid());
assertEquals(new Short("5"), ls.getPeerAdjSid().getWeight().getValue());
// serialization
final ByteBuf buff = Unpooled.buffer();
this.parser.serializeAttribute(builder.build(), buff);
buff.skipBytes(3);
// there is unresolved TLV at the end, that needs to be cut off
assertArrayEquals(ByteArray.subByte(LINK_ATTR, 0, LINK_ATTR.length - 5), ByteArray.getAllBytes(buff));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.ErrorSpec.Flags in project bgpcep by opendaylight.
the class ParserTest method testEORLS.
/*
* End of Rib for LS consists of empty MP_UNREACH_NLRI, with AFI 16388 and SAFI 71
*
* ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff <- marker
* 00 1d <- length (29) - including header
* 02 <- message type
* 00 00 <- withdrawn routes length
* 00 06 <- total path attribute length
* 80 <- attribute flags
* 0f <- attribute type (15 - MP_UNREACH_NLRI)
* 03 <- attribute length
* 40 04 <- value (AFI 16388: LS)
* 47 <- value (SAFI 71)
*/
@Test
public void testEORLS() throws Exception {
final byte[] body = ByteArray.cutBytes(inputBytes.get(0), MessageUtil.COMMON_HEADER_LENGTH);
final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(0), MessageUtil.MARKER_LENGTH, LENGTH_FIELD_LENGTH));
final Update message = ParserTest.updateParser.parseMessageBody(Unpooled.copiedBuffer(body), messageLength);
final Class<? extends AddressFamily> afi = message.getAttributes().getAugmentation(Attributes2.class).getMpUnreachNlri().getAfi();
final Class<? extends SubsequentAddressFamily> safi = message.getAttributes().getAugmentation(Attributes2.class).getMpUnreachNlri().getSafi();
assertEquals(LinkstateAddressFamily.class, afi);
assertEquals(LinkstateSubsequentAddressFamily.class, safi);
final ByteBuf buffer = Unpooled.buffer();
ParserTest.updateParser.serializeMessage(message, buffer);
assertArrayEquals(inputBytes.get(0), ByteArray.readAllBytes(buffer));
}
Aggregations