2 * Copyright (c) 2016 Brocade Communications Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.protocol.bgp.parser.impl.message.update;
11 import io.netty.buffer.ByteBuf;
12 import io.netty.buffer.Unpooled;
13 import java.util.List;
14 import org.opendaylight.protocol.bgp.parser.spi.AttributeSerializer;
15 import org.opendaylight.protocol.bgp.parser.spi.AttributeUtil;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.Attributes;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.UnrecognizedAttributes;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
21 public class UnrecognizedAttributesSerializer implements AttributeSerializer {
22 private static final Logger LOG = LoggerFactory.getLogger(UnrecognizedAttributesSerializer.class);
25 public void serializeAttribute(final Attributes attributes, final ByteBuf byteAggregator) {
26 final List<UnrecognizedAttributes> unrecognizedAttrs = attributes.getUnrecognizedAttributes();
27 if (unrecognizedAttrs == null) {
30 for (final UnrecognizedAttributes unrecognizedAttr : unrecognizedAttrs) {
31 LOG.trace("Serializing unrecognized attribute of type {}", unrecognizedAttr.getType());
32 int flags = AttributeUtil.OPTIONAL;
33 if (unrecognizedAttr.isPartial()) {
34 flags |= AttributeUtil.PARTIAL;
36 if (unrecognizedAttr.isTransitive()) {
37 flags |= AttributeUtil.TRANSITIVE;
39 AttributeUtil.formatAttribute(flags, unrecognizedAttr.getType().toJava(),
40 Unpooled.wrappedBuffer(unrecognizedAttr.getValue()), byteAggregator);