use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv4PrefixBinary in project lispflowmapping by opendaylight.
the class MaskUtilTest method normalizeTest_withIpv4PrefixBinary_withMask.
/**
* Tests {@link MaskUtil#normalize(Eid eid, short mask)} method with Ipv4PrefixBinary.
*/
@Test
public void normalizeTest_withIpv4PrefixBinary_withMask() throws UnknownHostException {
// input ip: 255.255.255.255, mask: 20
final Eid result = MaskUtil.normalize(EID_IPV4_PREFIX_BINARY, (short) 20);
final Ipv4PrefixBinary resultPrefix = (Ipv4PrefixBinary) result.getAddress();
// expected result
assertArrayEquals(ipv4ExpectedByteAddress, resultPrefix.getIpv4AddressBinary().getValue());
assertEquals((short) 20, (short) resultPrefix.getIpv4MaskLength());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv4PrefixBinary in project lispflowmapping by opendaylight.
the class MaskUtilTest method normalizeTest_withIpv4PrefixBinary.
/**
* Tests {@link MaskUtil#normalize(Eid eid)} method with Ipv4PrefixBinary.
*/
@Test
public void normalizeTest_withIpv4PrefixBinary() throws UnknownHostException {
// input ip: 255.255.255.255, mask: 20
final Eid result = MaskUtil.normalize(EID_IPV4_PREFIX_BINARY);
final Ipv4PrefixBinary resultPrefix = (Ipv4PrefixBinary) result.getAddress();
// expected result
final byte[] expectedResult = Inet4Address.getByName("255.255.240.0").getAddress();
assertArrayEquals(expectedResult, resultPrefix.getIpv4AddressBinary().getValue());
assertEquals((short) 20, (short) resultPrefix.getIpv4MaskLength());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv4PrefixBinary in project lispflowmapping by opendaylight.
the class MapReplySerializationTest method deserialize__MultipleRecordsWithoutRLOCs.
@Test
public void deserialize__MultipleRecordsWithoutRLOCs() throws Exception {
MapReply mr = MapReplySerializer.getInstance().deserialize(hexToByteBuffer("20 00 00 02 00 00 " + "00 00 00 00 00 00 00 00 00 01 00 20 00 00 00 00 " + "00 01 01 02 03 04 00 00 00 00 00 10 30 00 00 02 00 01 04 03 00 00"));
assertArrayEquals(new byte[] { 1, 2, 3, 4 }, ((Ipv4PrefixBinary) mr.getMappingRecordItem().get(0).getMappingRecord().getEid().getAddress()).getIpv4AddressBinary().getValue());
// XXX Why here normalized and other cases not normalized?
assertArrayEquals(new byte[] { 4, 3, 0, 0 }, ((Ipv4PrefixBinary) mr.getMappingRecordItem().get(1).getMappingRecord().getEid().getAddress()).getIpv4AddressBinary().getValue());
assertEquals(false, mr.getMappingRecordItem().get(0).getMappingRecord().isAuthoritative());
assertEquals(true, mr.getMappingRecordItem().get(1).getMappingRecord().isAuthoritative());
assertEquals(Action.NoAction, mr.getMappingRecordItem().get(0).getMappingRecord().getAction());
assertEquals(Action.NativelyForward, mr.getMappingRecordItem().get(1).getMappingRecord().getAction());
assertEquals(0, mr.getMappingRecordItem().get(0).getMappingRecord().getMapVersion().shortValue());
assertEquals(2, mr.getMappingRecordItem().get(1).getMappingRecord().getMapVersion().shortValue());
assertEquals(32, MaskUtil.getMaskForAddress(mr.getMappingRecordItem().get(0).getMappingRecord().getEid().getAddress()));
assertEquals(16, MaskUtil.getMaskForAddress(mr.getMappingRecordItem().get(1).getMappingRecord().getEid().getAddress()));
assertEquals(1, mr.getMappingRecordItem().get(0).getMappingRecord().getRecordTtl().byteValue());
assertEquals(0, mr.getMappingRecordItem().get(1).getMappingRecord().getRecordTtl().byteValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv4PrefixBinary in project lispflowmapping by opendaylight.
the class LispAddressUtil method toEid.
public static Eid toEid(Ipv4PrefixBinary prefix, InstanceIdType vni) {
EidBuilder builder = new EidBuilder();
builder.setAddressType(Ipv4PrefixBinaryAfi.class);
builder.setVirtualNetworkId(vni);
builder.setAddress((Address) prefix);
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv4PrefixBinary in project lispflowmapping by opendaylight.
the class LispAddressUtil method convertToBinary.
private static Ipv4PrefixBinary convertToBinary(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4Prefix prefix) {
Ipv4PrefixBinaryBuilder pb = new Ipv4PrefixBinaryBuilder();
byte[] address = InetAddresses.forString(MaskUtil.getAddressStringForIpv4Prefix(prefix)).getAddress();
pb.setIpv4AddressBinary(new Ipv4AddressBinary(address));
pb.setIpv4MaskLength(MaskUtil.getMaskForAddress(prefix));
return pb.build();
}
Aggregations