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.parser.spi;
10 import org.opendaylight.protocol.util.ByteArray;
12 import com.google.common.primitives.UnsignedBytes;
14 public final class CapabilityUtil {
16 private static final int HEADER_SIZE = 2;
18 private CapabilityUtil() {
22 public static byte[] formatCapability(final int code, final byte[] value) {
23 final byte[] ret = new byte[HEADER_SIZE + value.length];
24 ret[0] = UnsignedBytes.checkedCast(code);
25 ret[1] = UnsignedBytes.checkedCast(value.length);
26 ByteArray.copyWhole(value, ret, HEADER_SIZE);