use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.policy.definitions.policy.definition.statements.statement.actions.bgp.actions.set.ext.community.set.ext.community.method.Reference in project openflowplugin by opendaylight.
the class NodeConnectorRefToPortTranslator method toNodeConnectorRef.
/**
* Converts {@link PacketIn} to {@link NodeConnectorRef}.
* @param packetIn Packet input
* @param dataPathId Data path id
* @return packet input converted to node connector reference
*/
@Nullable
public static NodeConnectorRef toNodeConnectorRef(@Nonnull PacketIn packetIn, BigInteger dataPathId) {
Preconditions.checkNotNull(packetIn);
NodeConnectorRef ref = null;
Long port = getPortNoFromPacketIn(packetIn);
if (port != null) {
OpenflowVersion version = OpenflowVersion.get(packetIn.getVersion());
ref = InventoryDataServiceUtil.nodeConnectorRefFromDatapathIdPortno(dataPathId, port, version);
}
return ref;
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.policy.definitions.policy.definition.statements.statement.actions.bgp.actions.set.ext.community.set.ext.community.method.Reference in project bgpcep by opendaylight.
the class SetCommunityTest method testReferenceReplace.
@Test
public void testReferenceReplace() {
Statement statement = this.basicStatements.stream().filter(st -> st.getName().equals("set-community-reference-replace-test")).findFirst().get();
RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(new AttributesBuilder().build());
RouteAttributeContainer result = this.statementRegistry.applyExportStatement(this.baseAttributes, this.exportParameters, attributeContainer, statement);
assertEquals(this.multipleCom, result.getAttributes());
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.policy.definitions.policy.definition.statements.statement.actions.bgp.actions.set.ext.community.set.ext.community.method.Reference in project bgpcep by opendaylight.
the class SetExtCommunityTest method testReferenceAdd.
@Test
public void testReferenceAdd() {
Statement statement = this.basicStatements.stream().filter(st -> st.getName().equals("set-ext-community-reference-add-test")).findFirst().get();
RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(new AttributesBuilder().build());
RouteAttributeContainer result = this.statementRegistry.applyExportStatement(this.baseAttributes, this.exportParameters, attributeContainer, statement);
assertEquals(this.multipleExtCom, result.getAttributes());
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.policy.definitions.policy.definition.statements.statement.actions.bgp.actions.set.ext.community.set.ext.community.method.Reference in project bgpcep by opendaylight.
the class AsPathAttributeParser method parseAsPath.
/**
* Parses AS_PATH from bytes.
*
* @param refCache ReferenceCache shared reference of object
* @param buffer bytes to be parsed
* @return new ASPath object
* @throws BGPDocumentedException if there is no AS_SEQUENCE present (mandatory)
* @throws BGPParsingException
*/
private static AsPath parseAsPath(final ReferenceCache refCache, final ByteBuf buffer) throws BGPDocumentedException, BGPParsingException {
if (!buffer.isReadable()) {
return EMPTY;
}
final ArrayList<Segments> ases = new ArrayList<>();
boolean isSequence = false;
while (buffer.isReadable()) {
final int type = buffer.readUnsignedByte();
final SegmentType segmentType = AsPathSegmentParser.parseType(type);
if (segmentType == null) {
throw new BGPParsingException("AS Path segment type unknown : " + type);
}
final int count = buffer.readUnsignedByte();
final List<AsNumber> asList = AsPathSegmentParser.parseAsSegment(refCache, count, buffer.readSlice(count * AsPathSegmentParser.AS_NUMBER_LENGTH));
if (segmentType == SegmentType.AS_SEQUENCE) {
ases.add(new SegmentsBuilder().setAsSequence(asList).build());
isSequence = true;
} else {
ases.add(new SegmentsBuilder().setAsSet(asList).build());
}
}
if (!isSequence) {
throw new BGPDocumentedException("AS_SEQUENCE must be present in AS_PATH attribute.", BGPError.AS_PATH_MALFORMED);
}
ases.trimToSize();
return new AsPathBuilder().setSegments(ases).build();
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.policy.definitions.policy.definition.statements.statement.actions.bgp.actions.set.ext.community.set.ext.community.method.Reference in project bgpcep by opendaylight.
the class CommunityUtil method create.
/**
* Creates a new Community given AS number value and semantics using generated CommunitiesBuilder.
*
* @param refCache reference cache to use
* @param asn long
* @param semantics int
* @return new Community
*/
public static Community create(final ReferenceCache refCache, final long asn, final int semantics) {
final CommunitiesBuilder builder = new CommunitiesBuilder();
builder.setAsNumber(refCache.getSharedReference(new AsNumber(asn)));
builder.setSemantics(refCache.getSharedReference(semantics));
return refCache.getSharedReference(builder.build());
}
Aggregations