2 * Copyright (c) 2016 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
9 package org.opendaylight.protocol.bgp.linkstate.impl.attribute.sr;
12 import io.netty.buffer.ByteBuf;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.prefix.state.Ipv6SrPrefix;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.prefix.state.Ipv6SrPrefixBuilder;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.Algorithm;
17 public final class Ipv6SrPrefixAttributesParser {
18 private static final int FLAGS_SIZE = 2;
20 private Ipv6SrPrefixAttributesParser() {
21 throw new UnsupportedOperationException();
24 public static Ipv6SrPrefix parseSrIpv6Prefix(final ByteBuf buffer) {
25 final Ipv6SrPrefixBuilder builder = new Ipv6SrPrefixBuilder();
26 buffer.skipBytes(FLAGS_SIZE);
27 builder.setAlgorithm(Algorithm.forValue(buffer.readUnsignedByte()));
28 return builder.build();
31 public static void serializePrefixAttributes(final Algorithm algorithm, final ByteBuf buffer) {
32 buffer.writeZero(FLAGS_SIZE);
33 buffer.writeByte(algorithm.getIntValue());
36 public static void serializeIpv6SrPrefix(final Ipv6SrPrefix ipv6SrPrefix, final ByteBuf buffer) {
37 serializePrefixAttributes(ipv6SrPrefix.getAlgorithm(), buffer);