use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.inet.binary.types.rev160303.Ipv4AddressBinary in project lispflowmapping by opendaylight.
the class LispXtrSouthboundHandlerTest method getDefaultMapRequestBuilder.
private static MapRequestBuilder getDefaultMapRequestBuilder() {
final ItrRloc itrRloc = new ItrRlocBuilder().setRloc(new RlocBuilder().setAddressType(Ipv4BinaryAfi.class).setAddress(new Ipv4BinaryBuilder().setIpv4Binary(new Ipv4AddressBinary(new byte[] { 127, 0, 0, 2 })).build()).build()).build();
final EidItem eidItem = new EidItemBuilder().setEid(LispAddressUtil.asIpv4PrefixBinaryEid(IPV4_STRING_2 + IPV4_STRING_PREFIX)).build();
return new MapRequestBuilder().setItrRloc(Lists.newArrayList(itrRloc)).setEidItem(Lists.newArrayList(eidItem)).setNonce(NONCE).setSourceEid(new SourceEidBuilder().setEid(LispAddressUtil.asIpv4Eid(IPV4_STRING_1)).build()).setAuthoritative(false).setMapDataPresent(false).setPitr(false).setProbe(false).setSmr(false).setSmrInvoked(false);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.inet.binary.types.rev160303.Ipv4AddressBinary 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.inet.binary.types.rev160303.Ipv4AddressBinary 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.inet.binary.types.rev160303.Ipv4AddressBinary in project lispflowmapping by opendaylight.
the class LispAddressUtil method toRloc.
public static Rloc toRloc(Ipv4AddressBinary address) {
RlocBuilder builder = new RlocBuilder();
builder.setAddressType(Ipv4BinaryAfi.class);
builder.setVirtualNetworkId(null);
builder.setAddress((Address) new Ipv4BinaryBuilder().setIpv4Binary(address).build());
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.inet.binary.types.rev160303.Ipv4AddressBinary in project lispflowmapping by opendaylight.
the class LispNotificationHelper method getTransportAddressFromRloc.
public static TransportAddress getTransportAddressFromRloc(Rloc rloc) {
TransportAddressBuilder tab = new TransportAddressBuilder();
Address address = rloc.getAddress();
// object, yey!
if (address instanceof Ipv4) {
String ipv4 = ((Ipv4) address).getIpv4().getValue();
tab.setIpAddress(IpAddressBinaryBuilder.getDefaultInstance(InetAddresses.forString(ipv4).getAddress()));
tab.setPort(new PortNumber(LispMessage.PORT_NUM));
} else if (address instanceof Ipv6) {
String ipv6 = ((Ipv6) address).getIpv6().getValue();
tab.setIpAddress(IpAddressBinaryBuilder.getDefaultInstance(InetAddresses.forString(ipv6).getAddress()));
tab.setPort(new PortNumber(LispMessage.PORT_NUM));
} else if (address instanceof Ipv4Binary) {
Ipv4AddressBinary ipv6 = ((Ipv4Binary) address).getIpv4Binary();
tab.setIpAddress(new IpAddressBinary(ipv6));
tab.setPort(new PortNumber(LispMessage.PORT_NUM));
} else if (address instanceof Ipv6Binary) {
Ipv6AddressBinary ipv6 = ((Ipv6Binary) address).getIpv6Binary();
tab.setIpAddress(new IpAddressBinary(ipv6));
tab.setPort(new PortNumber(LispMessage.PORT_NUM));
} else if (address instanceof KeyValueAddress) {
SimpleAddress sa = ((KeyValueAddress) address).getKeyValueAddress().getValue();
if (sa.getDistinguishedNameType() != null) {
final Iterator<String> it = COLON_SPLITTER.split(sa.getDistinguishedNameType().getValue()).iterator();
String ip = it.next();
int port = Integer.valueOf(it.next());
tab.setIpAddress(IpAddressBinaryBuilder.getDefaultInstance(InetAddresses.forString(ip).getAddress()));
tab.setPort(new PortNumber(port));
}
} else if (address instanceof DistinguishedName) {
DistinguishedName dname = (DistinguishedName) address;
final Iterator<String> it = COLON_SPLITTER.split(dname.getDistinguishedName().getValue()).iterator();
String ip = it.next();
int port = Integer.valueOf(it.next());
tab.setIpAddress(IpAddressBinaryBuilder.getDefaultInstance(InetAddresses.forString(ip).getAddress()));
tab.setPort(new PortNumber(port));
} else if (address instanceof ApplicationData) {
ApplicationData appData = (ApplicationData) address;
tab.setIpAddress(getIpAddressBinary(appData.getApplicationData().getAddress().getIpAddress()));
tab.setPort(new PortNumber(appData.getApplicationData().getLocalPortLow()));
}
return tab.build();
}
Aggregations