Mass-convert all compontents to use -no-zone addresses
[bgpcep.git] / pcep / ietf-stateful07 / src / main / java / org / opendaylight / protocol / pcep / ietf / stateful07 / Stateful07LSPIdentifierIpv6TlvParser.java
index 64346aef77578431ff54fa29d3d9d3514f3f5f02..462b7027c5bdfbf391f6df524c9aa2bc28f514d8 100644 (file)
@@ -8,9 +8,6 @@
 package org.opendaylight.protocol.pcep.ietf.stateful07;
 
 import static com.google.common.base.Preconditions.checkArgument;
-import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeIpv6Address;
-import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeShort;
-import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedShort;
 
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
@@ -30,12 +27,13 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.Ipv6ExtendedTunnelId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.LspId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.TunnelId;
+import org.opendaylight.yangtools.yang.common.Uint32;
+import org.opendaylight.yangtools.yang.common.netty.ByteBufUtils;
 
 /**
  * Parser for {@link LspIdentifiers}.
  */
 public final class Stateful07LSPIdentifierIpv6TlvParser implements TlvParser, TlvSerializer {
-
     public static final int TYPE = 19;
 
     private static final int V6_LENGTH = 52;
@@ -48,11 +46,11 @@ public final class Stateful07LSPIdentifierIpv6TlvParser implements TlvParser, Tl
         checkArgument(buffer.readableBytes() == V6_LENGTH, "Length %s does not match LSP Identifiers Ipv6 tlv length.",
                 buffer.readableBytes());
         final Ipv6Builder builder = new Ipv6Builder();
-        builder.setIpv6TunnelSenderAddress(Ipv6Util.noZoneAddressForByteBuf(buffer));
-        final LspId lspId = new LspId((long) buffer.readUnsignedShort());
-        final TunnelId tunnelId = new TunnelId(buffer.readUnsignedShort());
-        builder.setIpv6ExtendedTunnelId(new Ipv6ExtendedTunnelId(Ipv6Util.noZoneAddressForByteBuf(buffer)));
-        builder.setIpv6TunnelEndpointAddress(Ipv6Util.noZoneAddressForByteBuf(buffer));
+        builder.setIpv6TunnelSenderAddress(Ipv6Util.addressForByteBuf(buffer));
+        final LspId lspId = new LspId(Uint32.valueOf(buffer.readUnsignedShort()));
+        final TunnelId tunnelId = new TunnelId(ByteBufUtils.readUint16(buffer));
+        builder.setIpv6ExtendedTunnelId(new Ipv6ExtendedTunnelId(Ipv6Util.addressForByteBuf(buffer)));
+        builder.setIpv6TunnelEndpointAddress(Ipv6Util.addressForByteBuf(buffer));
         final AddressFamily afi = new Ipv6CaseBuilder().setIpv6(builder.build()).build();
         return new LspIdentifiersBuilder().setAddressFamily(afi).setLspId(lspId).setTunnelId(tunnelId).build();
     }
@@ -64,15 +62,18 @@ public final class Stateful07LSPIdentifierIpv6TlvParser implements TlvParser, Tl
         final ByteBuf body = Unpooled.buffer();
         final Ipv6 ipv6 = ((Ipv6Case) lsp.getAddressFamily()).getIpv6();
         checkArgument(ipv6.getIpv6TunnelSenderAddress() != null, "Ipv6TunnelSenderAddress is mandatory.");
-        writeIpv6Address(ipv6.getIpv6TunnelSenderAddress(), body);
-        checkArgument(lsp.getLspId() != null, "LspId is mandatory.");
-        writeShort(lsp.getLspId().getValue().shortValue(), body);
-        checkArgument(lsp.getTunnelId() != null, "TunnelId is mandatory.");
-        writeUnsignedShort(lsp.getTunnelId().getValue(), body);
+        Ipv6Util.writeIpv6Address(ipv6.getIpv6TunnelSenderAddress(), body);
+
+        final LspId lspId = lsp.getLspId();
+        checkArgument(lspId != null, "LspId is mandatory.");
+        body.writeShort(lspId.getValue().shortValue());
+        final TunnelId tunnelId = lsp.getTunnelId();
+        checkArgument(tunnelId != null, "TunnelId is mandatory.");
+        ByteBufUtils.write(body, tunnelId.getValue());
         checkArgument(ipv6.getIpv6ExtendedTunnelId() != null, "Ipv6ExtendedTunnelId is mandatory.");
-        writeIpv6Address(ipv6.getIpv6ExtendedTunnelId(), body);
+        Ipv6Util.writeIpv6Address(ipv6.getIpv6ExtendedTunnelId(), body);
         checkArgument(ipv6.getIpv6TunnelEndpointAddress() != null, "Ipv6TunnelEndpointAddress is mandatory.");
-        writeIpv6Address(ipv6.getIpv6TunnelEndpointAddress(), body);
+        Ipv6Util.writeIpv6Address(ipv6.getIpv6TunnelEndpointAddress(), body);
         TlvUtil.formatTlv(TYPE, body, buffer);
     }
 }