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.rev180329.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.rev180329.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.rev180329.mac.mobility.extended.community.MacMobilityExtendedCommunity;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.mac.mobility.extended.community.MacMobilityExtendedCommunityBuilder;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.ExtendedCommunity;
20 public final class MACMobExtCom extends AbstractExtendedCommunities {
21 private static final int SUBTYPE = 0;
22 private static final int RESERVED = 1;
25 public ExtendedCommunity parseExtendedCommunity(final ByteBuf buffer)
26 throws BGPDocumentedException, BGPParsingException {
27 final boolean isStatic = buffer.readBoolean();
28 buffer.skipBytes(RESERVED);
29 final long seqNumber = buffer.readUnsignedInt();
30 return new MacMobilityExtendedCommunityCaseBuilder()
31 .setMacMobilityExtendedCommunity(new MacMobilityExtendedCommunityBuilder()
32 .setStatic(isStatic).setSeqNumber(seqNumber).build()).build();
36 public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf byteAggregator) {
37 Preconditions.checkArgument(extendedCommunity instanceof MacMobilityExtendedCommunityCase,
38 "The extended community %s is not MacMobilityExtendedCommunityCase type.", extendedCommunity);
39 final MacMobilityExtendedCommunity extCom = ((MacMobilityExtendedCommunityCase) extendedCommunity)
40 .getMacMobilityExtendedCommunity();
41 byteAggregator.writeBoolean(extCom.isStatic());
42 byteAggregator.writeZero(RESERVED);
43 byteAggregator.writeInt(extCom.getSeqNumber().intValue());
47 public int getSubType() {