def _send_and_receive(self, target, lun, netfn, cmdid, payload):
        """Send and receive data using RMCP interface.

        target:
        lun:
        netfn:
        cmdid:
        raw_bytes: IPMI message payload as bytestring

        Returns the received data as array.
        """
        self._inc_sequence_number()

        header = IpmbHeaderReq()
        header.netfn = netfn
        header.rs_lun = lun
        header.rs_sa = target.ipmb_address
        header.rq_seq = self.next_sequence_number
        header.rq_lun = 0
        header.rq_sa = self.slave_address
        header.cmd_id = cmdid

        # Bridge message
        if target.routing:
            tx_data = encode_bridged_message(target.routing, header, payload,
                                             self.next_sequence_number)
        else:
            tx_data = encode_ipmb_msg(header, payload)

        self._send_ipmi_msg(tx_data)

        received = False
        while received is False:
            if not self._q.empty():
                rx_data = self._q.get()
            else:
                rx_data = self._receive_ipmi_msg()

            if array('B', rx_data)[5] == constants.CMDID_SEND_MESSAGE:
                rx_data = decode_bridged_message(rx_data)

            received = rx_filter(header, rx_data)

            if not received:
                self._q.put(rx_data)

        return rx_data[6:-1]
Send and receive data using RMCP interface.

        target:
        lun:
        netfn:
        cmdid:
        raw_bytes: IPMI message payload as bytestring

        Returns the received data as array.