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
9 package org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier;
11 import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.PAddressPMulticastGroupUtil.parseIpAddress;
12 import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.PAddressPMulticastGroupUtil.serializeIpAddress;
14 import com.google.common.base.Preconditions;
15 import io.netty.buffer.ByteBuf;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.TunnelIdentifier;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.IngressReplication;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.IngressReplicationBuilder;
20 final class IngressReplicationParser implements TunnelIdentifierSerializer, TunnelIdentifierParser {
22 public int serialize(final TunnelIdentifier tunnelIdentifier, final ByteBuf buffer) {
23 Preconditions.checkArgument(tunnelIdentifier instanceof IngressReplication,
24 "The tunnelIdentifier %s is not IngressReplication type.", tunnelIdentifier);
25 final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi
26 .tunnel.tunnel.identifier.ingress.replication.IngressReplication ingressReplication =
27 ((IngressReplication) tunnelIdentifier).getIngressReplication();
28 serializeIpAddress(ingressReplication.getReceivingEndpointAddress(), buffer);
29 return TunnelType.INGRESS_REPLICATION.getIntValue();
33 public TunnelIdentifier parse(final ByteBuf buffer) {
34 final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi
35 .tunnel.tunnel.identifier.ingress.replication.IngressReplication builder =
36 new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel
37 .pmsi.tunnel.tunnel.identifier.ingress.replication.IngressReplicationBuilder()
38 .setReceivingEndpointAddress(parseIpAddress(buffer.readableBytes(), buffer)).build();
39 return new IngressReplicationBuilder().setIngressReplication(builder).build();