YANG revision dates mass-update
[bgpcep.git] / bgp / extensions / evpn / src / main / java / org / opendaylight / protocol / bgp / evpn / impl / extended / communities / DefaultGatewayExtCom.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.protocol.bgp.evpn.impl.extended.communities;
9
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;
19
20 public final class DefaultGatewayExtCom extends AbstractOpaqueExtendedCommunity {
21     private static final int SUBTYPE = 13;
22     private static final int RESERVED = 6;
23
24     @Override
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();
32     }
33
34     @Override
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);
39     }
40
41     @Override
42     public int getSubType() {
43         return SUBTYPE;
44     }
45 }