use of org.onosproject.net.packet.OutboundPacket in project onos by opennetworkinglab.
the class McastForwarding method forwardPacketToDst.
/**
* Forward the packet to it's multicast destinations.
*
* @param context The packet context
* @param egressList The list of egress ports which the multicast packet is intended for.
*/
private void forwardPacketToDst(PacketContext context, ArrayList<ConnectPoint> egressList) {
// Send the pack out each of the respective egress ports
for (ConnectPoint egress : egressList) {
TrafficTreatment treatment = DefaultTrafficTreatment.builder().setOutput(egress.port()).build();
OutboundPacket packet = new DefaultOutboundPacket(egress.deviceId(), treatment, context.inPacket().unparsed());
packetService.emit(packet);
}
}
use of org.onosproject.net.packet.OutboundPacket in project onos by opennetworkinglab.
the class SimpleFabricManager method requestMac.
@Override
public boolean requestMac(IpAddress ip) {
FabricSubnet fabricSubnet = fabricSubnet(ip);
if (fabricSubnet == null) {
log.warn("simple fabric request mac failed for unknown fabricSubnet: {}", ip);
return false;
}
FabricNetwork fabricNetwork = fabricNetwork(fabricSubnet.networkName());
if (fabricNetwork == null) {
log.warn("simple fabric request mac failed for unknown fabricNetwork name {}: {}", fabricSubnet.networkName(), ip);
return false;
}
log.debug("simple fabric send request mac fabricNetwork {}: {}", fabricNetwork.name(), ip);
for (Interface iface : fabricNetwork.interfaces()) {
Ethernet neighbourReq;
if (ip.isIp4()) {
neighbourReq = ARP.buildArpRequest(fabricSubnet.gatewayMac().toBytes(), fabricSubnet.gatewayIp().toOctets(), ip.toOctets(), iface.vlan().toShort());
} else {
byte[] soliciteIp = IPv6.getSolicitNodeAddress(ip.toOctets());
neighbourReq = NeighborSolicitation.buildNdpSolicit(ip.getIp6Address(), fabricSubnet.gatewayIp().getIp6Address(), Ip6Address.valueOf(soliciteIp), MacAddress.valueOf(fabricSubnet.gatewayMac().toBytes()), MacAddress.valueOf(IPv6.getMCastMacAddress(soliciteIp)), iface.vlan());
}
TrafficTreatment treatment = DefaultTrafficTreatment.builder().setOutput(iface.connectPoint().port()).build();
OutboundPacket packet = new DefaultOutboundPacket(iface.connectPoint().deviceId(), treatment, ByteBuffer.wrap(neighbourReq.serialize()));
packetService.emit(packet);
}
return true;
}
use of org.onosproject.net.packet.OutboundPacket in project onos by opennetworkinglab.
the class SimpleFabricRouting method forwardPacketToDstIp.
/**
* Emits the specified packet onto the network.
*/
private void forwardPacketToDstIp(PacketContext context, IpAddress nextHopIp, MacAddress srcMac, boolean updateMac) {
Set<Host> hosts = hostService.getHostsByIp(nextHopIp);
Host dstHost;
if (!hosts.isEmpty()) {
dstHost = hosts.iterator().next();
} else {
// NOTE: hostService.requestMac(nextHopIp); NOT IMPLEMENTED in ONOS HostManager.java; do it myself
log.warn("forward packet nextHopIp host_mac unknown: nextHopIp={}", nextHopIp);
hostService.startMonitoringIp(nextHopIp);
simpleFabric.requestMac(nextHopIp);
// CONSIDER: make flood on all port of the dstHost's DefaultFabricNetwork
return;
}
TrafficTreatment treatment = DefaultTrafficTreatment.builder().setOutput(dstHost.location().port()).build();
OutboundPacket outPacket;
if (updateMac) {
// NOTE: eth address update by treatment is NOT applied, so update mac myself
outPacket = new DefaultOutboundPacket(dstHost.location().deviceId(), treatment, ByteBuffer.wrap(context.inPacket().parsed().setSourceMACAddress(srcMac).setDestinationMACAddress(dstHost.mac()).serialize()));
} else {
outPacket = new DefaultOutboundPacket(dstHost.location().deviceId(), treatment, context.inPacket().unparsed());
}
// be quiet on normal situation
log.info("forward packet: nextHopIP={} srcCP={} dstCP={}", nextHopIp, context.inPacket().receivedFrom(), dstHost.location());
packetService.emit(outPacket);
}
use of org.onosproject.net.packet.OutboundPacket in project onos by opennetworkinglab.
the class SimpleFabricRouting method checkVirtualGatewayIpPacket.
/**
* handle Packet with dstIp=virtualGatewayIpAddresses.
* returns true(handled) or false(not for virtual gateway)
*/
private boolean checkVirtualGatewayIpPacket(InboundPacket pkt, IpAddress srcIp, IpAddress dstIp) {
// assume valid
Ethernet ethPkt = pkt.parsed();
MacAddress mac = simpleFabric.vMacForIp(dstIp);
if (mac == null || !simpleFabric.isVirtualGatewayMac(ethPkt.getDestinationMAC())) {
/* Destination MAC should be any of virtual gateway macs */
return false;
} else if (dstIp.isIp4()) {
IPv4 ipv4Packet = (IPv4) ethPkt.getPayload();
if (ipv4Packet.getProtocol() == IPv4.PROTOCOL_ICMP) {
ICMP icmpPacket = (ICMP) ipv4Packet.getPayload();
if (icmpPacket.getIcmpType() == ICMP.TYPE_ECHO_REQUEST) {
log.info("IPV4 ICMP ECHO request to virtual gateway: " + "srcIp={} dstIp={} proto={}", srcIp, dstIp, ipv4Packet.getProtocol());
TrafficTreatment treatment = DefaultTrafficTreatment.builder().setOutput(pkt.receivedFrom().port()).build();
OutboundPacket packet = new DefaultOutboundPacket(pkt.receivedFrom().deviceId(), treatment, ByteBuffer.wrap(icmpPacket.buildIcmpReply(pkt.parsed()).serialize()));
packetService.emit(packet);
return true;
}
}
log.warn("IPV4 packet to virtual gateway dropped: " + "srcIp={} dstIp={} proto={}", srcIp, dstIp, ipv4Packet.getProtocol());
return true;
} else if (dstIp.isIp6()) {
// TODO: not tested yet (2017-07-20)
IPv6 ipv6Packet = (IPv6) ethPkt.getPayload();
if (ipv6Packet.getNextHeader() == IPv6.PROTOCOL_ICMP6) {
ICMP6 icmp6Packet = (ICMP6) ipv6Packet.getPayload();
if (icmp6Packet.getIcmpType() == ICMP6.ECHO_REQUEST) {
log.info("IPV6 ICMP6 ECHO request to virtual gateway: srcIp={} dstIp={} nextHeader={}", srcIp, dstIp, ipv6Packet.getNextHeader());
TrafficTreatment treatment = DefaultTrafficTreatment.builder().setOutput(pkt.receivedFrom().port()).build();
OutboundPacket packet = new DefaultOutboundPacket(pkt.receivedFrom().deviceId(), treatment, ByteBuffer.wrap(icmp6Packet.buildIcmp6Reply(pkt.parsed()).serialize()));
packetService.emit(packet);
return true;
}
}
log.warn("IPV6 packet to virtual gateway dropped: srcIp={} dstIp={} nextHeader={}", srcIp, dstIp, ipv6Packet.getNextHeader());
return true;
}
// unknown traffic
return false;
}
use of org.onosproject.net.packet.OutboundPacket in project onos by opennetworkinglab.
the class IcmpHandler method sendPacketOut.
private void sendPacketOut(ConnectPoint outport, Ethernet payload) {
TrafficTreatment treatment = DefaultTrafficTreatment.builder().setOutput(outport.port()).build();
OutboundPacket packet = new DefaultOutboundPacket(outport.deviceId(), treatment, ByteBuffer.wrap(payload.serialize()));
packetService.emit(packet);
}
Aggregations