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;
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.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.UnrecognizedAttributesKey;
19 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory;
22 public class UnrecognizedAttributesSerializer implements AttributeSerializer {
23 private static final Logger LOG = LoggerFactory.getLogger(UnrecognizedAttributesSerializer.class);
26 public void serializeAttribute(final Attributes attributes, final ByteBuf byteAggregator) {
27 final Map<UnrecognizedAttributesKey, UnrecognizedAttributes> unrecognizedAttrs =
28 attributes.getUnrecognizedAttributes();
29 if (unrecognizedAttrs == null) {
32 for (final UnrecognizedAttributes unrecognizedAttr : unrecognizedAttrs.values()) {
33 LOG.trace("Serializing unrecognized attribute of type {}", unrecognizedAttr.getType());
34 int flags = AttributeUtil.OPTIONAL;
35 if (unrecognizedAttr.isPartial()) {
36 flags |= AttributeUtil.PARTIAL;
38 if (unrecognizedAttr.isTransitive()) {
39 flags |= AttributeUtil.TRANSITIVE;
41 AttributeUtil.formatAttribute(flags, unrecognizedAttr.getType().toJava(),
42 Unpooled.wrappedBuffer(unrecognizedAttr.getValue()), byteAggregator);