Fix junit dependencies in poms. Reuse existing from parent,
[bgpcep.git] / bgp / parser-impl / src / main / java / org / opendaylight / protocol / bgp / parser / impl / message / open / GracefulCapabilityHandler.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.protocol.bgp.parser.impl.message.open;
9
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.rev130918.open.bgp.parameters.CParameters;
13
14 final class GracefulCapabilityHandler implements CapabilitySerializer {
15         static final int CODE = 64;
16
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
22
23         @Override
24         public byte[] serializeCapability(final CParameters capability) {
25                 final byte[] bytes = null;
26
27                 // final GracefulCapability param = (GracefulCapability) capability;
28                 // final byte[] bytes = new byte[(RESTART_FLAGS_SIZE + TIMER_SIZE + (AFI_SIZE * Byte.SIZE + SAFI_SIZE * Byte.SIZE +
29                 // AF_FLAGS_SIZE
30                 // * Byte.SIZE)
31                 // * param.getTableTypes().size())
32                 // / Byte.SIZE];
33                 // if (param.isRestartFlag()) {
34                 // bytes[0] = (byte) 0x80;
35                 // }
36                 // int index = (RESTART_FLAGS_SIZE + TIMER_SIZE) / Byte.SIZE;
37                 // for (final Entry<BGPTableType, Boolean> entry : param.getTableTypes().entrySet()) {
38                 // final byte[] a = putAfi(entry.getKey().getAddressFamily());
39                 // final byte s = putSafi(entry.getKey().getSubsequentAddressFamily());
40                 // final byte f = (entry.getValue()) ? (byte) 0x80 : (byte) 0x00;
41                 // System.arraycopy(a, 0, bytes, index, AFI_SIZE);
42                 // index += AFI_SIZE;
43                 // bytes[index] = s;
44                 // index += SAFI_SIZE;
45                 // bytes[index] = f;
46                 // index += AF_FLAGS_SIZE;
47                 // }
48
49                 return CapabilityUtil.formatCapability(CODE, bytes);
50         }
51
52 }