use of org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceived in project genius by opendaylight.
the class AlivenessProtocolHandlerARP method handlePacketIn.
@Override
public String handlePacketIn(ARP packet, PacketReceived packetReceived) {
short tableId = packetReceived.getTableId().getValue();
int arpType = packet.getOpCode();
if (LOG.isTraceEnabled()) {
LOG.trace("packet: {}, tableId {}, arpType {}", packetReceived, tableId, arpType);
}
if (arpType == ARP.REPLY) {
if (LOG.isTraceEnabled()) {
LOG.trace("packet: {}", packetReceived);
}
BigInteger metadata = packetReceived.getMatch().getMetadata().getMetadata();
int portTag = MetaDataUtil.getLportFromMetadata(metadata).intValue();
String interfaceName = null;
try {
GetInterfaceFromIfIndexInput input = new GetInterfaceFromIfIndexInputBuilder().setIfIndex(portTag).build();
Future<RpcResult<GetInterfaceFromIfIndexOutput>> output = interfaceManager.getInterfaceFromIfIndex(input);
RpcResult<GetInterfaceFromIfIndexOutput> result = output.get();
if (result.isSuccessful()) {
GetInterfaceFromIfIndexOutput ifIndexOutput = result.getResult();
interfaceName = ifIndexOutput.getInterfaceName();
} else {
LOG.warn("RPC call to get interface name for if index {} failed with errors {}", portTag, result.getErrors());
return null;
}
} catch (InterruptedException | ExecutionException e) {
LOG.warn("Error retrieving interface Name for tag {}", portTag, e);
}
if (!Strings.isNullOrEmpty(interfaceName)) {
String sourceIp = NWUtil.toStringIpAddress(packet.getSenderProtocolAddress());
String targetIp = NWUtil.toStringIpAddress(packet.getTargetProtocolAddress());
return getMonitoringKey(interfaceName, targetIp, sourceIp);
} else {
LOG.debug("No interface associated with tag {} to interpret the received ARP Reply", portTag);
}
}
return null;
}
Aggregations