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.util.ByteArray;
13 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.IetfYangUtil;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.es._import.route.extended.community.EsImportRouteExtendedCommunityBuilder;
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.EsImportRouteExtendedCommunityCase;
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.EsImportRouteExtendedCommunityCaseBuilder;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.extended.community.ExtendedCommunity;
19 public final class ESImpRouteTargetExtCom extends AbstractExtendedCommunities {
20 private static final int SUBTYPE = 2;
21 private static final int MAC_ADDRESS_LENGTH = 6;
24 public ExtendedCommunity parseExtendedCommunity(final ByteBuf buffer) {
25 return new EsImportRouteExtendedCommunityCaseBuilder()
26 .setEsImportRouteExtendedCommunity(new EsImportRouteExtendedCommunityBuilder()
27 .setEsImport(IetfYangUtil.macAddressFor(ByteArray.readBytes(buffer, MAC_ADDRESS_LENGTH)))
33 public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf byteAggregator) {
34 Preconditions.checkArgument(extendedCommunity instanceof EsImportRouteExtendedCommunityCase,
35 "The extended community %s is not EsImportRouteExtendedCommunityCaseCase type.",
37 final var extCom = ((EsImportRouteExtendedCommunityCase) extendedCommunity).getEsImportRouteExtendedCommunity();
38 byteAggregator.writeBytes(IetfYangUtil.macAddressBytes(extCom.getEsImport()));
42 public int getSubType() {