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
8 package org.opendaylight.protocol.bgp.linkstate.impl.attribute.sr;
10 import io.netty.buffer.ByteBuf;
11 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.prefix.state.Ipv6SrPrefix;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.prefix.state.Ipv6SrPrefixBuilder;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.Algorithm;
15 public final class Ipv6SrPrefixAttributesParser {
16 private static final int FLAGS_SIZE = 2;
18 private Ipv6SrPrefixAttributesParser() {
22 public static Ipv6SrPrefix parseSrIpv6Prefix(final ByteBuf buffer) {
23 final Ipv6SrPrefixBuilder builder = new Ipv6SrPrefixBuilder();
24 buffer.skipBytes(FLAGS_SIZE);
25 builder.setAlgorithm(Algorithm.forValue(buffer.readUnsignedByte()));
26 return builder.build();
29 public static void serializePrefixAttributes(final Algorithm algorithm, final ByteBuf buffer) {
30 buffer.writeZero(FLAGS_SIZE);
31 buffer.writeByte(algorithm.getIntValue());
34 public static void serializeIpv6SrPrefix(final Ipv6SrPrefix ipv6SrPrefix, final ByteBuf buffer) {
35 serializePrefixAttributes(ipv6SrPrefix.getAlgorithm(), buffer);