use of org.onosproject.net.packet.OutboundPacket in project onos by opennetworkinglab.
the class TunnellingConnectivityManager method forward.
/**
* Forwards a BGP packet to another connect point.
*
* @param context the packet context of the incoming packet
*/
private void forward(PacketContext context) {
ConnectPoint outputPort = null;
IPv4 ipv4 = (IPv4) context.inPacket().parsed().getPayload();
IpAddress dstAddress = IpAddress.valueOf(ipv4.getDestinationAddress());
if (context.inPacket().receivedFrom().equals(bgpSpeaker.connectPoint())) {
if (bgpSpeaker.peers().contains(dstAddress)) {
Interface intf = interfaceService.getMatchingInterface(dstAddress);
if (intf != null) {
outputPort = intf.connectPoint();
}
}
} else {
Set<Interface> interfaces = interfaceService.getInterfacesByPort(context.inPacket().receivedFrom());
if (interfaces.stream().flatMap(intf -> intf.ipAddressesList().stream()).anyMatch(ia -> ia.ipAddress().equals(dstAddress))) {
outputPort = bgpSpeaker.connectPoint();
}
}
if (outputPort != null) {
TrafficTreatment t = DefaultTrafficTreatment.builder().setOutput(outputPort.port()).build();
OutboundPacket o = new DefaultOutboundPacket(outputPort.deviceId(), t, context.inPacket().unparsed());
packetService.emit(o);
}
}
use of org.onosproject.net.packet.OutboundPacket in project onos by opennetworkinglab.
the class Dhcp4HandlerImpl method sendResponseToClient.
/**
* Send the response DHCP to the requester host.
*
* @param thePacket the packet
* @param dhcpPayload the DHCP data
*/
private void sendResponseToClient(InternalPacket thePacket, DHCP dhcpPayload) {
checkNotNull(thePacket, "Nothing to send");
checkNotNull(thePacket.getPacket(), "Packet to send must not be empty");
checkNotNull(thePacket.getDestLocation(), "Packet destination not be empty");
Ethernet ethPacket = thePacket.getPacket();
if (directlyConnected(dhcpPayload)) {
ethPacket = removeRelayAgentOption(ethPacket);
}
TrafficTreatment treatment = DefaultTrafficTreatment.builder().setOutput(thePacket.getDestLocation().port()).build();
OutboundPacket o = new DefaultOutboundPacket(thePacket.getDestLocation().deviceId(), treatment, ByteBuffer.wrap(ethPacket.serialize()));
if (log.isTraceEnabled()) {
log.trace("Relaying packet to DHCP client {} via {}", ethPacket, thePacket.getDestLocation());
}
packetService.emit(o);
}
use of org.onosproject.net.packet.OutboundPacket in project onos by opennetworkinglab.
the class Dhcp4HandlerImpl method forwardPacket.
// forward the packet to ConnectPoint where the DHCP server is attached.
private void forwardPacket(InternalPacket packet) {
// send Packetout to dhcp server connectpoint.
if (packet.getDestLocation() != null) {
TrafficTreatment t = DefaultTrafficTreatment.builder().setOutput(packet.getDestLocation().port()).build();
OutboundPacket o = new DefaultOutboundPacket(packet.getDestLocation().deviceId(), t, ByteBuffer.wrap(packet.getPacket().serialize()));
if (log.isTraceEnabled()) {
log.trace("Relaying packet to destination {}", packet.getDestLocation());
}
log.debug("packetService.emit(o) to port {}", packet.getDestLocation());
packetService.emit(o);
}
}
use of org.onosproject.net.packet.OutboundPacket in project onos by opennetworkinglab.
the class Dhcp6HandlerImpl method forwardPacket.
// forward the packet to ConnectPoint where the DHCP server is attached.
private void forwardPacket(InternalPacket packet) {
// send Packetout to dhcp server connectpoint.
if (packet.getDestLocation() != null) {
TrafficTreatment t = DefaultTrafficTreatment.builder().setOutput(packet.getDestLocation().port()).build();
OutboundPacket o = new DefaultOutboundPacket(packet.getDestLocation().deviceId(), t, ByteBuffer.wrap(packet.getPacket().serialize()));
packetService.emit(o);
if (log.isTraceEnabled()) {
IPv6 ip6 = (IPv6) packet.getPacket().getPayload();
UDP udp = (UDP) ip6.getPayload();
DHCP6 dhcp6 = (DHCP6) udp.getPayload();
log.trace("Relaying packet to destination {} eth: {} dhcp: {}", packet.getDestLocation(), packet.getPacket(), dhcp6);
}
}
}
use of org.onosproject.net.packet.OutboundPacket in project onos by opennetworkinglab.
the class DhcpRelayManager method sendHostRelearnProbeToConnectPoint.
// Send Host Relearn Probe packets to ConnectPoint
private void sendHostRelearnProbeToConnectPoint(Ethernet nsPacket, ConnectPoint connectPoint) {
TrafficTreatment treatment = DefaultTrafficTreatment.builder().setOutput(connectPoint.port()).build();
OutboundPacket outboundPacket = new DefaultOutboundPacket(connectPoint.deviceId(), treatment, ByteBuffer.wrap(nsPacket.serialize()));
int counter = 0;
try {
while (counter < dhcpHostRelearnProbeCount) {
packetService.emit(outboundPacket);
counter++;
Thread.sleep(dhcpHostRelearnProbeInterval);
}
} catch (Exception e) {
log.error("Exception while emmiting packet {}", e.getMessage(), e);
}
}
Aggregations