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.parser.impl.message.update.extended.communities.four.octect.as.specific;
11 import com.google.common.base.Preconditions;
12 import io.netty.buffer.ByteBuf;
13 import org.opendaylight.protocol.bgp.parser.spi.extended.community.Abstract4OctetAsExtendedCommunity;
14 import org.opendaylight.protocol.bgp.parser.spi.extended.community.FourOctAsCommonECUtil;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.ExtendedCommunity;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.extended.community.As4RouteOriginExtendedCommunityCase;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.extended.community.As4RouteOriginExtendedCommunityCaseBuilder;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.extended.community.as._4.route.origin.extended.community._case.As4RouteOriginExtendedCommunityBuilder;
20 public final class RouteOrigin4OctectASEcHandler extends Abstract4OctetAsExtendedCommunity {
21 private static final int SUBTYPE = 3;
24 public ExtendedCommunity parseExtendedCommunity(final ByteBuf body) {
25 return new As4RouteOriginExtendedCommunityCaseBuilder()
26 .setAs4RouteOriginExtendedCommunity(new As4RouteOriginExtendedCommunityBuilder()
27 .setAs4SpecificCommon(FourOctAsCommonECUtil.parseCommon(body)).build()).build();
31 public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf body) {
32 Preconditions.checkArgument(extendedCommunity instanceof As4RouteOriginExtendedCommunityCase,
33 "The extended community %s is not As4RouteOriginExtendedCommunityCase type.",
35 FourOctAsCommonECUtil.serializeCommon(((As4RouteOriginExtendedCommunityCase) extendedCommunity)
36 .getAs4RouteOriginExtendedCommunity().getAs4SpecificCommon(), body);
40 public int getSubType() {