2 * Copyright (c) 2018 AT&T Intellectual Property. 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.parser.impl.message.update.extended.communities.route.target;
11 import io.netty.buffer.ByteBuf;
12 import org.opendaylight.yangtools.yang.common.netty.ByteBufUtils;
13 import org.opendaylight.protocol.util.ByteBufWriteUtil;
14 import org.opendaylight.protocol.util.Ipv4Util;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.route.target.ipv4.grouping.RouteTargetIpv4;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.route.target.ipv4.grouping.RouteTargetIpv4Builder;
19 * Route Target Ipv4 Handler.
21 * @author Claudio D. Gasparini
23 public final class RouteTargetIpv4Handler {
24 private RouteTargetIpv4Handler() {
25 throw new UnsupportedOperationException();
28 public static void serialize(final RouteTargetIpv4 routeTarget, final ByteBuf byteAggregator) {
29 ByteBufWriteUtil.writeIpv4Address(routeTarget.getGlobalAdministrator(), byteAggregator);
30 ByteBufWriteUtil.writeUnsignedShort(routeTarget.getLocalAdministrator(), byteAggregator);
33 public static RouteTargetIpv4 parse(final ByteBuf buffer) {
34 return new RouteTargetIpv4Builder()
35 .setGlobalAdministrator(Ipv4Util.addressForByteBuf(buffer))
36 .setLocalAdministrator(ByteBufUtils.readUint16(buffer))