use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transport.address.TransportAddressBuilder in project lispflowmapping by opendaylight.
the class LispSouthboundRpcTest method sendMapRegisterTest_inputNotNull.
/**
* Tests {@link LispSouthboundRPC#sendMapRegister} method.
*/
@Test
public void sendMapRegisterTest_inputNotNull() throws ExecutionException, InterruptedException {
final MapRegister mapRegister = getDefaultMapRegisterBuilder().build();
final TransportAddress transportAddress = new TransportAddressBuilder().build();
final SendMapRegisterInput sendMapRegisterInputMock = Mockito.mock(SendMapRegisterInput.class);
Mockito.when(sendMapRegisterInputMock.getTransportAddress()).thenReturn(transportAddress);
Mockito.when(sendMapRegisterInputMock.getMapRegister()).thenReturn(mapRegister);
assertEquals(RPC_RESULT_SUCCESS.isSuccessful(), lispSouthboundRPC.sendMapRegister(sendMapRegisterInputMock).get().isSuccessful());
Mockito.verify(lispSouthboundPlugin).handleSerializedLispBuffer(transportAddress, MapRegisterSerializer.getInstance().serialize(mapRegister), MessageType.MapRegister);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transport.address.TransportAddressBuilder in project lispflowmapping by opendaylight.
the class LispSouthboundHandler method handleMapRequest.
@SuppressWarnings("checkstyle:IllegalCatch")
private void handleMapRequest(ByteBuffer inBuffer, InetAddress sourceAddress, int port) {
try {
MapRequest request = MapRequestSerializer.getInstance().deserialize(inBuffer, sourceAddress);
InetAddress finalSourceAddress = MapRequestUtil.selectItrRloc(request);
if (finalSourceAddress == null) {
throw new LispMalformedPacketException("Couldn't deserialize Map-Request, no ITR Rloc found!");
}
RequestMappingBuilder requestMappingBuilder = new RequestMappingBuilder();
requestMappingBuilder.setMapRequest(LispNotificationHelper.convertMapRequest(request));
TransportAddressBuilder transportAddressBuilder = new TransportAddressBuilder();
transportAddressBuilder.setIpAddress(LispNotificationHelper.getIpAddressBinaryFromInetAddress(finalSourceAddress));
transportAddressBuilder.setPort(new PortNumber(port));
requestMappingBuilder.setTransportAddress(transportAddressBuilder.build());
lispSbPlugin.sendNotificationIfPossible(requestMappingBuilder.build());
} catch (RuntimeException re) {
throw new LispMalformedPacketException("Couldn't deserialize Map-Request (len=" + inBuffer.capacity() + ")", re);
} catch (InterruptedException e) {
LOG.warn("Notification publication interrupted!");
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transport.address.TransportAddressBuilder in project lispflowmapping by opendaylight.
the class LispSouthboundHandler method handleMapReply.
@SuppressWarnings("checkstyle:IllegalCatch")
private void handleMapReply(ByteBuffer inBuffer, InetAddress sourceAddress, int port) {
try {
MapReply mapReply = MapReplySerializer.getInstance().deserialize(inBuffer);
GotMapReplyBuilder gotMapReplyBuilder = new GotMapReplyBuilder();
gotMapReplyBuilder.setMapReply(LispNotificationHelper.convertMapReply(mapReply));
TransportAddressBuilder transportAddressBuilder = new TransportAddressBuilder();
transportAddressBuilder.setIpAddress(LispNotificationHelper.getIpAddressBinaryFromInetAddress(sourceAddress));
transportAddressBuilder.setPort(new PortNumber(port));
gotMapReplyBuilder.setTransportAddress(transportAddressBuilder.build());
lispSbPlugin.sendNotificationIfPossible(gotMapReplyBuilder.build());
} catch (RuntimeException re) {
throw new LispMalformedPacketException("Couldn't deserialize Map-Reply (len=" + inBuffer.capacity() + ")", re);
} catch (InterruptedException e) {
LOG.warn("Notification publication interrupted!");
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transport.address.TransportAddressBuilder in project lispflowmapping by opendaylight.
the class MapServer method getTransportAddresses.
private static List<TransportAddress> getTransportAddresses(Set<IpAddressBinary> addresses) {
List<TransportAddress> rlocs = new ArrayList<TransportAddress>();
for (IpAddressBinary address : addresses) {
TransportAddressBuilder tab = new TransportAddressBuilder();
tab.setIpAddress(address);
tab.setPort(new PortNumber(LispMessage.PORT_NUM));
rlocs.add(tab.build());
}
return rlocs;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transport.address.TransportAddressBuilder 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