use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.Attributes in project bgpcep by opendaylight.
the class UnrecognizedAttributesSerializer method serializeAttribute.
@Override
public void serializeAttribute(final Attributes attributes, final ByteBuf byteAggregator) {
final Map<UnrecognizedAttributesKey, UnrecognizedAttributes> unrecognizedAttrs = attributes.getUnrecognizedAttributes();
if (unrecognizedAttrs == null) {
return;
}
for (final UnrecognizedAttributes unrecognizedAttr : unrecognizedAttrs.values()) {
LOG.trace("Serializing unrecognized attribute of type {}", unrecognizedAttr.getType());
int flags = AttributeUtil.OPTIONAL;
if (unrecognizedAttr.getPartial()) {
flags |= AttributeUtil.PARTIAL;
}
if (unrecognizedAttr.getTransitive()) {
flags |= AttributeUtil.TRANSITIVE;
}
AttributeUtil.formatAttribute(flags, unrecognizedAttr.getType().toJava(), Unpooled.wrappedBuffer(unrecognizedAttr.getValue()), byteAggregator);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.Attributes in project bgpcep by opendaylight.
the class ClusterIdAttributeParser method serializeAttribute.
@Override
public void serializeAttribute(final Attributes pathAttributes, final ByteBuf byteAggregator) {
final ClusterId cid = pathAttributes.getClusterId();
if (cid != null) {
final List<ClusterIdentifier> cluster = cid.getCluster();
if (cluster != null && !cluster.isEmpty()) {
final ByteBuf clusterIdBuffer = Unpooled.buffer();
for (final ClusterIdentifier clusterIdentifier : cluster) {
clusterIdBuffer.writeBytes(Ipv4Util.bytesForAddress(clusterIdentifier));
}
AttributeUtil.formatAttribute(AttributeUtil.OPTIONAL, TYPE, clusterIdBuffer, byteAggregator);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.Attributes in project bgpcep by opendaylight.
the class MPUnreachAttributeParser method serializeAttribute.
@Override
public void serializeAttribute(final Attributes attribute, final ByteBuf byteAggregator) {
final AttributesUnreach pathAttributes2 = attribute.augmentation(AttributesUnreach.class);
if (pathAttributes2 != null) {
final ByteBuf unreachBuffer = Unpooled.buffer();
reg.serializeMpUnReach(pathAttributes2.getMpUnreachNlri(), unreachBuffer);
for (final NlriSerializer nlriSerializer : this.reg.getSerializers()) {
nlriSerializer.serializeAttribute(attribute, unreachBuffer);
}
AttributeUtil.formatAttribute(AttributeUtil.OPTIONAL, TYPE, unreachBuffer, byteAggregator);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.Attributes in project bgpcep by opendaylight.
the class NextHopAttributeParser method serializeAttribute.
@Override
public void serializeAttribute(final Attributes attribute, final ByteBuf byteAggregator) {
final CNextHop cNextHop = attribute.getCNextHop();
if (cNextHop != null) {
final ByteBuf nextHopBuffer = Unpooled.buffer();
NextHopUtil.serializeNextHop(cNextHop, nextHopBuffer);
AttributeUtil.formatAttribute(AttributeUtil.TRANSITIVE, TYPE, nextHopBuffer, byteAggregator);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.Attributes in project bgpcep by opendaylight.
the class BGPUpdateMessageParser method checkMandatoryAttributesPresence.
/**
* Check for presence of well known mandatory path attributes ORIGIN, AS_PATH and NEXT_HOP in Update message.
*
* @param message Update message
* @param errorHandling Error handling type
*/
private static void checkMandatoryAttributesPresence(final Update message, final RevisedErrorHandling errorHandling) throws BGPDocumentedException, BGPTreatAsWithdrawException {
requireNonNull(message, "Update message cannot be null");
final Attributes attrs = message.getAttributes();
if (message.getNlri() != null && (attrs == null || attrs.getCNextHop() == null)) {
throw reportMissingAttribute(errorHandling, "NEXT_HOP", NextHopAttributeParser.TYPE);
}
if (MessageUtil.isAnyNlriPresent(message)) {
if (attrs == null || attrs.getOrigin() == null) {
throw reportMissingAttribute(errorHandling, "ORIGIN", OriginAttributeParser.TYPE);
}
if (attrs.getAsPath() == null) {
throw reportMissingAttribute(errorHandling, "AS_PATH", AsPathAttributeParser.TYPE);
}
}
}
Aggregations