def send(self, packet): """ Send a packet via a PACKET_OUT OpenFlow message. We use the PacketOut members and use net.es.netshell.odlmdsal.impl.EthernetFrame to help us put a VLAN header on the front :param packet: common.openflow.PacketOut :return: True if successful, False if not """ # print "ODLClient.send with packet from " + str(packet.dl_src) + " to " + str(packet.dl_dst) + " on " + packet.scope.switch.props['dpid'] if self.isPacketOutValid(packet): # Get the switch (Node in the ODL world) and port (NodeConnector in the ODL world) sw = self.findODLSwitch(packet.scope.switch) dpid = packet.scope.switch.props['dpid'][-8:] if sw == None: print packet, "cannot be sent because the switch is not in inventory" return False portName = packet.port.name nodeconn = self.odlController.getNodeConnector(sw, portName) if nodeconn == None: ODLClient.logger.warning('can not send %r because the port %s on %r is invalid' % (packet, portName, sw.getId())) return False # Create the outgoing packet in ODL land. The outgoing node connector must be set. frame = EthernetFrame() frame.setDstMac(self.javaByteArray(packet.dl_dst.data)) frame.setSrcMac(self.javaByteArray(packet.dl_src.data)) frame.setEtherType(packet.etherType) frame.setVid(packet.vlan) frame.setPayload(packet.payload) self.odlController.transmitDataPacket(self.javaByteArray(dpid), portName, frame.toPacket()) return True ODLClient.logger.warning("Packet %r is not valid" % packet) return False