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() {
24 public static Inet4SpecificExtendedCommunityCommon parseCommon(final ByteBuf buffer) {
25 return new Inet4SpecificExtendedCommunityCommonBuilder()
26 .setGlobalAdministrator(Ipv4Util.addressForByteBuf(buffer))
27 .setLocalAdministrator(ByteArray.readBytes(buffer, INET_LOCAL_ADMIN_LENGTH))
31 public static void serializeCommon(final Inet4SpecificExtendedCommunityCommon extComm,
32 final ByteBuf byteAggregator) {
33 ByteBufWriteUtil.writeIpv4Address(extComm.getGlobalAdministrator(), byteAggregator);
34 byteAggregator.writeBytes(extComm.getLocalAdministrator());