import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
+import org.opendaylight.protocol.util.ByteArray;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev160321.EsiType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev160321.esi.Esi;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev160321.esi.esi.ArbitraryCase;
@Override
- public Esi parseEsi(final ByteBuf buffer) {
- return new ArbitraryCaseBuilder().setArbitrary(new ArbitraryBuilder().setArbitrary(buffer.readSlice(ARBITRARY_LENGTH).array()).build()).build();
+ public Esi parseEsi(final ByteBuf body) {
+ return new ArbitraryCaseBuilder().setArbitrary(new ArbitraryBuilder().setArbitrary(ByteArray.readBytes(body, ARBITRARY_LENGTH)).build()).build();
}
}
}
public static IpAddress parseOrigRouteIp(final ByteBuf buffer) {
- final int ipLength = buffer.readByte();
- if (ipLength == Ipv6Util.IPV6_LENGTH) {
+ final int ipLength = buffer.readUnsignedByte();
+ if (ipLength == Ipv6Util.IPV6_BITS_LENGTH) {
return new IpAddress(Ipv6Util.addressForByteBuf(buffer));
- } else if (ipLength == Ipv4Util.IP4_LENGTH) {
+ } else if (ipLength == Ipv4Util.IP4_BITS_LENGTH) {
return new IpAddress(Ipv4Util.addressForByteBuf(buffer));
}
return null;
static ByteBuf serializeOrigRouteIp(final IpAddress origRouteIp) {
final ByteBuf body = Unpooled.buffer();
if (origRouteIp.getIpv4Address() != null) {
- body.writeByte(Ipv4Util.IP4_LENGTH);
+ body.writeByte(Ipv4Util.IP4_BITS_LENGTH);
body.writeBytes(Ipv4Util.bytesForAddress(origRouteIp.getIpv4Address()));
} else if (origRouteIp.getIpv6Address() != null) {
- body.writeByte(Ipv6Util.IPV6_LENGTH);
+ body.writeByte(Ipv6Util.IPV6_BITS_LENGTH);
body.writeBytes(Ipv6Util.bytesForAddress(origRouteIp.getIpv6Address()));
} else {
body.writeZero(ZERO_BYTE);
private static ByteBuf serializeIp(final IpAddress ipAddress) {
final ByteBuf body = Unpooled.buffer();
if (ipAddress.getIpv4Address() != null) {
- body.writeByte(Ipv4Util.IP4_LENGTH * BITS_SIZE);
+ body.writeByte(Ipv4Util.IP4_BITS_LENGTH);
body.writeBytes(Ipv4Util.bytesForAddress(ipAddress.getIpv4Address()));
} else if (ipAddress.getIpv6Address() != null) {
- body.writeByte(Ipv6Util.IPV6_LENGTH * BITS_SIZE);
+ body.writeByte(Ipv6Util.IPV6_BITS_LENGTH);
body.writeBytes(Ipv6Util.bytesForAddress(ipAddress.getIpv6Address()));
} else {
body.writeZero(ZERO_BYTE);
private static IpAddress parseIp(final ByteBuf buffer) {
final int ipLength = buffer.readUnsignedByte();
- if (ipLength == Ipv6Util.IPV6_LENGTH * BITS_SIZE) {
+ if (ipLength == Ipv6Util.IPV6_BITS_LENGTH) {
return new IpAddress(Ipv6Util.addressForByteBuf(buffer));
- } else if (ipLength == Ipv4Util.IP4_LENGTH * BITS_SIZE) {
+ } else if (ipLength == Ipv4Util.IP4_BITS_LENGTH) {
return new IpAddress(Ipv4Util.addressForByteBuf(buffer));
}
return null;
public class EthSegRParserTest {
private static final byte[] VALUE = {
(byte) 0x02, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x02, (byte) 0x02, (byte) 0x00,
- (byte) 0x04, (byte) 0x7f, (byte) 0x00, (byte) 0x00, (byte) 0x01
+ (byte) 0x20, (byte) 0x7f, (byte) 0x00, (byte) 0x00, (byte) 0x01
};
private static final byte[] RESULT = {
(byte) 0x04, (byte) 0x17,
(byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04, (byte) 0x01, (byte) 0x02,
(byte) 0x02, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x02, (byte) 0x02, (byte) 0x00,
- (byte) 0x04, (byte) 0x7f, (byte) 0x00, (byte) 0x00, (byte) 0x01
+ (byte) 0x20, (byte) 0x7f, (byte) 0x00, (byte) 0x00, (byte) 0x01
};
private static final byte[] VALUE2 = {
(byte) 0x02, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x02, (byte) 0x02, (byte) 0x00,
- (byte) 0x10,//IPV6
+ (byte) 0x80,//IPV6
(byte) 0x20, (byte) 0x01, (byte) 0x00, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
(byte) 0x04, (byte) 0x23,
(byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04, (byte) 0x01, (byte) 0x02,
(byte) 0x02, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x02, (byte) 0x02, (byte) 0x00,
- (byte) 0x10,//IPV6
+ (byte) 0x80,//IPV6
(byte) 0x20, (byte) 0x01, (byte) 0x00, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
(byte) 0x03, (byte) 0x11,
(byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04, (byte) 0x01, (byte) 0x02,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x0a,
- (byte) 0x04, (byte) 0x7f, (byte) 0x00, (byte) 0x00, (byte) 0x01
+ (byte) 0x20, (byte) 0x7f, (byte) 0x00, (byte) 0x00, (byte) 0x01
};
private static final byte[] VALUE = {
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x0a,
- (byte) 0x04, (byte) 0x7f, (byte) 0x00, (byte) 0x00, (byte) 0x01
+ (byte) 0x20, (byte) 0x7f, (byte) 0x00, (byte) 0x00, (byte) 0x01
};
private IncMultEthTagRParser parser;
*/
public final class Ipv4Util {
public static final int IP4_LENGTH = 4;
+ public static final int IP4_BITS_LENGTH = 32;
private static final Ipv4Prefix EMPTY_PREFIX = new Ipv4Prefix("0.0.0.0/0");
private Ipv4Util() {
*/
public final class Ipv6Util {
public static final int IPV6_LENGTH = 16;
+ public static final int IPV6_BITS_LENGTH = 128;
private static final Ipv6Prefix EMPTY_PREFIX = new Ipv6Prefix("::/0");
private Ipv6Util() {