@Override public DefaultOutboundPacket read(Kryo kryo, Input input, Class<DefaultOutboundPacket> type) { DeviceId sendThrough = (DeviceId) kryo.readClassAndObject(input); TrafficTreatment treatment = (TrafficTreatment) kryo.readClassAndObject(input); byte[] data = (byte[]) kryo.readClassAndObject(input); return new DefaultOutboundPacket(sendThrough, treatment, ByteBuffer.wrap(data)); }
private void sendPacketOut(DeviceId deviceId, PortNumber portNumber, Ethernet payload) { TrafficTreatment treatment = DefaultTrafficTreatment.builder() .setOutput(portNumber).build(); OutboundPacket packet = new DefaultOutboundPacket(deviceId, treatment, ByteBuffer .wrap(payload .serialize())); packetService.emit(packet); }
private OutboundPacket packet(TrafficTreatment.Builder builder, ConnectPoint point, ByteBuffer data) { builder.setOutput(point.port()); return new DefaultOutboundPacket(point.deviceId(), builder.build(), data); }
@Override public void handlePacketIn(Bmv2Device device, int inputPort, ImmutableByteSequence packet) { Ethernet ethPkt = new Ethernet(); ethPkt.deserialize(packet.asArray(), 0, packet.size()); DeviceId deviceId = device.asDeviceId(); ConnectPoint receivedFrom = new ConnectPoint(deviceId, PortNumber.portNumber(inputPort)); ByteBuffer rawData = ByteBuffer.wrap(packet.asArray()); InboundPacket inPkt = new DefaultInboundPacket(receivedFrom, ethPkt, rawData); OutboundPacket outPkt = new DefaultOutboundPacket(deviceId, null, rawData); PacketContext pktCtx = new Bmv2PacketContext(System.currentTimeMillis(), inPkt, outPkt, false); providerService.processPacket(pktCtx); } }
.filter(port -> !port.equals(inPort)) .map(outPort -> DefaultTrafficTreatment.builder().setOutput(outPort).build()) .map(outTreatment -> new DefaultOutboundPacket(deviceId, outTreatment, rawData)) .forEach(Bmv2PacketProvider.this::emit); } else { emit(new DefaultOutboundPacket(deviceId, treatment, rawData));
/** * Send packet back to classifier. * * @param context packet context */ private void sendPacket(PacketContext context) { ConnectPoint sourcePoint = context.inPacket().receivedFrom(); TrafficTreatment treatment = DefaultTrafficTreatment.builder().setOutput(PortNumber.TABLE).build(); OutboundPacket packet = new DefaultOutboundPacket(sourcePoint.deviceId(), treatment, context.inPacket() .unparsed()); packetService.emit(packet); log.trace("Sending packet: {}", packet); } }
/** * Creates packet_out BDDP for specified output port. * * @param port the port * @return Packet_out message with LLDP data */ private OutboundPacket createOutBoundBddp(Long port) { if (port == null) { return null; } ONOSLLDP lldp = getLinkProbe(port); bddpEth.setSourceMACAddress(context.fingerprint()).setPayload(lldp); return new DefaultOutboundPacket(device.id(), builder().setOutput(portNumber(port)).build(), ByteBuffer.wrap(bddpEth.serialize())); }
/** * Creates packet_out LLDP for specified output port. * * @param port the port * @return Packet_out message with LLDP data */ private OutboundPacket createOutBoundLldp(Long port) { if (port == null) { return null; } ONOSLLDP lldp = getLinkProbe(port); ethPacket.setSourceMACAddress(context.fingerprint()).setPayload(lldp); return new DefaultOutboundPacket(device.id(), builder().setOutput(portNumber(port)).build(), ByteBuffer.wrap(ethPacket.serialize())); }
/** * Outputs a packet out a specific port. * * @param packet packet to send * @param outPort port to send it out */ private void sendTo(ByteBuffer packet, ConnectPoint outPort) { if (!edgeService.isEdgePoint(outPort)) { // Sanity check to make sure we don't send the packet out an // internal port and create a loop (could happen due to // misconfiguration). return; } TrafficTreatment.Builder builder = DefaultTrafficTreatment.builder(); builder.setOutput(outPort.port()); packetService.emit(new DefaultOutboundPacket(outPort.deviceId(), builder.build(), packet)); }
@Override public void handlePacket(OpenFlowPacketContext pktCtx) { DeviceId id = DeviceId.deviceId(Dpid.uri(pktCtx.dpid().value())); DefaultInboundPacket inPkt = new DefaultInboundPacket( new ConnectPoint(id, PortNumber.portNumber(pktCtx.inPort())), pktCtx.parsed(), ByteBuffer.wrap(pktCtx.unparsed()), pktCtx.cookie()); DefaultOutboundPacket outPkt = null; if (!pktCtx.isBuffered()) { outPkt = new DefaultOutboundPacket(id, null, ByteBuffer.wrap(pktCtx.unparsed())); } OpenFlowCorePacketContext corePktCtx = new OpenFlowCorePacketContext(System.currentTimeMillis(), inPkt, outPkt, pktCtx.isHandled(), pktCtx); providerService.processPacket(corePktCtx); }
new DefaultOutboundPacket(connectPoint.deviceId(), treatment, ByteBuffer.wrap(probePacket.serialize()));
.build(); packetService.emit(new DefaultOutboundPacket( pkt.receivedFrom().deviceId(), treatment,