use of org.onosproject.net.neighbour.NeighbourMessageContext in project trellis-control by opennetworkinglab.
the class ArpHandler method validateArpSpa.
/**
* Check if the source protocol address of an ARP packet belongs to the same
* subnet configured on the port it is seen.
*
* @param pkt ARP packet and context information
* @return true if the source protocol address belongs to the configured subnet
*/
private boolean validateArpSpa(NeighbourMessageContext pkt) {
Ip4Address spa = pkt.sender().getIp4Address();
Set<IpPrefix> subnet = config.getPortSubnets(pkt.inPort().deviceId(), pkt.inPort().port()).stream().filter(ipPrefix -> ipPrefix.isIp4() && ipPrefix.contains(spa)).collect(Collectors.toSet());
return !subnet.isEmpty();
}
use of org.onosproject.net.neighbour.NeighbourMessageContext in project onos by opennetworkinglab.
the class VplsNeighbourHandler method handleRequest.
/**
* Handles request messages.
*
* @param context the message context
*/
protected void handleRequest(NeighbourMessageContext context) {
// Find target VPLS first, then broadcast to all interface of this VPLS
VplsData vplsData = findVpls(context);
if (vplsData != null) {
vplsData.interfaces().stream().filter(intf -> !context.inPort().equals(intf.connectPoint())).forEach(context::forward);
} else {
log.warn(CAN_NOT_FIND_VPLS, context.inPort(), context.vlan());
context.drop();
}
}
use of org.onosproject.net.neighbour.NeighbourMessageContext in project onos by opennetworkinglab.
the class NeighbourResolutionManager method handlePacket.
private void handlePacket(PacketContext context) {
InboundPacket pkt = context.inPacket();
Ethernet ethPkt = pkt.parsed();
NeighbourMessageContext msgContext = DefaultNeighbourMessageContext.createContext(ethPkt, pkt.receivedFrom(), actions);
if (msgContext == null) {
return;
}
if (handleMessage(msgContext)) {
context.block();
}
}
use of org.onosproject.net.neighbour.NeighbourMessageContext in project trellis-control by opennetworkinglab.
the class SegmentRoutingNeighbourHandler method flood.
/*
* Floods only on the port which have been configured with the subnet
* of the target address. The in port is excluded.
*
* @param pkt the ndp/arp packet and context information
*/
protected void flood(NeighbourMessageContext pkt) {
try {
srManager.deviceConfiguration.getSubnetPortsMap(pkt.inPort().deviceId()).forEach((subnet, ports) -> {
if (subnet.contains(pkt.target())) {
ports.stream().filter(port -> port != pkt.inPort().port()).forEach(port -> {
ConnectPoint outPoint = new ConnectPoint(pkt.inPort().deviceId(), port);
pkt.forward(outPoint);
});
}
});
} catch (DeviceConfigNotFoundException e) {
log.warn(e.getMessage() + " Cannot flood in subnet as device config not available" + " for device: " + pkt.inPort().deviceId());
}
}
use of org.onosproject.net.neighbour.NeighbourMessageContext in project trellis-control by opennetworkinglab.
the class IcmpHandler method isNdpForGateway.
/**
* Utility to verify if the ND are for the gateway.
*
* @param pkt the ndp packet
* @return true if the ndp is for the gateway. False otherwise
*/
private boolean isNdpForGateway(NeighbourMessageContext pkt) {
DeviceId deviceId = pkt.inPort().deviceId();
Set<IpAddress> gatewayIpAddresses = null;
try {
if (pkt.target().equals(config.getRouterIpv6(deviceId))) {
return true;
}
gatewayIpAddresses = config.getPortIPs(deviceId);
} catch (DeviceConfigNotFoundException e) {
log.warn(e.getMessage() + " Aborting check for router IP in processing ndp");
return false;
}
return gatewayIpAddresses != null && gatewayIpAddresses.stream().filter(IpAddress::isIp6).anyMatch(gatewayIp -> gatewayIp.equals(pkt.target()) || Arrays.equals(IPv6.getSolicitNodeAddress(gatewayIp.toOctets()), pkt.target().toOctets()));
}
Aggregations