2 * Copyright (c) 2013 Cisco 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
8 package org.opendaylight.protocol.bgp.linkstate.spi;
10 import io.netty.buffer.ByteBuf;
11 import io.netty.buffer.ByteBufUtil;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.linkstate.object.type.prefix._case.PrefixDescriptors;
13 import org.opendaylight.yangtools.yang.common.QName;
14 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
15 import org.slf4j.Logger;
16 import org.slf4j.LoggerFactory;
18 public final class TlvUtil {
20 public static final int TOPOLOGY_ID_OFFSET = 0x3fff;
21 public static final int MULTI_TOPOLOGY_ID = 263;
22 public static final NodeIdentifier MULTI_TOPOLOGY_NID = new NodeIdentifier(QName.create(PrefixDescriptors.QNAME, "topology-identifier").intern());
23 public static final int LOCAL_IPV4_ROUTER_ID = 1028;
24 public static final int LOCAL_IPV6_ROUTER_ID = 1029;
25 private static final Logger LOG = LoggerFactory.getLogger(TlvUtil.class);
27 throw new UnsupportedOperationException();
31 * Util method for writing TLV header.
33 * @param type TLV type (2B)
34 * @param value TLV value (2B)
35 * @param byteAggregator final ByteBuf where the tlv should be serialized
37 public static void writeTLV(final int type, final ByteBuf value, final ByteBuf byteAggregator) {
38 byteAggregator.writeShort(type);
39 byteAggregator.writeShort(value.writerIndex());
40 byteAggregator.writeBytes(value);
41 if (LOG.isDebugEnabled()) {
43 LOG.debug("Serialized tlv type {} to: {}", type, ByteBufUtil.hexDump(value));