use of org.onosproject.net.packet.OutboundPacket in project onos by opennetworkinglab.
the class OpenFlowPacketProviderTest method wrongScheme.
@Test(expected = IllegalArgumentException.class)
public void wrongScheme() {
sw.setRole(RoleState.MASTER);
OutboundPacket schemeFailPkt = outPacket(DID_WRONG, TR, null);
provider.emit(schemeFailPkt);
assertEquals("message sent incorrectly", 0, sw.sent.size());
}
use of org.onosproject.net.packet.OutboundPacket in project onos by opennetworkinglab.
the class LinkDiscovery method sendProbes.
private void sendProbes(Long portNumber, String portDesc) {
if (context.packetService() == null) {
return;
}
log.trace("Sending probes out of {}@{}", portNumber, deviceId);
OutboundPacket pkt = createOutBoundLldp(portNumber, portDesc);
if (pkt != null) {
context.packetService().emit(pkt);
} else {
log.warn("Cannot send lldp packet due to packet is null {}", deviceId);
}
if (context.useBddp()) {
OutboundPacket bpkt = createOutBoundBddp(portNumber, portDesc);
if (bpkt != null) {
context.packetService().emit(bpkt);
} else {
log.warn("Cannot send bddp packet due to packet is null {}", deviceId);
}
}
}
use of org.onosproject.net.packet.OutboundPacket in project onos by opennetworkinglab.
the class HostLocationProvider method sendProbe.
private void sendProbe(Host host, IpAddress targetIp) {
Ethernet probePacket = null;
if (targetIp.isIp4()) {
// IPv4: Use ARP
probePacket = buildArpRequest(targetIp, host);
} else {
// IPv6: Use Neighbor Discovery
// TODO need to implement ndp probe
log.info("Triggering probe on device {} ", host);
return;
}
TrafficTreatment treatment = DefaultTrafficTreatment.builder().setOutput(host.location().port()).build();
OutboundPacket outboundPacket = new DefaultOutboundPacket(host.location().deviceId(), treatment, ByteBuffer.wrap(probePacket.serialize()));
packetService.emit(outboundPacket);
}
use of org.onosproject.net.packet.OutboundPacket in project onos by opennetworkinglab.
the class DefaultHostProbingProvider method sendLocationProbe.
/**
* Send the probe packet on given port.
*
* @param probe the probe packet
* @param connectPoint the port we want to probe
*/
private void sendLocationProbe(Ethernet probe, ConnectPoint connectPoint) {
log.debug("Sending probe for host {} on location {} with probeMac {}", probe.getDestinationMAC(), connectPoint, probe.getSourceMAC());
TrafficTreatment treatment = DefaultTrafficTreatment.builder().setOutput(connectPoint.port()).build();
OutboundPacket outboundPacket = new DefaultOutboundPacket(connectPoint.deviceId(), treatment, ByteBuffer.wrap(probe.serialize()));
packetService.emit(outboundPacket);
}
use of org.onosproject.net.packet.OutboundPacket in project onos by opennetworkinglab.
the class BasicInterpreterImpl method mapOutboundPacket.
@Override
public Collection<PiPacketOperation> mapOutboundPacket(OutboundPacket packet) throws PiInterpreterException {
TrafficTreatment treatment = packet.treatment();
// basic.p4 supports only OUTPUT instructions.
List<OutputInstruction> outInstructions = treatment.allInstructions().stream().filter(i -> i.type().equals(OUTPUT)).map(i -> (OutputInstruction) i).collect(toList());
if (treatment.allInstructions().size() != outInstructions.size()) {
// There are other instructions that are not of type OUTPUT.
throw new PiInterpreterException("Treatment not supported: " + treatment);
}
ImmutableList.Builder<PiPacketOperation> builder = ImmutableList.builder();
for (OutputInstruction outInst : outInstructions) {
if (outInst.port().isLogical() && !outInst.port().equals(FLOOD)) {
throw new PiInterpreterException(format("Output on logical port '%s' not supported", outInst.port()));
} else if (outInst.port().equals(FLOOD)) {
// Since basic.p4 does not support flooding, we create a packet
// operation for each switch port.
final DeviceService deviceService = handler().get(DeviceService.class);
for (Port port : deviceService.getPorts(packet.sendThrough())) {
builder.add(createPiPacketOperation(packet.data(), port.number().toLong()));
}
} else {
builder.add(createPiPacketOperation(packet.data(), outInst.port().toLong()));
}
}
return builder.build();
}
Aggregations