Mass-convert all compontents to use -no-zone addresses
[bgpcep.git] / bgp / extensions / evpn / src / main / java / org / opendaylight / protocol / bgp / evpn / impl / nlri / MACIpAdvRParser.java
index 87e38b1f5ee3c48974360d2cc9a9f61e569868c7..e18d218663e43e5d6354f1ab6edfb199d85664f6 100644 (file)
@@ -21,10 +21,9 @@ import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import org.opendaylight.protocol.bgp.evpn.spi.pojo.SimpleEsiTypeRegistry;
 import org.opendaylight.protocol.util.ByteArray;
-import org.opendaylight.protocol.util.ByteBufWriteUtil;
 import org.opendaylight.protocol.util.Ipv4Util;
 import org.opendaylight.protocol.util.Ipv6Util;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.IetfYangUtil;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.NlriType;
@@ -51,7 +50,7 @@ final class MACIpAdvRParser extends AbstractEvpnNlri {
         final EthernetTagId eti = new EthernetTagIdBuilder().setVlanId(ByteBufUtils.readUint32(buffer)).build();
         buffer.skipBytes(1);
         final MacAddress mac = IetfYangUtil.INSTANCE.macAddressFor(ByteArray.readBytes(buffer, MAC_ADDRESS_LENGTH));
-        final IpAddress ip = parseIp(buffer);
+        final IpAddressNoZone ip = parseIp(buffer);
         final MplsLabel label1 = mplsLabelForByteBuf(buffer);
         MplsLabel label2;
         if (buffer.readableBytes() > 0) {
@@ -81,11 +80,11 @@ final class MACIpAdvRParser extends AbstractEvpnNlri {
         if (esi != null) {
             SimpleEsiTypeRegistry.getInstance().serializeEsi(evpn.getEsi(), body);
         }
-        ByteBufWriteUtil.writeUnsignedInt(evpn.getEthernetTagId().getVlanId(), body);
+        ByteBufUtils.writeOrZero(body, evpn.getEthernetTagId().getVlanId());
 
         final MacAddress mac = evpn.getMacAddress();
         body.writeByte(MAC_ADDRESS_LENGTH * BITS_SIZE);
-        body.writeBytes(IetfYangUtil.INSTANCE.bytesFor(mac));
+        body.writeBytes(IetfYangUtil.INSTANCE.macAddressBytes(mac));
         final ByteBuf ipAddress = serializeIp(evpn.getIpAddress());
         Preconditions.checkArgument(ipAddress.readableBytes() > 0);
         body.writeBytes(ipAddress);
@@ -122,15 +121,15 @@ final class MACIpAdvRParser extends AbstractEvpnNlri {
         return builder;
     }
 
-    private static ByteBuf serializeIp(final IpAddress ipAddress) {
+    private static ByteBuf serializeIp(final IpAddressNoZone ipAddress) {
         final ByteBuf body = Unpooled.buffer();
         if (ipAddress != null) {
-            if (ipAddress.getIpv4Address() != null) {
+            if (ipAddress.getIpv4AddressNoZone() != null) {
                 body.writeByte(Ipv4Util.IP4_BITS_LENGTH);
-                body.writeBytes(Ipv4Util.bytesForAddress(ipAddress.getIpv4Address()));
-            } else if (ipAddress.getIpv6Address() != null) {
+                body.writeBytes(Ipv4Util.bytesForAddress(ipAddress.getIpv4AddressNoZone()));
+            } else if (ipAddress.getIpv6AddressNoZone() != null) {
                 body.writeByte(Ipv6Util.IPV6_BITS_LENGTH);
-                body.writeBytes(Ipv6Util.bytesForAddress(ipAddress.getIpv6Address()));
+                body.writeBytes(Ipv6Util.bytesForAddress(ipAddress.getIpv6AddressNoZone()));
             } else {
                 body.writeByte(0);
             }
@@ -140,12 +139,12 @@ final class MACIpAdvRParser extends AbstractEvpnNlri {
         return body;
     }
 
-    private static IpAddress parseIp(final ByteBuf buffer) {
+    private static IpAddressNoZone parseIp(final ByteBuf buffer) {
         final int ipLength = buffer.readUnsignedByte();
         if (ipLength == Ipv6Util.IPV6_BITS_LENGTH) {
-            return new IpAddress(Ipv6Util.addressForByteBuf(buffer));
+            return new IpAddressNoZone(Ipv6Util.addressForByteBuf(buffer));
         } else if (ipLength == Ipv4Util.IP4_BITS_LENGTH) {
-            return new IpAddress(Ipv4Util.addressForByteBuf(buffer));
+            return new IpAddressNoZone(Ipv4Util.addressForByteBuf(buffer));
         }
         return null;
     }