use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Community in project bgpcep by opendaylight.
the class CommunitiesAttributeParser method serializeAttribute.
@Override
public void serializeAttribute(final Attributes pathAttributes, final ByteBuf byteAggregator) {
final List<Communities> communities = pathAttributes.getCommunities();
if (communities == null || communities.isEmpty()) {
return;
}
final ByteBuf communitiesBuffer = Unpooled.buffer();
for (final Community community : communities) {
communitiesBuffer.writeShort(community.getAsNumber().getValue().shortValue());
communitiesBuffer.writeShort(community.getSemantics().shortValue());
}
AttributeUtil.formatAttribute(AttributeUtil.OPTIONAL | AttributeUtil.TRANSITIVE, TYPE, communitiesBuffer, byteAggregator);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Community in project bgpcep by opendaylight.
the class AsTwoOctetSpecificEcHandler method serializeExtendedCommunity.
@Override
public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf byteAggregator) {
Preconditions.checkArgument(extendedCommunity instanceof AsSpecificExtendedCommunityCase, "The extended community %s is not AsSpecificExtendedCommunity type.", extendedCommunity);
final AsSpecificExtendedCommunity asSpecific = ((AsSpecificExtendedCommunityCase) extendedCommunity).getAsSpecificExtendedCommunity();
byteAggregator.writeShort(asSpecific.getGlobalAdministrator().getValue().intValue());
byteAggregator.writeBytes(asSpecific.getLocalAdministrator());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Community in project bgpcep by opendaylight.
the class OpaqueEcHandler method serializeExtendedCommunity.
@Override
public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf byteAggregator) {
Preconditions.checkArgument(extendedCommunity instanceof OpaqueExtendedCommunityCase, "The extended community %s is not OpaqueExtendedCommunityCase type.", extendedCommunity);
final OpaqueExtendedCommunity opaqueExtendedCommunity = ((OpaqueExtendedCommunityCase) extendedCommunity).getOpaqueExtendedCommunity();
byteAggregator.writeBytes(opaqueExtendedCommunity.getValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Community 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