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 LispAddressUtil method asSrcDst.
public static SourceDestKey asSrcDst(String src, String dst, int smask, int dmask) {
SourceDestKeyBuilder builder = new SourceDestKeyBuilder();
builder.setSource(new SimpleAddress(asIpPrefix(src, smask)));
builder.setDest(new SimpleAddress(asIpPrefix(dst, dmask)));
return builder.build();
}
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 MaskUtil method normalizeSrcDst.
private static Eid normalizeSrcDst(Eid eid) throws UnknownHostException {
final SimpleAddress normalizedSrc = normalizeSimpleAddress(((SourceDestKey) eid.getAddress()).getSourceDestKey().getSource());
final SimpleAddress normalizedDst = normalizeSimpleAddress(((SourceDestKey) eid.getAddress()).getSourceDestKey().getDest());
return LispAddressUtil.asSrcDstEid(new SourceDestKeyBuilder().setSource(normalizedSrc).setDest(normalizedDst).build(), eid.getVirtualNetworkId());
}
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 LispAddressUtilTest method asSrcDstEid_addressesAsSrcDstKey.
/**
* Tests {@link LispAddressUtil#asSrcDstEid(SourceDestKey, InstanceIdType)} method.
*/
@Test
public void asSrcDstEid_addressesAsSrcDstKey() {
final SourceDestKey expectedSourceDestKey = new SourceDestKeyBuilder().setSource(SIMPLE_ADDRESS_IPV4_PREFIX_TEST).setDest(SIMPLE_ADDRESS_IPV6_PREFIX_TEST).build();
final Eid srcDstEid = LispAddressUtil.asSrcDstEid(expectedSourceDestKey, INSTANCE_ID_TYPE_TEST);
assertNotNull(srcDstEid);
assertEquals(SourceDestKeyLcaf.class, srcDstEid.getAddressType());
final SourceDestKey testedSourceDestKey = ((org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.SourceDestKey) srcDstEid.getAddress()).getSourceDestKey();
assertNotNull(testedSourceDestKey);
assertEquals(SIMPLE_ADDRESS_IPV4_PREFIX_TEST, testedSourceDestKey.getSource());
assertEquals(SIMPLE_ADDRESS_IPV6_PREFIX_TEST, testedSourceDestKey.getDest());
}
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 SourceDestKeySerializer method deserializeData.
private Address deserializeData(ByteBuffer buffer, LispAddressSerializerContext ctx) {
// reserved bytes
buffer.getShort();
short srcMaskLength = (short) ByteUtil.getUnsignedByte(buffer);
short dstMaskLength = (short) ByteUtil.getUnsignedByte(buffer);
ctx.setMaskLen(srcMaskLength);
SimpleAddress srcAddress = SimpleAddressSerializer.getInstance().deserialize(buffer, ctx);
ctx.setMaskLen(dstMaskLength);
SimpleAddress dstAddress = SimpleAddressSerializer.getInstance().deserialize(buffer, ctx);
SourceDestKeyBuilder sdb = new SourceDestKeyBuilder();
sdb.setSource(srcAddress);
sdb.setDest(dstAddress);
return new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.SourceDestKeyBuilder().setSourceDestKey(sdb.build()).build();
}
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 MappingServiceIntegrationTest method registerAndQuery__SrcDestLCAF.
// ------------------------------- LCAF Tests ---------------------------
public void registerAndQuery__SrcDestLCAF() throws SocketTimeoutException {
cleanUP();
String ipPrefix = "10.20.30.200/32";
String macString = "01:02:03:04:05:06";
SourceDestKeyBuilder builder = new SourceDestKeyBuilder();
builder.setSource(new SimpleAddress(new IpPrefix(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix(ipPrefix))));
builder.setDest(new SimpleAddress(new MacAddress(macString)));
EidBuilder eb = new EidBuilder();
eb.setAddressType(SourceDestKeyLcaf.class);
eb.setVirtualNetworkId(null);
eb.setAddress(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.SourceDestKeyBuilder().setSourceDestKey(builder.build()).build());
MapReply reply = registerAddressAndQuery(eb.build());
Eid fromNetwork = reply.getMappingRecordItem().get(0).getMappingRecord().getEid();
assertEquals(SourceDestKeyLcaf.class, fromNetwork.getAddressType());
SourceDestKey sourceDestFromNetwork = (SourceDestKey) fromNetwork.getAddress();
SimpleAddress receivedAddr1 = sourceDestFromNetwork.getSourceDestKey().getSource();
SimpleAddress receivedAddr2 = sourceDestFromNetwork.getSourceDestKey().getDest();
assertNotNull(receivedAddr1.getIpPrefix().getIpv4Prefix());
assertNotNull(receivedAddr2.getMacAddress());
IpPrefix receivedIP = receivedAddr1.getIpPrefix();
MacAddress receivedMAC = receivedAddr2.getMacAddress();
assertEquals(ipPrefix, receivedIP.getIpv4Prefix().getValue());
assertEquals(macString, receivedMAC.getValue());
}
Aggregations