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.impl.message.open;
10 import org.opendaylight.protocol.bgp.parser.spi.CapabilitySerializer;
11 import org.opendaylight.protocol.bgp.parser.spi.CapabilityUtil;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.open.bgp.parameters.CParameters;
14 final class GracefulCapabilityHandler implements CapabilitySerializer {
15 static final int CODE = 64;
17 private static final int RESTART_FLAGS_SIZE = 4; // bits
18 private static final int TIMER_SIZE = 12; // bits
19 private static final int AFI_SIZE = 2; // bytes
20 private static final int SAFI_SIZE = 1; // bytes
21 private static final int AF_FLAGS_SIZE = 1; // bytes
24 public byte[] serializeCapability(final CParameters capability) {
25 final byte[] bytes = null;
27 // final GracefulCapability param = (GracefulCapability) capability;
28 // final byte[] bytes = new byte[(RESTART_FLAGS_SIZE + TIMER_SIZE + (AFI_SIZE * Byte.SIZE + SAFI_SIZE *
32 // * param.getTableTypes().size())
34 // if (param.isRestartFlag()) {
35 // bytes[0] = (byte) 0x80;
37 // int index = (RESTART_FLAGS_SIZE + TIMER_SIZE) / Byte.SIZE;
38 // for (final Entry<BGPTableType, Boolean> entry : param.getTableTypes().entrySet()) {
39 // final byte[] a = putAfi(entry.getKey().getAddressFamily());
40 // final byte s = putSafi(entry.getKey().getSubsequentAddressFamily());
41 // final byte f = (entry.getValue()) ? (byte) 0x80 : (byte) 0x00;
42 // System.arraycopy(a, 0, bytes, index, AFI_SIZE);
45 // index += SAFI_SIZE;
47 // index += AF_FLAGS_SIZE;
50 return CapabilityUtil.formatCapability(CODE, bytes);