use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev200120.Opaque in project bgpcep by opendaylight.
the class OpaqueUtil method parseOpaque.
static Opaque parseOpaque(final ByteBuf buffer) {
final short type = buffer.readUnsignedByte();
final OpaqueValueBuilder builder = new OpaqueValueBuilder();
switch(type) {
case GENERIC_LSP_IDENTIFIER:
builder.setOpaque(buildOpaqueValue(buffer));
break;
case EXTENDED_TYPE:
buildExtended(builder, buffer);
break;
default:
final int length = buffer.readUnsignedShort();
buffer.skipBytes(length);
LOG.debug("Skipping parsing of Opaque Value {}", buffer);
return null;
}
builder.setOpaqueType(type);
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev200120.Opaque in project bgpcep by opendaylight.
the class MldpMp2mpLspParser method parse.
@Override
public TunnelIdentifier parse(final ByteBuf buffer) {
final Opaque opaque = OpaqueUtil.parseOpaque(buffer);
if (opaque == null) {
return null;
}
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.mldp.mp2mp.lsp.MldpMp2mpLsp mldpMp2mpLsp = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.mldp.mp2mp.lsp.MldpMp2mpLspBuilder(opaque).build();
return new MldpMp2mpLspBuilder().setMldpMp2mpLsp(mldpMp2mpLsp).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev200120.Opaque in project bgpcep by opendaylight.
the class OpaqueUtilTest method serializeOpaque.
@Test
public void serializeOpaque() {
final ByteBuf actualOpaque = Unpooled.buffer();
OpaqueUtil.serializeOpaque(OPAQUE, actualOpaque);
assertArrayEquals(OPAQUE_EXPECTED, ByteArray.readAllBytes(actualOpaque));
final ByteBuf actualOpaqueExt = Unpooled.buffer();
OpaqueUtil.serializeOpaque(OPAQUE_EXTENDED, actualOpaqueExt);
assertArrayEquals(OPAQUE_EXT_EXPECTED, ByteArray.readAllBytes(actualOpaqueExt));
final ByteBuf empty = Unpooled.buffer();
OpaqueUtil.serializeOpaque(new OpaqueValueBuilder().setOpaqueType(Uint8.valueOf(5)).build(), actualOpaqueExt);
assertArrayEquals(new byte[0], ByteArray.readAllBytes(empty));
final Opaque opaque = OpaqueUtil.parseOpaque(Unpooled.wrappedBuffer(OPAQUE_EXPECTED));
assertEquals(OPAQUE, opaque);
final Opaque opaqueExt = OpaqueUtil.parseOpaque(Unpooled.wrappedBuffer(OPAQUE_EXT_EXPECTED));
assertEquals(OPAQUE_EXTENDED, opaqueExt);
assertNull(OpaqueUtil.parseOpaque(Unpooled.wrappedBuffer(OPAQUE_WRONG)));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev200120.Opaque in project bgpcep by opendaylight.
the class MldpMp2mpLspParser method parse.
@Override
public MldpMp2mpLsp parse(final ByteBuf buffer) {
final Opaque opaque = OpaqueUtil.parseOpaque(buffer);
if (opaque == null) {
return null;
}
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev200120.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.mldp.mp2mp.lsp.MldpMp2mpLsp mldpMp2mpLsp = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev200120.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.mldp.mp2mp.lsp.MldpMp2mpLspBuilder(opaque).build();
return new MldpMp2mpLspBuilder().setMldpMp2mpLsp(mldpMp2mpLsp).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev200120.Opaque in project bgpcep by opendaylight.
the class CommunitiesBuilder method createExtComm.
static List<ExtendedCommunities> createExtComm(final List<String> extCom) {
final List<ExtendedCommunities> extendedCommunities = new ArrayList<>();
for (String ec : extCom) {
ExtendedCommunity community = null;
switch(ec) {
case "as-4-generic-spec-extended-community":
community = CommunitiesBuilder.as4GenSpecBuild();
break;
case "as-4-route-target-extended-community":
community = CommunitiesBuilder.as4RTBuild();
break;
case "as-4-route-origin-extended-community":
community = CommunitiesBuilder.as4ROBuild();
break;
case "route-origin":
community = CommunitiesBuilder.rOBuild();
break;
case "route-target":
community = CommunitiesBuilder.rTBuild();
break;
case "route-origin-extended-community":
community = CommunitiesBuilder.rOECBuild();
break;
case "route-target-extended-community":
community = CommunitiesBuilder.rTECBuild();
break;
case "link-bandwidth-extended-community":
community = CommunitiesBuilder.linkBandBuild();
break;
case "opaque-extended-community":
community = CommunitiesBuilder.opaqueBuild();
break;
case "inet4-specific-extended-community":
community = CommunitiesBuilder.inet4Build();
break;
case "as-specific-extended-community":
community = CommunitiesBuilder.asSpecBuild();
break;
default:
LOG.debug("Not recognized Extended Community {}", ec);
break;
}
extendedCommunities.add(new ExtendedCommunitiesBuilder().setTransitive(true).setExtendedCommunity(community).build());
}
return extendedCommunities;
}
Aggregations