use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv4PrefixBinaryBuilder 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();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv4PrefixBinaryBuilder in project lispflowmapping by opendaylight.
the class Ipv4PrefixBinarySerializer method deserializeEidData.
@Override
protected Eid deserializeEidData(ByteBuffer buffer, LispAddressSerializerContext ctx) {
byte[] ipBuffer = new byte[4];
buffer.get(ipBuffer);
Ipv4PrefixBinary prefix = new Ipv4PrefixBinaryBuilder().setIpv4AddressBinary(new Ipv4AddressBinary(ipBuffer)).setIpv4MaskLength(ctx.getMaskLen()).build();
EidBuilder eb = new EidBuilder();
eb.setAddressType(Ipv4PrefixBinaryAfi.class);
eb.setVirtualNetworkId(getVni(ctx));
eb.setAddress(prefix);
return eb.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv4PrefixBinaryBuilder in project lispflowmapping by opendaylight.
the class MappingServiceIntegrationTest method testGapIntersection.
/**
* Tests a negative mapping from an intersection of gaps in northbound and southbound.
*/
private void testGapIntersection() throws UnknownHostException {
// request an Eid from a gap between mappings
final MapReply mapReply = lms.handleMapRequest(newMapRequest(1L, "1.1.127.10/32"));
// expected negative mapping
final Address resultNegMapping = new Ipv4PrefixBinaryBuilder().setIpv4AddressBinary(new Ipv4AddressBinary(InetAddress.getByName("1.1.64.0").getAddress())).setIpv4MaskLength((short) 18).build();
assertEquals(resultNegMapping, mapReply.getMappingRecordItem().get(0).getMappingRecord().getEid().getAddress());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv4PrefixBinaryBuilder in project lispflowmapping by opendaylight.
the class MappingServiceIntegrationTest method testMultipleMappings.
private void testMultipleMappings() throws UnknownHostException {
final InstanceIdType iid = new InstanceIdType(1L);
// prefix from the intersection of NB and SB gaps
final String prefix1 = "1.1.127.10/32";
// prefix with existing mapping in NB
final String prefix2 = "1.1.200.255/32";
final String prefix3 = "1.3.255.255/32";
final MapRequest mapRequest = new MapRequestBuilder().setSmrInvoked(false).setEidItem(Lists.newArrayList(new EidItemBuilder().setEid(LispAddressUtil.asIpv4PrefixBinaryEid(prefix1, iid)).build(), new EidItemBuilder().setEid(LispAddressUtil.asIpv4PrefixBinaryEid(prefix2, iid)).build(), new EidItemBuilder().setEid(LispAddressUtil.asIpv4PrefixBinaryEid(prefix3, iid)).build())).build();
final MapReply mapReply = lms.handleMapRequest(mapRequest);
// expected result
final String resultPrefix1 = "1.1.64.0";
final Address resultNegMapping1 = new Ipv4PrefixBinaryBuilder().setIpv4AddressBinary(new Ipv4AddressBinary(InetAddress.getByName(resultPrefix1).getAddress())).setIpv4MaskLength((short) 18).build();
final String resultPrefix2 = "1.1.128.0";
final Address resultMapping2 = new Ipv4PrefixBinaryBuilder().setIpv4AddressBinary(new Ipv4AddressBinary(InetAddress.getByName(resultPrefix2).getAddress())).setIpv4MaskLength((short) 17).build();
final String resultPrefix3 = "1.3.0.0";
final Address resultNegMapping3 = new Ipv4PrefixBinaryBuilder().setIpv4AddressBinary(new Ipv4AddressBinary(InetAddress.getByName(resultPrefix3).getAddress())).setIpv4MaskLength((short) 16).build();
assertEquals(resultNegMapping1, mapReply.getMappingRecordItem().get(0).getMappingRecord().getEid().getAddress());
assertEquals(resultMapping2, mapReply.getMappingRecordItem().get(1).getMappingRecord().getEid().getAddress());
assertEquals(resultNegMapping3, mapReply.getMappingRecordItem().get(2).getMappingRecord().getEid().getAddress());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv4PrefixBinaryBuilder in project lispflowmapping by opendaylight.
the class LispAddressUtil method asIpv4PrefixBinaryEid.
public static Eid asIpv4PrefixBinaryEid(InstanceIdType vni, byte[] address, short mask) {
Preconditions.checkArgument(address.length == 4, "asIpv4PrefixBinaryEid called with incorrect length byte array ({})", address.length);
EidBuilder builder = new EidBuilder();
builder.setAddressType(Ipv4PrefixBinaryAfi.class);
builder.setVirtualNetworkId(vni);
builder.setAddress(new Ipv4PrefixBinaryBuilder().setIpv4AddressBinary(new Ipv4AddressBinary(address)).setIpv4MaskLength(mask).build());
return builder.build();
}
Aggregations