use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix in project lispflowmapping by opendaylight.
the class LispAddressUtil method toEidNoVni.
// XXX getMapping rcp fails if VNI set to 0
public static Eid toEidNoVni(IpPrefix prefix) {
EidBuilder builder = new EidBuilder();
builder.setAddress(addressFromIpPrefix(prefix));
builder.setAddressType(addressTypeFromIpPrefix(prefix));
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix in project lispflowmapping by opendaylight.
the class LispAddressUtil method toIpPrefixEid.
public static Eid toIpPrefixEid(IpAddress addr, int vni) {
// If you touch this, be sure that sfclisp compiles!
int mask = addressTypeFromIpAddress(addr) == Ipv4Afi.class ? 32 : 128;
IpPrefix prefix = asIpPrefix(String.valueOf(addr.getValue()), mask);
// XXX getMapping rcp fails if VNI set to 0
return toEidNoVni(prefix);
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix 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());
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix in project lispflowmapping by opendaylight.
the class MappingServiceIntegrationTest method registerAndQuery__SrcDestLCAFOverlap.
public void registerAndQuery__SrcDestLCAFOverlap() throws SocketTimeoutException {
cleanUP();
String ipString1 = "10.10.10.0";
String ipString2 = "20.20.20.0";
String ipPrefix1 = ipString1 + "/24";
String ipPrefix2 = ipString2 + "/24";
Eid srcDst = LispAddressUtil.asSrcDstEid(ipString1, ipString2, 24, 24, 0);
registerAddress(LispAddressUtil.asIpv4PrefixBinaryEid(ipPrefix2));
registerAddress(srcDst);
// exact match
MapReply reply = queryForAddress(srcDst, null);
Eid fromNetwork = reply.getMappingRecordItem().get(0).getMappingRecord().getEid();
assertEquals(SourceDestKeyLcaf.class, fromNetwork.getAddressType());
SourceDestKey sourceDestFromNetwork = (SourceDestKey) fromNetwork.getAddress();
IpPrefix receivedAddr1 = sourceDestFromNetwork.getSourceDestKey().getSource().getIpPrefix();
IpPrefix receivedAddr2 = sourceDestFromNetwork.getSourceDestKey().getDest().getIpPrefix();
assertNotNull(receivedAddr1.getIpv4Prefix());
assertNotNull(receivedAddr2.getIpv4Prefix());
assertEquals(ipPrefix1, receivedAddr1.getIpv4Prefix().getValue());
assertEquals(ipPrefix2, receivedAddr2.getIpv4Prefix().getValue());
// srcEid/dstEid match
reply = queryForAddress(LispAddressUtil.asIpv4PrefixBinaryEid("20.20.20.1/32"), "10.10.10.1");
fromNetwork = reply.getMappingRecordItem().get(0).getMappingRecord().getEid();
assertEquals(Ipv4PrefixBinaryAfi.class, fromNetwork.getAddressType());
assertEquals(LispAddressUtil.asIpv4PrefixBinaryEid(ipPrefix2), fromNetwork);
// dstEid match only
reply = queryForAddress(LispAddressUtil.asIpv4PrefixBinaryEid("20.20.20.1/32"), "1.2.3.4");
fromNetwork = reply.getMappingRecordItem().get(0).getMappingRecord().getEid();
assertEquals(Ipv4PrefixBinaryAfi.class, fromNetwork.getAddressType());
assertEquals(LispAddressUtil.asIpv4PrefixBinaryEid(ipPrefix2), fromNetwork);
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix in project lispflowmapping by opendaylight.
the class MappingMergeUtil method getIpPrefix.
private static IpPrefix getIpPrefix(Address address) {
IpPrefix ipPrefix = null;
if (address instanceof org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4Prefix) {
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4Prefix lispPrefix = (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4Prefix) address;
Ipv4Prefix inetPrefix = new Ipv4Prefix(lispPrefix.getIpv4Prefix());
ipPrefix = new IpPrefix(inetPrefix);
} else if (address instanceof org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv6Prefix) {
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv6Prefix lispPrefix = (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv6Prefix) address;
Ipv6Prefix inetPrefix = new Ipv6Prefix(lispPrefix.getIpv6Prefix());
ipPrefix = new IpPrefix(inetPrefix);
} else {
LOG.warn("Southbound mapping address is not an IpPrefix");
}
return ipPrefix;
}
Aggregations