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.pcep.spi;
10 import io.netty.buffer.ByteBuf;
11 import org.opendaylight.protocol.util.BitArray;
13 public final class ObjectUtil {
15 private static final int HEADER_SIZE = 4;
17 private static final int FLAGS_SIZE = 4;
19 * flags offsets inside multi-field
21 private static final int PROCESSED = 2;
22 private static final int IGNORED = 3;
24 private ObjectUtil() {
27 public static void formatSubobject(final int objectType, final int objectClass, final Boolean processingRule,
28 final Boolean ignore, final ByteBuf body, final ByteBuf out) {
29 out.writeByte(objectClass);
30 final BitArray flags = new BitArray(FLAGS_SIZE);
31 flags.set(IGNORED, ignore);
32 flags.set(PROCESSED, processingRule);
33 final byte flagB = flags.toByte();
34 final int typeByte = objectType << FLAGS_SIZE | flagB & 0xff;
35 out.writeByte(typeByte);
36 out.writeShort(body.writerIndex() + HEADER_SIZE);