use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.source.dest.key.SourceDestKeyBuilder in project lispflowmapping by opendaylight.
the class SourceDestKeySerializerTest method serialize__Simple.
@Test
public void serialize__Simple() throws Exception {
SourceDestKeyBuilder addressBuilder = new SourceDestKeyBuilder();
addressBuilder.setSource(new SimpleAddress(new IpPrefix(new Ipv4Prefix("17.34.51.68/8"))));
addressBuilder.setDest(new SimpleAddress(new IpPrefix(new Ipv4Prefix("34.51.68.85/16"))));
EidBuilder eb = new EidBuilder();
eb.setAddressType(SourceDestKeyLcaf.class);
eb.setVirtualNetworkId(null);
eb.setAddress((Address) new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.SourceDestKeyBuilder().setSourceDestKey(addressBuilder.build()).build());
ByteBuffer buf = ByteBuffer.allocate(LispAddressSerializer.getInstance().getAddressSize(eb.build()));
LispAddressSerializer.getInstance().serialize(buf, eb.build());
ByteBuffer expectedBuf = hexToByteBuffer(//
"40 03 00 00 " + //
"0C 00 00 10 " + // reserved + masks
"00 00 08 10 " + // AFI=1, IP=0x11223344
"00 01 11 22 33 44 " + // AFI=1, IP=0x22334455
"00 01 22 33 44 55");
ArrayAssert.assertEquals(expectedBuf.array(), buf.array());
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.source.dest.key.SourceDestKeyBuilder in project lispflowmapping by opendaylight.
the class MappingMergeUtil method computeNbSbIntersection.
private static MappingRecord computeNbSbIntersection(MappingRecord nbMapping, MappingRecord sbMapping) {
// returns a MappingRecord which has the more specific EID, and intersection of locator records.
// If locators intersection is empty, original NB mapping is returned.
// The intersection is only computed for mappings with maskable EIDs.
// Supports both maskable and non-maskable EIDs
MappingRecordBuilder mrb = new MappingRecordBuilder(nbMapping);
if (MaskUtil.isMaskable(sbMapping.getEid().getAddress()) && MaskUtil.isMaskable(nbMapping.getEid().getAddress())) {
short sbMask = MaskUtil.getMaskForAddress(sbMapping.getEid().getAddress());
short nbMask = MaskUtil.getMaskForAddress(nbMapping.getEid().getAddress());
if (nbMapping.getEid().getAddress() instanceof org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.SourceDestKey) {
nbMask = SourceDestKeyHelper.getDstMask(nbMapping.getEid());
if (nbMask < sbMask) {
// We have to create a new SourceDest EID, where the source is same as the
// one in NB record, and dest EID is the more specific from SB mapping record.
SourceDestKey srcDstKey = ((org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.SourceDestKey) nbMapping.getEid().getAddress()).getSourceDestKey();
SourceDestKeyBuilder sdb = new SourceDestKeyBuilder(srcDstKey);
sdb.setDest(new SimpleAddress(getIpPrefix(sbMapping.getEid().getAddress())));
mrb.setEid(LispAddressUtil.asSrcDstEid(sdb.build(), nbMapping.getEid().getVirtualNetworkId()));
}
} else if (nbMask < sbMask) {
// Both EIDs are IP prefixes. SB mapping is a subprefix so we have to update EID intersection
mrb.setEid(sbMapping.getEid());
}
}
// find and update locators intersection if not empty
List<LocatorRecord> commonLocators = getCommonLocatorRecords(nbMapping, sbMapping);
if (commonLocators != null && !commonLocators.isEmpty()) {
mrb.setLocatorRecord(commonLocators);
}
return mrb.build();
}
Aggregations