use of org.onlab.packet.ARP in project onos by opennetworkinglab.
the class K8sSwitchingArpHandler method processArpReply.
private void processArpReply(PacketContext context, Ethernet ethPacket) {
ARP arpPacket = (ARP) ethPacket.getPayload();
IpAddress srcIp = IpAddress.valueOf(INET, arpPacket.getSenderProtocolAddress());
MacAddress srcMac = MacAddress.valueOf(arpPacket.getSenderHardwareAddress());
IpAddress dstIp = IpAddress.valueOf(INET, arpPacket.getTargetProtocolAddress());
if (dstIp.equals(IpAddress.valueOf(NODE_FAKE_IP_STR))) {
// mutable MAP scenario is not considered for now
if (!extHostMacStore.containsKey(srcIp)) {
extHostMacStore.put(srcIp, srcMac);
}
K8sNode k8sNode = k8sNodeService.nodes().stream().filter(n -> n.nodeIp().equals(srcIp)).findAny().orElse(null);
if (k8sNode == null) {
return;
} else {
if (k8sNode.nodeInfo().nodeMac() != null) {
return;
}
}
// we update node MAC address which will be referred in node port scenario
K8sNodeInfo nodeInfo = new K8sNodeInfo(k8sNode.nodeIp(), srcMac);
K8sNode updatedNode = k8sNode.updateNodeInfo(nodeInfo);
k8sNodeService.updateNode(updatedNode);
}
}
use of org.onlab.packet.ARP in project aaa by opencord.
the class PortBasedRadiusCommunicator method handleArpPacketFromServer.
/**
* Handles ARP packets from RADIUS server.
*
* @param context Context for the packet
*/
private void handleArpPacketFromServer(PacketContext context) {
// Extract the original Ethernet frame from the packet information
InboundPacket pkt = context.inPacket();
Ethernet ethPkt = pkt.parsed();
if (ethPkt == null) {
return;
}
ARP arpPacket = (ARP) ethPkt.getPayload();
Ip4Address targetAddress = Ip4Address.valueOf(arpPacket.getTargetProtocolAddress());
String serialNo = ipToSnMap.get(targetAddress);
if (serialNo == null) {
log.info("No mapping found for ARP reply, target address {}", targetAddress);
return;
}
if (subsService == null) {
log.warn(SADIS_NOT_RUNNING);
return;
}
MacAddress senderMac = subsService.get(serialNo).hardwareIdentifier();
if (senderMac == null) {
log.warn("ARP resolution, MAC address not found for SN {}", serialNo);
return;
}
ARP arpReply = (ARP) arpPacket.clone();
arpReply.setOpCode(ARP.OP_REPLY);
arpReply.setTargetProtocolAddress(arpPacket.getSenderProtocolAddress());
arpReply.setTargetHardwareAddress(arpPacket.getSenderHardwareAddress());
arpReply.setSenderProtocolAddress(arpPacket.getTargetProtocolAddress());
arpReply.setSenderHardwareAddress(senderMac.toBytes());
log.debug("AAA Manager: Query for ARP of IP : {}", arpPacket.getTargetProtocolAddress());
// Ethernet Frame.
Ethernet ethReply = new Ethernet();
ethReply.setSourceMACAddress(senderMac);
ethReply.setDestinationMACAddress(ethPkt.getSourceMAC());
ethReply.setEtherType(Ethernet.TYPE_ARP);
ethReply.setVlanID(radiusVlanID);
ethReply.setPriorityCode(ethPkt.getPriorityCode());
ethReply.setPayload(arpReply);
sendFromRadiusServerPort(ethReply);
}
Aggregations