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.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.evpn.routes.evpn.routes.evpn.route.attributes.extended.communities.extended.community.MacMobilityExtendedCommunityCase;
15 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.MacMobilityExtendedCommunityCaseBuilder;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.mac.mobility.extended.community.MacMobilityExtendedCommunity;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.mac.mobility.extended.community.MacMobilityExtendedCommunityBuilder;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.extended.community.ExtendedCommunity;
19 import org.opendaylight.yangtools.yang.common.netty.ByteBufUtils;
21 public final class MACMobExtCom extends AbstractExtendedCommunities {
22 private static final int SUBTYPE = 0;
23 private static final int RESERVED = 1;
26 public ExtendedCommunity parseExtendedCommunity(final ByteBuf buffer)
27 throws BGPDocumentedException, BGPParsingException {
28 final boolean isStatic = buffer.readBoolean();
29 buffer.skipBytes(RESERVED);
30 return new MacMobilityExtendedCommunityCaseBuilder()
31 .setMacMobilityExtendedCommunity(new MacMobilityExtendedCommunityBuilder()
33 .setSeqNumber(ByteBufUtils.readUint32(buffer))
39 public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf byteAggregator) {
40 Preconditions.checkArgument(extendedCommunity instanceof MacMobilityExtendedCommunityCase,
41 "The extended community %s is not MacMobilityExtendedCommunityCase type.", extendedCommunity);
42 final MacMobilityExtendedCommunity extCom = ((MacMobilityExtendedCommunityCase) extendedCommunity)
43 .getMacMobilityExtendedCommunity();
44 byteAggregator.writeBoolean(extCom.getStatic());
45 byteAggregator.writeZero(RESERVED);
46 byteAggregator.writeInt(extCom.getSeqNumber().intValue());
50 public int getSubType() {