+ @Override
+ public void parseAttribute(final ByteBuf buffer, final AttributesBuilder builder,
+ final RevisedErrorHandling errorHandling, final PeerSpecificParserConstraint constraint)
+ throws BGPDocumentedException, BGPTreatAsWithdrawException {
+ builder.setAsPath(parseAsPath(refCache, buffer, errorHandling));
+ }
+
+ @Override
+ public void serializeAttribute(final Attributes pathAttributes, final ByteBuf byteAggregator) {
+ final AsPath asPath = pathAttributes.getAsPath();
+ if (asPath == null) {
+ return;
+ }
+ final ByteBuf segmentsBuffer = Unpooled.buffer();
+ if (asPath.getSegments() != null) {
+ for (final Segments segments : asPath.getSegments()) {
+ if (segments.getAsSequence() != null) {
+ AsPathSegmentParser.serializeAsList(segments.getAsSequence(), SegmentType.AS_SEQUENCE,
+ segmentsBuffer);
+ } else if (segments.getAsSet() != null) {
+ AsPathSegmentParser.serializeAsList(segments.getAsSet(), SegmentType.AS_SET, segmentsBuffer);
+ } else {
+ LOG.warn("Segment doesn't have AsSequence nor AsSet list.");
+ }
+ }
+ }
+ AttributeUtil.formatAttribute(AttributeUtil.TRANSITIVE, TYPE, segmentsBuffer, byteAggregator);
+ }
+