use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.EidBuilder 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.opendaylight.lfm.lisp.proto.rev151105.eid.container.EidBuilder in project lispflowmapping by opendaylight.
the class MappingServiceIntegrationTest method registerAndQuery__ApplicationData.
public void registerAndQuery__ApplicationData() throws SocketTimeoutException {
cleanUP();
String ipString = "1.2.3.4";
short protocol = 1;
int ipTOs = 2;
int localPortLow = 3;
int localPortHigh = 4;
int remotePortLow = 4;
int remotePortHigh = 5;
ApplicationDataBuilder builder = new ApplicationDataBuilder();
builder.setIpTos(ipTOs);
builder.setProtocol(protocol);
builder.setLocalPortLow(new PortNumber(localPortLow));
builder.setLocalPortHigh(new PortNumber(localPortHigh));
builder.setRemotePortLow(new PortNumber(remotePortLow));
builder.setRemotePortHigh(new PortNumber(remotePortHigh));
builder.setAddress(new SimpleAddress(new IpAddress(new Ipv4Address(ipString))));
EidBuilder eb = new EidBuilder();
eb.setAddressType(ApplicationDataLcaf.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.ApplicationDataBuilder().setApplicationData(builder.build()).build());
Eid addressToSend = eb.build();
MapReply reply = registerAddressAndQuery(addressToSend);
Eid receivedAddress = reply.getMappingRecordItem().get(0).getMappingRecord().getEid();
assertEquals(ApplicationDataLcaf.class, receivedAddress.getAddressType());
ApplicationData receivedApplicationDataAddress = (ApplicationData) receivedAddress.getAddress();
assertEquals(protocol, receivedApplicationDataAddress.getApplicationData().getProtocol().intValue());
assertEquals(ipTOs, receivedApplicationDataAddress.getApplicationData().getIpTos().intValue());
assertEquals(localPortLow, receivedApplicationDataAddress.getApplicationData().getLocalPortLow().getValue().intValue());
assertEquals(localPortHigh, receivedApplicationDataAddress.getApplicationData().getLocalPortHigh().getValue().intValue());
assertEquals(remotePortLow, receivedApplicationDataAddress.getApplicationData().getRemotePortLow().getValue().intValue());
assertEquals(remotePortHigh, receivedApplicationDataAddress.getApplicationData().getRemotePortHigh().getValue().intValue());
SimpleAddress ipAddressReceived = receivedApplicationDataAddress.getApplicationData().getAddress();
assertEquals(ipString, ipAddressReceived.getIpAddress().getIpv4Address().getValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.EidBuilder in project lispflowmapping by opendaylight.
the class MappingServiceIntegrationTest method registerAndQuery__TrafficEngineering.
public void registerAndQuery__TrafficEngineering() throws SocketTimeoutException {
cleanUP();
String macString = "01:02:03:04:05:06";
String ipString = "10.20.255.30";
HopBuilder hopBuilder = new HopBuilder();
hopBuilder.setAddress(new SimpleAddress(new IpAddress(new Ipv4Address(ipString))));
hopBuilder.setLrsBits(new LrsBits(true, false, true));
Hop hop1 = hopBuilder.build();
hopBuilder.setAddress(new SimpleAddress(new MacAddress(macString)));
hopBuilder.setLrsBits(new LrsBits(false, true, false));
Hop hop2 = hopBuilder.build();
ExplicitLocatorPathBuilder elpBuilder = new ExplicitLocatorPathBuilder();
elpBuilder.setHop(new ArrayList<Hop>());
elpBuilder.getHop().add(hop1);
elpBuilder.getHop().add(hop2);
EidBuilder eb = new EidBuilder();
eb.setAddressType(ExplicitLocatorPathLcaf.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.ExplicitLocatorPathBuilder().setExplicitLocatorPath(elpBuilder.build()).build());
MapReply reply = registerAddressAndQuery(eb.build());
assertEquals(ExplicitLocatorPathLcaf.class, reply.getMappingRecordItem().get(0).getMappingRecord().getEid().getAddressType());
ExplicitLocatorPath receivedAddress = (ExplicitLocatorPath) reply.getMappingRecordItem().get(0).getMappingRecord().getEid().getAddress();
Hop receivedHop1 = (Hop) receivedAddress.getExplicitLocatorPath().getHop().get(0);
Hop receivedHop2 = (Hop) receivedAddress.getExplicitLocatorPath().getHop().get(1);
assertEquals(true, receivedHop1.getLrsBits().isLookup());
assertEquals(false, receivedHop1.getLrsBits().isRlocProbe());
assertEquals(true, receivedHop1.getLrsBits().isStrict());
assertEquals(false, receivedHop2.getLrsBits().isLookup());
assertEquals(true, receivedHop2.getLrsBits().isRlocProbe());
assertEquals(false, receivedHop2.getLrsBits().isStrict());
assertNotNull(receivedHop1.getAddress().getIpAddress().getIpv4Address());
assertNotNull(receivedHop2.getAddress().getMacAddress());
assertEquals(ipString, receivedHop1.getAddress().getIpAddress().getIpv4Address().getValue());
assertEquals(macString, receivedHop2.getAddress().getMacAddress().getValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.EidBuilder in project lispflowmapping by opendaylight.
the class MappingServiceIntegrationTestUtil method removePrefixIfNecessary.
static Eid removePrefixIfNecessary(Eid eid) {
EidBuilder eb = new EidBuilder(eid);
Address address = eid.getAddress();
if (address instanceof Ipv4PrefixBinary) {
Ipv4Binary convertedEid = new Ipv4BinaryBuilder().setIpv4Binary(((Ipv4PrefixBinary) address).getIpv4AddressBinary()).build();
return eb.setAddress(convertedEid).setAddressType(Ipv4BinaryAfi.class).build();
} else if (address instanceof Ipv6PrefixBinary) {
Ipv6Binary convertedEid = new Ipv6BinaryBuilder().setIpv6Binary(((Ipv6PrefixBinary) address).getIpv6AddressBinary()).build();
return eb.setAddress(convertedEid).setAddressType(Ipv6BinaryAfi.class).build();
}
return eid;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.EidBuilder in project lispflowmapping by opendaylight.
the class SourceDestKeyHelperTest method getDstTest_sourceDestKey.
/**
* Tests {@link SourceDestKeyHelper#getDst} method with SourceDestKey address type.
*/
@Test
public void getDstTest_sourceDestKey() {
final Eid expectedResult = new EidBuilder().setAddress(new Ipv4PrefixBuilder().setIpv4Prefix(IPV4_PREFIX_DEST).build()).setVirtualNetworkId(INSTANCE_ID).setAddressType(Ipv4PrefixAfi.class).build();
assertEquals(expectedResult, SourceDestKeyHelper.getDst(EID_SOURCE_DEST_KEY));
}
Aggregations