Search in sources :

Example 1 with OriginatorId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.OriginatorId in project bgpcep by opendaylight.

the class OriginatorIdAttributeParser method serializeAttribute.

@Override
public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) {
    Preconditions.checkArgument(attribute instanceof Attributes, "Attribute parameter is not a PathAttribute object.");
    final OriginatorId originator = ((Attributes) attribute).getOriginatorId();
    if (originator == null) {
        return;
    }
    final ByteBuf originatorIdBuf = Unpooled.buffer();
    originatorIdBuf.writeBytes(Ipv4Util.bytesForAddress(originator.getOriginator()));
    AttributeUtil.formatAttribute(AttributeUtil.OPTIONAL, TYPE, originatorIdBuf, byteAggregator);
}
Also used : OriginatorId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.OriginatorId) Attributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes) ByteBuf(io.netty.buffer.ByteBuf)

Example 2 with OriginatorId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.OriginatorId in project bgpcep by opendaylight.

the class MatchOriginatorIdSetHandler method matchOriginatorCondition.

private boolean matchOriginatorCondition(final Ipv4Address localOriginatorId, final OriginatorId originatorId, final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.odl.bgp._default.policy.rev180109.match.originator.id.set.condition.grouping.MatchOriginatorIdSetCondition condition) {
    final OriginatorIdSet originatorIdSet = this.sets.getUnchecked(StringUtils.substringBetween(condition.getOriginatorIdSet(), "=\"", "\""));
    if (originatorIdSet == null) {
        return false;
    }
    boolean found = false;
    if (originatorId != null) {
        final Ipv4Address remOrigin = originatorId.getOriginator();
        if (originatorIdSet.getLocal() != null && localOriginatorId.equals(remOrigin)) {
            found = true;
        }
        if (!found && originatorIdSet.getOriginatorId() != null) {
            found = originatorIdSet.getOriginatorId().contains(remOrigin);
        }
    }
    final MatchSetOptionsRestrictedType matchOption = condition.getMatchSetOptions();
    return matchOption.equals(MatchSetOptionsRestrictedType.ANY) && found || matchOption.equals(MatchSetOptionsRestrictedType.INVERT) && !found;
}
Also used : MatchSetOptionsRestrictedType(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.policy.types.rev151009.MatchSetOptionsRestrictedType) OriginatorIdSet(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.odl.bgp._default.policy.rev180109.originator.id.set.OriginatorIdSet) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)1 MatchSetOptionsRestrictedType (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.policy.types.rev151009.MatchSetOptionsRestrictedType)1 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)1 OriginatorId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.OriginatorId)1 Attributes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes)1 OriginatorIdSet (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.odl.bgp._default.policy.rev180109.originator.id.set.OriginatorIdSet)1