2 * Copyright (c) 2014 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.pcep.spi;
10 import io.netty.buffer.ByteBuf;
11 import org.opendaylight.protocol.util.BitArray;
13 public final class LabelUtil {
15 private static final int FLAGS_SIZE = 8;
17 private static final int UNIDIRECTIONAL = 0;
18 private static final int GLOBAL = 7;
23 public static void formatLabel(final int type, final Boolean unidirectional, final Boolean global,
24 final ByteBuf body, final ByteBuf buffer) {
25 final BitArray reserved = new BitArray(FLAGS_SIZE);
26 reserved.set(UNIDIRECTIONAL, unidirectional);
27 reserved.set(GLOBAL, global);
28 reserved.toByteBuf(buffer);
29 buffer.writeByte(type);
30 buffer.writeBytes(body);