@Override public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) { Preconditions.checkArgument(attribute instanceof Attributes, "Attribute parameter is not a PathAttribute object."); final Attributes pathAttributes = (Attributes) attribute; final Attributes1 pathAttributes1 = pathAttributes.getAugmentation(Attributes1.class); if (pathAttributes1 == null) { return; } final MpReachNlri mpReachNlri = pathAttributes1.getMpReachNlri(); final ByteBuf reachBuffer = Unpooled.buffer(); this.reg.serializeMpReach(mpReachNlri, reachBuffer); for (final NlriSerializer nlriSerializer : this.reg.getSerializers()) { nlriSerializer.serializeAttribute(attribute, reachBuffer); } AttributeUtil.formatAttribute(AttributeUtil.OPTIONAL, TYPE, reachBuffer, byteAggregator); } }
@Override public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) { Preconditions.checkArgument(attribute instanceof Attributes, "Attribute parameter is not a PathAttribute object."); final Attributes pathAttributes = (Attributes) attribute; final Attributes2 pathAttributes2 = pathAttributes.getAugmentation(Attributes2.class); if (pathAttributes2 == null) { return; } final MpUnreachNlri mpUnreachNlri = pathAttributes2.getMpUnreachNlri(); final ByteBuf unreachBuffer = Unpooled.buffer(); this.reg.serializeMpUnReach(mpUnreachNlri, unreachBuffer); for (final NlriSerializer nlriSerializer : this.reg.getSerializers()){ nlriSerializer.serializeAttribute(attribute,unreachBuffer); } AttributeUtil.formatAttribute(AttributeUtil.OPTIONAL, TYPE, unreachBuffer, byteAggregator); } }
@Override public void parseAttribute(final ByteBuf buffer, final AttributesBuilder builder, final PeerSpecificParserConstraint constraint) throws BGPDocumentedException { try { final MpReachNlri mpReachNlri = this.reg.parseMpReach(buffer, constraint); final Attributes1 a = new Attributes1Builder().setMpReachNlri(mpReachNlri).build(); builder.addAugmentation(Attributes1.class, a); } catch (final BGPParsingException e) { throw new BGPDocumentedException("Could not parse MP_REACH_NLRI", BGPError.OPT_ATTR_ERROR, e); } }
@Override public void parseAttribute(final ByteBuf buffer, final AttributesBuilder builder, final PeerSpecificParserConstraint constraint) throws BGPDocumentedException { try { final MpUnreachNlri mpUnreachNlri = this.reg.parseMpUnreach(buffer, constraint); final Attributes2 a = new Attributes2Builder().setMpUnreachNlri(mpUnreachNlri).build(); builder.addAugmentation(Attributes2.class, a); } catch (final BGPParsingException e) { throw new BGPDocumentedException("Could not parse MP_UNREACH_NLRI", BGPError.OPT_ATTR_ERROR, e); } }