def send(self, pkt):
        """Send a packet"""

        # Use the routing table to find the output interface
        iff = pkt.route()[0]
        if iff is None:
            iff = conf.iface

        # Assign the network interface to the BPF handle
        if self.assigned_interface != iff:
            try:
                fcntl.ioctl(self.outs, BIOCSETIF, struct.pack("16s16x", iff.encode()))  # noqa: E501
            except IOError:
                raise Scapy_Exception("BIOCSETIF failed on %s" % iff)
            self.assigned_interface = iff

        # Build the frame
        frame = raw(self.guessed_cls() / pkt)
        pkt.sent_time = time.time()

        # Send the frame
        L2bpfSocket.send(self, frame)
def send ( self , pkt ) : iff = pkt . route ( ) [ 0 ] if iff is None : iff = conf . iface if self . assigned_interface != iff : try : fcntl . ioctl ( self . outs , BIOCSETIF , struct . pack ( "16s16x" , iff . encode ( ) ) ) except IOError : raise Scapy_Exception ( "BIOCSETIF failed on %s" % iff ) self . assigned_interface = iff frame = raw ( self . guessed_cls ( ) / pkt ) pkt . sent_time = time . time ( ) L2bpfSocket . send ( self , frame )
Send a packet