2 * Copyright (c) 2018 AT&T Intellectual Property. 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.spi.extended.community;
10 import static org.opendaylight.protocol.bgp.parser.spi.extended.community.AbstractIpv4ExtendedCommunity.INET_LOCAL_ADMIN_LENGTH;
12 import io.netty.buffer.ByteBuf;
13 import org.opendaylight.protocol.util.ByteArray;
14 import org.opendaylight.protocol.util.ByteBufWriteUtil;
15 import org.opendaylight.protocol.util.Ipv4Util;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.inet4.specific.extended.community.common.Inet4SpecificExtendedCommunityCommon;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.inet4.specific.extended.community.common.Inet4SpecificExtendedCommunityCommonBuilder;
19 public final class Inet4SpecificExtendedCommunityCommonUtil {
20 private Inet4SpecificExtendedCommunityCommonUtil() {
21 throw new UnsupportedOperationException();
25 public static Inet4SpecificExtendedCommunityCommon parseCommon(final ByteBuf buffer) {
26 return new Inet4SpecificExtendedCommunityCommonBuilder()
27 .setGlobalAdministrator(Ipv4Util.addressForByteBuf(buffer))
28 .setLocalAdministrator(ByteArray.readBytes(buffer, INET_LOCAL_ADMIN_LENGTH))
32 public static void serializeCommon(
33 final Inet4SpecificExtendedCommunityCommon extComm,
34 final ByteBuf byteAggregator) {
35 ByteBufWriteUtil.writeIpv4Address(extComm.getGlobalAdministrator(), byteAggregator);
36 byteAggregator.writeBytes(extComm.getLocalAdministrator());