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.evpn.impl.extended.communities;
10 import com.google.common.base.Preconditions;
11 import io.netty.buffer.ByteBuf;
12 import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
13 import org.opendaylight.protocol.bgp.parser.BGPParsingException;
14 import org.opendaylight.protocol.bgp.parser.spi.extended.community.AbstractOpaqueExtendedCommunity;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120._default.gateway.extended.community.DefaultGatewayExtendedCommunityBuilder;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.evpn.routes.evpn.routes.evpn.route.attributes.extended.communities.extended.community.DefaultGatewayExtendedCommunityCase;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.evpn.routes.evpn.routes.evpn.route.attributes.extended.communities.extended.community.DefaultGatewayExtendedCommunityCaseBuilder;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.extended.community.ExtendedCommunity;
20 public final class DefaultGatewayExtCom extends AbstractOpaqueExtendedCommunity {
21 private static final int SUBTYPE = 13;
22 private static final int RESERVED = 6;
25 public ExtendedCommunity parseExtendedCommunity(final ByteBuf buffer)
26 throws BGPDocumentedException, BGPParsingException {
27 Preconditions.checkArgument(buffer.readableBytes() == RESERVED,
28 "Wrong length of array of bytes. Passed: %s .", buffer.readableBytes());
29 buffer.skipBytes(RESERVED);
30 return new DefaultGatewayExtendedCommunityCaseBuilder().setDefaultGatewayExtendedCommunity(
31 new DefaultGatewayExtendedCommunityBuilder().build()).build();
35 public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf byteAggregator) {
36 Preconditions.checkArgument(extendedCommunity instanceof DefaultGatewayExtendedCommunityCase,
37 "The extended community %s is not DefaultGatewayExtendedCommunityCase type.", extendedCommunity);
38 byteAggregator.writeZero(RESERVED);
42 public int getSubType() {