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.route.target;
11 import com.google.common.base.Preconditions;
12 import io.netty.buffer.ByteBuf;
13 import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
14 import org.opendaylight.protocol.bgp.parser.BGPParsingException;
15 import org.opendaylight.protocol.bgp.parser.spi.extended.community.Abstract4OctetAsExtendedCommunity;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.ExtendedCommunity;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.extended.community.As4RouteTargetExtendedCommunityCase;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.extended.community.As4RouteTargetExtendedCommunityCaseBuilder;
20 public final class RouteTarget4OctectASEcHandler extends Abstract4OctetAsExtendedCommunity {
21 private static final int SUBTYPE = 2;
24 public ExtendedCommunity parseExtendedCommunity(final ByteBuf body)
25 throws BGPDocumentedException, BGPParsingException {
26 return new As4RouteTargetExtendedCommunityCaseBuilder()
27 .setAs4RouteTargetExtendedCommunity(As4RouteTargetExtendedHandler.parse(body)).build();
31 public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf body) {
32 Preconditions.checkArgument(extendedCommunity instanceof As4RouteTargetExtendedCommunityCase,
33 "The extended community %s is not As4RouteTargetExtendedCommunityCase type.",
35 As4RouteTargetExtendedHandler.serialize(((As4RouteTargetExtendedCommunityCase) extendedCommunity)
36 .getAs4RouteTargetExtendedCommunity(), body);
40 public int getSubType() {