NTSTATUS smbd_smb2_request_process_flush(struct smbd_smb2_request *req) { NTSTATUS status; const uint8_t *inbody; int i = req->current_idx; uint64_t in_file_id_persistent; uint64_t in_file_id_volatile; struct tevent_req *subreq; status = smbd_smb2_request_verify_sizes(req, 0x18); if (!NT_STATUS_IS_OK(status)) { return smbd_smb2_request_error(req, status); } inbody = (const uint8_t *)req->in.vector[i+1].iov_base; in_file_id_persistent = BVAL(inbody, 0x08); in_file_id_volatile = BVAL(inbody, 0x10); if (req->compat_chain_fsp) { /* skip check */ } else if (in_file_id_persistent != in_file_id_volatile) { return smbd_smb2_request_error(req, NT_STATUS_FILE_CLOSED); } subreq = smbd_smb2_flush_send(req, req->sconn->ev_ctx, req, in_file_id_volatile); if (subreq == NULL) { return smbd_smb2_request_error(req, NT_STATUS_NO_MEMORY); } tevent_req_set_callback(subreq, smbd_smb2_request_flush_done, req); return smbd_smb2_request_pending_queue(req, subreq, 500); }
static void __etb_disable(void) { int count; uint32_t ffcr; ETB_UNLOCK(); ffcr = etb_readl(etb, ETB_FFCR); ffcr |= (BIT(12) | BIT(6)); etb_writel(etb, ffcr, ETB_FFCR); for (count = TIMEOUT_US; BVAL(etb_readl(etb, ETB_FFCR), 6) != 0 && count > 0; count--) udelay(1); WARN(count == 0, "timeout while flushing ETB, ETB_FFCR: %#x\n", etb_readl(etb, ETB_FFCR)); etb_writel(etb, 0x0, ETB_CTL_REG); for (count = TIMEOUT_US; BVAL(etb_readl(etb, ETB_FFSR), 1) != 1 && count > 0; count--) udelay(1); WARN(count == 0, "timeout while disabling ETB, ETB_FFSR: %#x\n", etb_readl(etb, ETB_FFSR)); ETB_LOCK(); }
/* Open a file using TRANSACT2_OPEN - async recv */ static NTSTATUS smb_raw_nttrans_create_recv(struct smbcli_request *req, TALLOC_CTX *mem_ctx, union smb_open *parms) { NTSTATUS status; struct smb_nttrans nt; uint8_t *params; status = smb_raw_nttrans_recv(req, mem_ctx, &nt); if (!NT_STATUS_IS_OK(status)) return status; if (nt.out.params.length < 69) { return NT_STATUS_INVALID_PARAMETER; } params = nt.out.params.data; parms->ntcreatex.out.oplock_level = CVAL(params, 0); parms->ntcreatex.out.file.fnum = SVAL(params, 2); parms->ntcreatex.out.create_action = IVAL(params, 4); parms->ntcreatex.out.create_time = smbcli_pull_nttime(params, 12); parms->ntcreatex.out.access_time = smbcli_pull_nttime(params, 20); parms->ntcreatex.out.write_time = smbcli_pull_nttime(params, 28); parms->ntcreatex.out.change_time = smbcli_pull_nttime(params, 36); parms->ntcreatex.out.attrib = IVAL(params, 44); parms->ntcreatex.out.alloc_size = BVAL(params, 48); parms->ntcreatex.out.size = BVAL(params, 56); parms->ntcreatex.out.file_type = SVAL(params, 64); parms->ntcreatex.out.ipc_state = SVAL(params, 66); parms->ntcreatex.out.is_directory = CVAL(params, 68); return NT_STATUS_OK; }
void smb2srv_lock_recv(struct smb2srv_request *req) { union smb_lock *io; int i; SMB2SRV_CHECK_BODY_SIZE(req, 0x30, false); SMB2SRV_TALLOC_IO_PTR(io, union smb_lock); SMB2SRV_SETUP_NTVFS_REQUEST(smb2srv_lock_send, NTVFS_ASYNC_STATE_MAY_ASYNC); io->smb2.level = RAW_LOCK_SMB2; io->smb2.in.lock_count = SVAL(req->in.body, 0x02); io->smb2.in.reserved = IVAL(req->in.body, 0x04); io->smb2.in.file.ntvfs = smb2srv_pull_handle(req, req->in.body, 0x08); if (req->in.body_size < 24 + 24*(uint64_t)io->smb2.in.lock_count) { DEBUG(0,("%s: lock buffer too small\n", __location__)); smb2srv_send_error(req, NT_STATUS_FOOBAR); return; } io->smb2.in.locks = talloc_array(io, struct smb2_lock_element, io->smb2.in.lock_count); if (io->smb2.in.locks == NULL) { smb2srv_send_error(req, NT_STATUS_NO_MEMORY); return; } for (i=0;i<io->smb2.in.lock_count;i++) { io->smb2.in.locks[i].offset = BVAL(req->in.body, 24 + i*24); io->smb2.in.locks[i].length = BVAL(req->in.body, 32 + i*24); io->smb2.in.locks[i].flags = IVAL(req->in.body, 40 + i*24); io->smb2.in.locks[i].reserved = IVAL(req->in.body, 44 + i*24); } SMB2SRV_CHECK_FILE_HANDLE(io->smb2.in.file.ntvfs); SMB2SRV_CALL_NTVFS_BACKEND(ntvfs_lock(req->ntvfs, io)); }
void server_id_get(struct server_id *id, const uint8_t buf[24]) { id->pid = BVAL(buf, 0); id->task_id = IVAL(buf, 8); id->vnn = IVAL(buf, 12); id->unique_id = BVAL(buf, 16); }
/* recv a create reply */ NTSTATUS smb2_create_recv(struct smb2_request *req, TALLOC_CTX *mem_ctx, struct smb2_create *io) { NTSTATUS status; if (!smb2_request_receive(req) || !smb2_request_is_ok(req)) { return smb2_request_destroy(req); } SMB2_CHECK_PACKET_RECV(req, 0x58, True); io->out.oplock_flags = SVAL(req->in.body, 0x02); io->out.create_action = IVAL(req->in.body, 0x04); io->out.create_time = smbcli_pull_nttime(req->in.body, 0x08); io->out.access_time = smbcli_pull_nttime(req->in.body, 0x10); io->out.write_time = smbcli_pull_nttime(req->in.body, 0x18); io->out.change_time = smbcli_pull_nttime(req->in.body, 0x20); io->out.alloc_size = BVAL(req->in.body, 0x28); io->out.size = BVAL(req->in.body, 0x30); io->out.file_attr = IVAL(req->in.body, 0x38); io->out._pad = IVAL(req->in.body, 0x3C); smb2_pull_handle(req->in.body+0x40, &io->out.file.handle); status = smb2_pull_o32s32_blob(&req->in, mem_ctx, req->in.body+0x50, &io->out.blob); if (!NT_STATUS_IS_OK(status)) { smb2_request_destroy(req); return status; } return smb2_request_destroy(req); }
void smb2srv_read_recv(struct smb2srv_request *req) { union smb_read *io; SMB2SRV_CHECK_BODY_SIZE(req, 0x30, True); SMB2SRV_TALLOC_IO_PTR(io, union smb_read); SMB2SRV_SETUP_NTVFS_REQUEST(smb2srv_read_send, NTVFS_ASYNC_STATE_MAY_ASYNC); io->smb2.level = RAW_READ_SMB2; io->smb2.in._pad = SVAL(req->in.body, 0x02); io->smb2.in.length = IVAL(req->in.body, 0x04); io->smb2.in.offset = BVAL(req->in.body, 0x08); io->smb2.in.file.ntvfs = smb2srv_pull_handle(req, req->in.body, 0x10); io->smb2.in.unknown1 = BVAL(req->in.body, 0x20); io->smb2.in.unknown2 = BVAL(req->in.body, 0x28); SMB2SRV_CHECK_FILE_HANDLE(io->smb2.in.file.ntvfs); /* preallocate the buffer for the backends */ io->smb2.out.data = data_blob_talloc(io, NULL, io->smb2.in.length); if (io->smb2.out.data.length != io->smb2.in.length) { SMB2SRV_CHECK(NT_STATUS_NO_MEMORY); } SMB2SRV_CALL_NTVFS_BACKEND(ntvfs_read(req->ntvfs, io)); }
NTSTATUS smbd_smb2_request_process_read(struct smbd_smb2_request *req) { NTSTATUS status; const uint8_t *inhdr; const uint8_t *inbody; int i = req->current_idx; uint32_t in_smbpid; uint32_t in_length; uint64_t in_offset; uint64_t in_file_id_persistent; uint64_t in_file_id_volatile; uint32_t in_minimum_count; uint32_t in_remaining_bytes; struct tevent_req *subreq; status = smbd_smb2_request_verify_sizes(req, 0x31); if (!NT_STATUS_IS_OK(status)) { return smbd_smb2_request_error(req, status); } inhdr = (const uint8_t *)req->in.vector[i+0].iov_base; inbody = (const uint8_t *)req->in.vector[i+1].iov_base; in_smbpid = IVAL(inhdr, SMB2_HDR_PID); in_length = IVAL(inbody, 0x04); in_offset = BVAL(inbody, 0x08); in_file_id_persistent = BVAL(inbody, 0x10); in_file_id_volatile = BVAL(inbody, 0x18); in_minimum_count = IVAL(inbody, 0x20); in_remaining_bytes = IVAL(inbody, 0x28); /* check the max read size */ if (in_length > lp_smb2_max_read()) { DEBUG(0,("here:%s: 0x%08X: 0x%08X\n", __location__, in_length, lp_smb2_max_read())); return smbd_smb2_request_error(req, NT_STATUS_INVALID_PARAMETER); } if (req->compat_chain_fsp) { /* skip check */ } else if (in_file_id_persistent != in_file_id_volatile) { return smbd_smb2_request_error(req, NT_STATUS_FILE_CLOSED); } subreq = smbd_smb2_read_send(req, req->sconn->smb2.event_ctx, req, in_smbpid, in_file_id_volatile, in_length, in_offset, in_minimum_count, in_remaining_bytes); if (subreq == NULL) { return smbd_smb2_request_error(req, NT_STATUS_NO_MEMORY); } tevent_req_set_callback(subreq, smbd_smb2_request_read_done, req); return smbd_smb2_request_pending_queue(req, subreq); }
static void __etb_disable(void) { int count; uint32_t ffcr; /* Avoid oopsing in panic() if called before the device is probed. */ if (!etb.base) return; ETB_UNLOCK(); ffcr = etb_readl(etb, ETB_FFCR); ffcr |= (BIT(12) | BIT(6)); etb_writel(etb, ffcr, ETB_FFCR); for (count = TIMEOUT_US; BVAL(etb_readl(etb, ETB_FFCR), 6) != 0 && count > 0; count--) udelay(1); WARN(count == 0, "timeout while flushing ETB, ETB_FFCR: %#x\n", etb_readl(etb, ETB_FFCR)); etb_writel(etb, 0x0, ETB_CTL_REG); for (count = TIMEOUT_US; BVAL(etb_readl(etb, ETB_FFSR), 1) != 1 && count > 0; count--) udelay(1); WARN(count == 0, "timeout while disabling ETB, ETB_FFSR: %#x\n", etb_readl(etb, ETB_FFSR)); ETB_LOCK(); }
NTSTATUS smbd_smb2_request_process_close(struct smbd_smb2_request *req) { const uint8_t *inbody; uint16_t in_flags; uint64_t in_file_id_persistent; uint64_t in_file_id_volatile; struct files_struct *in_fsp; NTSTATUS status; struct tevent_req *subreq; status = smbd_smb2_request_verify_sizes(req, 0x18); if (!NT_STATUS_IS_OK(status)) { return smbd_smb2_request_error(req, status); } inbody = SMBD_SMB2_IN_BODY_PTR(req); in_flags = SVAL(inbody, 0x02); in_file_id_persistent = BVAL(inbody, 0x08); in_file_id_volatile = BVAL(inbody, 0x10); in_fsp = file_fsp_smb2(req, in_file_id_persistent, in_file_id_volatile); if (in_fsp == NULL) { return smbd_smb2_request_error(req, NT_STATUS_FILE_CLOSED); } subreq = smbd_smb2_close_send(req, req->sconn->ev_ctx, req, in_fsp, in_flags); if (subreq == NULL) { return smbd_smb2_request_error(req, NT_STATUS_NO_MEMORY); } tevent_req_set_callback(subreq, smbd_smb2_request_close_done, req); return smbd_smb2_request_pending_queue(req, subreq, 500); }
static void smbd_smb2_request_oplock_break_done(struct tevent_req *subreq) { struct smbd_smb2_request *req = tevent_req_callback_data(subreq, struct smbd_smb2_request); const uint8_t *inbody; int i = req->current_idx; uint64_t in_file_id_persistent; uint64_t in_file_id_volatile; uint8_t out_oplock_level = 0; DATA_BLOB outbody; NTSTATUS status; NTSTATUS error; /* transport error */ status = smbd_smb2_oplock_break_recv(subreq, &out_oplock_level); TALLOC_FREE(subreq); if (!NT_STATUS_IS_OK(status)) { error = smbd_smb2_request_error(req, status); if (!NT_STATUS_IS_OK(error)) { smbd_server_connection_terminate(req->sconn, nt_errstr(error)); return; } return; } inbody = (const uint8_t *)req->in.vector[i+1].iov_base; in_file_id_persistent = BVAL(inbody, 0x08); in_file_id_volatile = BVAL(inbody, 0x10); outbody = data_blob_talloc(req->out.vector, NULL, 0x18); if (outbody.data == NULL) { error = smbd_smb2_request_error(req, NT_STATUS_NO_MEMORY); if (!NT_STATUS_IS_OK(error)) { smbd_server_connection_terminate(req->sconn, nt_errstr(error)); return; } return; } SSVAL(outbody.data, 0x00, 0x18); /* struct size */ SCVAL(outbody.data, 0x02, out_oplock_level); /* SMB2 oplock level */ SCVAL(outbody.data, 0x03, 0); /* reserved */ SIVAL(outbody.data, 0x04, 0); /* reserved */ SBVAL(outbody.data, 0x08, in_file_id_persistent); /* file id (persistent) */ SBVAL(outbody.data, 0x10, in_file_id_volatile); /* file id (volatile) */ error = smbd_smb2_request_done(req, outbody, NULL); if (!NT_STATUS_IS_OK(error)) { smbd_server_connection_terminate(req->sconn, nt_errstr(error)); return; } }
NTSTATUS smbd_smb2_request_process_read(struct smbd_smb2_request *req) { struct smbXsrv_connection *xconn = req->xconn; NTSTATUS status; const uint8_t *inbody; uint32_t in_length; uint64_t in_offset; uint64_t in_file_id_persistent; uint64_t in_file_id_volatile; struct files_struct *in_fsp; uint32_t in_minimum_count; uint32_t in_remaining_bytes; struct tevent_req *subreq; status = smbd_smb2_request_verify_sizes(req, 0x31); if (!NT_STATUS_IS_OK(status)) { return smbd_smb2_request_error(req, status); } inbody = SMBD_SMB2_IN_BODY_PTR(req); in_length = IVAL(inbody, 0x04); in_offset = BVAL(inbody, 0x08); in_file_id_persistent = BVAL(inbody, 0x10); in_file_id_volatile = BVAL(inbody, 0x18); in_minimum_count = IVAL(inbody, 0x20); in_remaining_bytes = IVAL(inbody, 0x28); /* check the max read size */ if (in_length > xconn->smb2.server.max_read) { DEBUG(2,("smbd_smb2_request_process_read: " "client ignored max read: %s: 0x%08X: 0x%08X\n", __location__, in_length, xconn->smb2.server.max_read)); return smbd_smb2_request_error(req, NT_STATUS_INVALID_PARAMETER); } status = smbd_smb2_request_verify_creditcharge(req, in_length); if (!NT_STATUS_IS_OK(status)) { return smbd_smb2_request_error(req, status); } in_fsp = file_fsp_smb2(req, in_file_id_persistent, in_file_id_volatile); if (in_fsp == NULL) { return smbd_smb2_request_error(req, NT_STATUS_FILE_CLOSED); } subreq = smbd_smb2_read_send(req, req->sconn->ev_ctx, req, in_fsp, in_length, in_offset, in_minimum_count, in_remaining_bytes); if (subreq == NULL) { return smbd_smb2_request_error(req, NT_STATUS_NO_MEMORY); } tevent_req_set_callback(subreq, smbd_smb2_request_read_done, req); return smbd_smb2_request_pending_queue(req, subreq, 500); }
NTSTATUS smbd_smb2_request_process_sesssetup(struct smbd_smb2_request *smb2req) { const uint8_t *inhdr; const uint8_t *inbody; uint64_t in_session_id; uint8_t in_flags; uint8_t in_security_mode; uint64_t in_previous_session_id; uint16_t in_security_offset; uint16_t in_security_length; DATA_BLOB in_security_buffer; NTSTATUS status; struct tevent_req *subreq; status = smbd_smb2_request_verify_sizes(smb2req, 0x19); if (!NT_STATUS_IS_OK(status)) { return smbd_smb2_request_error(smb2req, status); } inhdr = SMBD_SMB2_IN_HDR_PTR(smb2req); inbody = SMBD_SMB2_IN_BODY_PTR(smb2req); in_session_id = BVAL(inhdr, SMB2_HDR_SESSION_ID); in_flags = CVAL(inbody, 0x02); in_security_mode = CVAL(inbody, 0x03); /* Capabilities = IVAL(inbody, 0x04) */ /* Channel = IVAL(inbody, 0x08) */ in_security_offset = SVAL(inbody, 0x0C); in_security_length = SVAL(inbody, 0x0E); in_previous_session_id = BVAL(inbody, 0x10); if (in_security_offset != (SMB2_HDR_BODY + SMBD_SMB2_IN_BODY_LEN(smb2req))) { return smbd_smb2_request_error(smb2req, NT_STATUS_INVALID_PARAMETER); } if (in_security_length > SMBD_SMB2_IN_DYN_LEN(smb2req)) { return smbd_smb2_request_error(smb2req, NT_STATUS_INVALID_PARAMETER); } in_security_buffer.data = SMBD_SMB2_IN_DYN_PTR(smb2req); in_security_buffer.length = in_security_length; subreq = smbd_smb2_session_setup_wrap_send(smb2req, smb2req->sconn->ev_ctx, smb2req, in_session_id, in_flags, in_security_mode, in_previous_session_id, in_security_buffer); if (subreq == NULL) { return smbd_smb2_request_error(smb2req, NT_STATUS_NO_MEMORY); } tevent_req_set_callback(subreq, smbd_smb2_request_sesssetup_done, smb2req); return smbd_smb2_request_pending_queue(smb2req, subreq, 500); }
NTSTATUS smbd_smb2_request_process_notify(struct smbd_smb2_request *req) { struct smbXsrv_connection *xconn = req->xconn; NTSTATUS status; const uint8_t *inbody; uint16_t in_flags; uint32_t in_output_buffer_length; uint64_t in_file_id_persistent; uint64_t in_file_id_volatile; struct files_struct *in_fsp; uint64_t in_completion_filter; struct tevent_req *subreq; status = smbd_smb2_request_verify_sizes(req, 0x20); if (!NT_STATUS_IS_OK(status)) { return smbd_smb2_request_error(req, status); } inbody = SMBD_SMB2_IN_BODY_PTR(req); in_flags = SVAL(inbody, 0x02); in_output_buffer_length = IVAL(inbody, 0x04); in_file_id_persistent = BVAL(inbody, 0x08); in_file_id_volatile = BVAL(inbody, 0x10); in_completion_filter = IVAL(inbody, 0x18); /* * 0x00010000 is what Windows 7 uses, * Windows 2008 uses 0x00080000 */ if (in_output_buffer_length > xconn->smb2.server.max_trans) { return smbd_smb2_request_error(req, NT_STATUS_INVALID_PARAMETER); } status = smbd_smb2_request_verify_creditcharge(req, in_output_buffer_length); if (!NT_STATUS_IS_OK(status)) { return smbd_smb2_request_error(req, status); } in_fsp = file_fsp_smb2(req, in_file_id_persistent, in_file_id_volatile); if (in_fsp == NULL) { return smbd_smb2_request_error(req, NT_STATUS_FILE_CLOSED); } subreq = smbd_smb2_notify_send(req, req->sconn->ev_ctx, req, in_fsp, in_flags, in_output_buffer_length, in_completion_filter); if (subreq == NULL) { return smbd_smb2_request_error(req, NT_STATUS_NO_MEMORY); } tevent_req_set_callback(subreq, smbd_smb2_request_notify_done, req); return smbd_smb2_request_pending_queue(req, subreq, 500); }
s32 coresight_get_sysctrl_status(void) { u32 clk = 0; u32 rst = 0; u32 tcmos = 0; if(g_modem_sysctrl_cfg.mdm_ctrl_sys_virt_addr == NULL) { printk("sys ctrl base addr is null\n"); return BSP_ERROR; } clk = readl((u32)((u32)g_modem_sysctrl_cfg.mdm_ctrl_sys_virt_addr + g_modem_sysctrl_cfg.clk.offset)); rst = readl((u32)((u32)g_modem_sysctrl_cfg.mdm_ctrl_sys_virt_addr + g_modem_sysctrl_cfg.rst.offset)); tcmos = readl((u32)((u32)g_modem_sysctrl_cfg.mdm_ctrl_sys_virt_addr + g_modem_sysctrl_cfg.mtcmos.offset)); g_modem_sys_val[0] = clk; g_modem_sys_val[1] = rst; g_modem_sys_val[2] = tcmos; if(!BVAL(clk, g_modem_sysctrl_cfg.clk.mcpu_dbg_clk_status)) { cs_error("clk = %x,rst = %x,tcmos = %x\n",clk,rst,tcmos); cs_error("modem a9 mcpu_dbg_clk_status is disable,mcpu_dbg_clk_status=0x%x status=0x%x\n",g_modem_sysctrl_cfg.clk.mcpu_dbg_clk_status,clk); return BSP_ERROR; } if(!BVAL(clk, g_modem_sysctrl_cfg.clk.mcpu_pd_clk_status)) { cs_error("clk = %x,rst = %x,tcmos = %x\n",clk,rst,tcmos); cs_error("modem a9 mcpu_pd_clk_status is disable,bit=0x%x status=0x%x\n",g_modem_sysctrl_cfg.clk.mcpu_pd_clk_status,clk); return BSP_ERROR; } if(BVAL(rst, g_modem_sysctrl_cfg.rst.mdma9_pd_srst_status)) { cs_error("clk = %x,rst = %x,tcmos = %x\n",clk,rst,tcmos); cs_error("modem a9 mdma9_pd_srst_status is disable,bit=0x%x status =0x%x\n",g_modem_sysctrl_cfg.rst.mdma9_pd_srst_status,rst); return BSP_ERROR; } if(BVAL(rst, g_modem_sysctrl_cfg.rst.moda9_cpu_srst_status)) { cs_error("clk = %x,rst = %x,tcmos = %x\n",clk,rst,tcmos); cs_error("modem a9 moda9_cpu_srst_status is disable,bit=0x%x status =0x%x\n",g_modem_sysctrl_cfg.rst.moda9_cpu_srst_status,rst); return BSP_ERROR; } if(!BVAL(tcmos, g_modem_sysctrl_cfg.mtcmos.cpu_mtcmos_strl_status)) { cs_error("clk = %x,rst = %x,tcmos = %x\n",clk,rst,tcmos); cs_error("modem a9 moda9_cpu_srst_status is disable,bit=0x%x status = 0x%x",g_modem_sysctrl_cfg.mtcmos.cpu_mtcmos_strl_status,tcmos); return BSP_ERROR; } return BSP_OK; }
static void etm_os_lock_init(struct etm_ctx *etmdata) { uint32_t etmoslsr; etmoslsr = etm_readl(etmdata, TRCOSLSR); if ((BVAL(etmoslsr, 0) == 0) && BVAL(etmoslsr, 3)) etmdata->os_lock_present = true; else etmdata->os_lock_present = false; }
void annotate(void) { char buf[64]; int ypos, xpos; glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho((GLdouble) 0, (GLdouble) wscreen, (GLdouble) hscreen, (GLdouble) 0, (GLdouble) -1.0, (GLdouble) 1.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glPushMatrix(); glColor3f(RVAL(0xffffff), GVAL(0xffffff), BVAL(0xffffff)); if (actval == -1) { if (! strnull(getparam("ident"))) showtext(getparam("ident"), 10, 20); sprintf(buf, "%.2f", tnow); showtext(buf, wscreen - (8 * strlen(buf) + 10), 20); } else { ypos = hscreen - 10; if (vectoroff != -1) { sprintf(buf, "vector scale: %.2f", vscale); showtext(buf, 10, ypos); ypos -= 20; } if (scalaroff != -1 || dopcolor) { xpos = 10; sprintf(buf, "mapping: "); showtext(buf, xpos, ypos); xpos += 8 * strlen(buf); sprintf(buf, "%.2f", cmidpt + crange); glColor3f(RVAL(0x0000ff), GVAL(0x0000ff), BVAL(0x0000ff)); showtext(buf, xpos, ypos); xpos += 8 * strlen(buf); glColor3f(RVAL(0xffffff), GVAL(0xffffff), BVAL(0xffffff)); showtext(" to ", xpos, ypos); xpos += 32; sprintf(buf, "%.2f", cmidpt - crange); glColor3f(RVAL(0xff4f00), GVAL(0xff4f00), BVAL(0xff4f00)); showtext(buf, xpos, ypos); xpos += 8 * strlen(buf); ypos -= 20; glColor3f(RVAL(0xffffff), GVAL(0xffffff), BVAL(0xffffff)); } sprintf(buf, "angles: %.2f, %.2f, %.2f", thetax, thetay, thetaz); showtext(buf, 10, ypos); ypos -= 20; sprintf(buf, "view: %.2f, %.2f, %.2f; %.2f", xoff, yoff, dview, fview); showtext(buf, 10, ypos); ypos -= 20; } glPopMatrix(); }
NTSTATUS cli_get_fs_quota_info(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_STRUCT *pqt) { uint16_t setup[1]; uint8_t param[2]; uint8_t *rdata=NULL; uint32_t rdata_count=0; SMB_NTQUOTA_STRUCT qt; NTSTATUS status; ZERO_STRUCT(qt); if (!cli||!pqt) { smb_panic("cli_get_fs_quota_info() called with NULL Pointer!"); } SSVAL(setup + 0, 0, TRANSACT2_QFSINFO); SSVAL(param,0,SMB_FS_QUOTA_INFORMATION); status = cli_trans(talloc_tos(), cli, SMBtrans2, NULL, -1, /* name, fid */ 0, 0, /* function, flags */ setup, 1, 0, /* setup */ param, 2, 0, /* param */ NULL, 0, 560, /* data */ NULL, /* recv_flags2 */ NULL, 0, NULL, /* rsetup */ NULL, 0, NULL, /* rparam */ &rdata, 48, &rdata_count); if (!NT_STATUS_IS_OK(status)) { DEBUG(1, ("SMB_FS_QUOTA_INFORMATION failed: %s\n", nt_errstr(status))); return status; } /* unknown_1 24 NULL bytes in pdata*/ /* the soft quotas 8 bytes (uint64_t)*/ qt.softlim = BVAL(rdata,24); /* the hard quotas 8 bytes (uint64_t)*/ qt.hardlim = BVAL(rdata,32); /* quota_flags 2 bytes **/ qt.qflags = SVAL(rdata,40); qt.qtype = SMB_USER_FS_QUOTA_TYPE; *pqt = qt; TALLOC_FREE(rdata); return status; }
void my_bool_listener (PluginParam *param) { GtkCheckButton *editable; if (sdlGoom->config_win == 0) return; editable = GTK_CHECK_BUTTON(param->user_data); if (editable) { if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(editable)) != BVAL(*param)) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(editable),BVAL(*param)); } }
NTSTATUS smbd_smb2_request_process_break(struct smbd_smb2_request *req) { const uint8_t *inhdr; const uint8_t *inbody; int i = req->current_idx; size_t expected_body_size = 0x18; size_t body_size; uint8_t in_oplock_level; uint64_t in_file_id_persistent; uint64_t in_file_id_volatile; struct tevent_req *subreq; inhdr = (const uint8_t *)req->in.vector[i+0].iov_base; if (req->in.vector[i+1].iov_len != (expected_body_size & 0xFFFFFFFE)) { return smbd_smb2_request_error(req, NT_STATUS_INVALID_PARAMETER); } inbody = (const uint8_t *)req->in.vector[i+1].iov_base; body_size = SVAL(inbody, 0x00); if (body_size != expected_body_size) { return smbd_smb2_request_error(req, NT_STATUS_INVALID_PARAMETER); } in_oplock_level = CVAL(inbody, 0x02); if (in_oplock_level != SMB2_OPLOCK_LEVEL_NONE && in_oplock_level != SMB2_OPLOCK_LEVEL_II) { return smbd_smb2_request_error(req, NT_STATUS_INVALID_PARAMETER); } /* 0x03 1 bytes reserved */ /* 0x04 4 bytes reserved */ in_file_id_persistent = BVAL(inbody, 0x08); in_file_id_volatile = BVAL(inbody, 0x10); if (req->compat_chain_fsp) { /* skip check */ } else if (in_file_id_persistent != in_file_id_volatile) { return smbd_smb2_request_error(req, NT_STATUS_FILE_CLOSED); } subreq = smbd_smb2_oplock_break_send(req, req->sconn->smb2.event_ctx, req, in_oplock_level, in_file_id_volatile); if (subreq == NULL) { return smbd_smb2_request_error(req, NT_STATUS_NO_MEMORY); } tevent_req_set_callback(subreq, smbd_smb2_request_oplock_break_done, req); return smbd_smb2_request_pending_queue(req, subreq); }
static bool parse_user_quota_record(const uint8_t *rdata, unsigned int rdata_count, unsigned int *offset, SMB_NTQUOTA_STRUCT *pqt) { int sid_len; SMB_NTQUOTA_STRUCT qt; ZERO_STRUCT(qt); if (!rdata||!offset||!pqt) { smb_panic("parse_quota_record: called with NULL POINTER!"); } if (rdata_count < 40) { return False; } /* offset to next quota record. * 4 bytes IVAL(rdata,0) * unused here... */ *offset = IVAL(rdata,0); /* sid len */ sid_len = IVAL(rdata,4); if (rdata_count < 40+sid_len) { return False; } /* unknown 8 bytes in pdata * maybe its the change time in NTTIME */ /* the used space 8 bytes (uint64_t)*/ qt.usedspace = BVAL(rdata,16); /* the soft quotas 8 bytes (uint64_t)*/ qt.softlim = BVAL(rdata,24); /* the hard quotas 8 bytes (uint64_t)*/ qt.hardlim = BVAL(rdata,32); if (!sid_parse((const char *)rdata+40,sid_len,&qt.sid)) { return false; } qt.qtype = SMB_USER_QUOTA_TYPE; *pqt = qt; return True; }
void render(void) { int step, oldc, newc; bodyptr bp; float cval; glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective((GLdouble) fview, (GLdouble) ((double) wscreen) / hscreen, (GLdouble) 0.01 * dview, (GLdouble) 100.0 * dview); glGetFloatv(GL_PROJECTION_MATRIX, &projmat[0][0]); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glClear(GL_COLOR_BUFFER_BIT); glPushMatrix(); glTranslatef(xoff, yoff, -dview); glRotatef(-thetaz, 0.0, 0.0, 1.0); /* same map as snaprotate */ glRotatef(-thetay, 0.0, 1.0, 0.0); glRotatef(-thetax, 1.0, 0.0, 0.0); glGetFloatv(GL_MODELVIEW_MATRIX, &viewmat[0][0]); glBegin(vectoroff == -1 ? GL_POINTS : GL_LINES); step = (actval == -1 ? 1 : rceil((float) nbody / (float) maxfast)); oldc = -1; for (bp = btab; bp < NthBody(btab, nbody); bp = NthBody(bp, step)) { if (scalaroff == -1 && ! dopcolor) newc = Key(bp); else { if (! dopcolor) cval = (SelectReal(bp, scalaroff) - cmidpt) / crange; else cval = (dotvp(Vel(bp), znorm) - cmidpt) / crange; newc = (cval > 1.0 ? 0x0000ff : cval > 0.6 ? 0x006fdf : cval > 0.2 ? 0x00cf7f : cval > -0.2 ? 0x00ff00 : cval > -0.6 ? 0x7fcf00 : cval > -1.0 ? 0xbf8f00 : 0xff4f00); } if (oldc != newc) glColor3f(RVAL(newc), GVAL(newc), BVAL(newc)); oldc = newc; glVertex3f(Pos(bp)[0], Pos(bp)[1], Pos(bp)[2]); if (vectoroff != -1) glVertex3f(Pos(bp)[0] + vscale * SelectVect(bp, vectoroff)[0], Pos(bp)[1] + vscale * SelectVect(bp, vectoroff)[1], Pos(bp)[2] + vscale * SelectVect(bp, vectoroff)[2]); } glEnd(); if (actval != -1) { glColor3f(RVAL(bcolor), GVAL(bcolor), BVAL(bcolor)); glutWireCube(refscale); } glPopMatrix(); }
NTSTATUS smbd_smb2_request_process_close(struct smbd_smb2_request *req) { const uint8_t *inhdr; const uint8_t *inbody; int i = req->current_idx; uint8_t *outhdr; DATA_BLOB outbody; size_t expected_body_size = 0x18; size_t body_size; uint16_t in_flags; uint64_t in_file_id_persistent; uint64_t in_file_id_volatile; NTSTATUS status; inhdr = (const uint8_t *)req->in.vector[i+0].iov_base; if (req->in.vector[i+1].iov_len != (expected_body_size & 0xFFFFFFFE)) { return smbd_smb2_request_error(req, NT_STATUS_INVALID_PARAMETER); } inbody = (const uint8_t *)req->in.vector[i+1].iov_base; body_size = SVAL(inbody, 0x00); if (body_size != expected_body_size) { return smbd_smb2_request_error(req, NT_STATUS_INVALID_PARAMETER); } outbody = data_blob_talloc(req->out.vector, NULL, 0x3C); if (outbody.data == NULL) { return smbd_smb2_request_error(req, NT_STATUS_NO_MEMORY); } in_flags = SVAL(inbody, 0x02); in_file_id_persistent = BVAL(inbody, 0x08); in_file_id_volatile = BVAL(inbody, 0x10); if (req->compat_chain_fsp) { /* skip check */ } else if (in_file_id_persistent != in_file_id_volatile) { return smbd_smb2_request_error(req, NT_STATUS_FILE_CLOSED); } status = smbd_smb2_close(req, in_flags, in_file_id_volatile, &outbody); if (!NT_STATUS_IS_OK(status)) { return smbd_smb2_request_error(req, status); } outhdr = (uint8_t *)req->out.vector[i].iov_base; return smbd_smb2_request_done(req, outbody, NULL); }
NTSTATUS smbd_smb2_request_process_notify(struct smbd_smb2_request *req) { NTSTATUS status; const uint8_t *inbody; int i = req->current_idx; uint16_t in_flags; uint32_t in_output_buffer_length; uint64_t in_file_id_persistent; uint64_t in_file_id_volatile; uint64_t in_completion_filter; struct tevent_req *subreq; status = smbd_smb2_request_verify_sizes(req, 0x20); if (!NT_STATUS_IS_OK(status)) { return smbd_smb2_request_error(req, status); } inbody = (const uint8_t *)req->in.vector[i+1].iov_base; in_flags = SVAL(inbody, 0x02); in_output_buffer_length = IVAL(inbody, 0x04); in_file_id_persistent = BVAL(inbody, 0x08); in_file_id_volatile = BVAL(inbody, 0x10); in_completion_filter = IVAL(inbody, 0x18); /* * 0x00010000 is what Windows 7 uses, * Windows 2008 uses 0x00080000 */ if (in_output_buffer_length > lp_smb2_max_trans()) { return smbd_smb2_request_error(req, NT_STATUS_INVALID_PARAMETER); } if (req->compat_chain_fsp) { /* skip check */ } else if (in_file_id_persistent != in_file_id_volatile) { return smbd_smb2_request_error(req, NT_STATUS_FILE_CLOSED); } subreq = smbd_smb2_notify_send(req, req->sconn->smb2.event_ctx, req, in_flags, in_output_buffer_length, in_file_id_volatile, in_completion_filter); if (subreq == NULL) { return smbd_smb2_request_error(req, NT_STATUS_NO_MEMORY); } tevent_req_set_callback(subreq, smbd_smb2_request_notify_done, req); return smbd_smb2_request_pending_queue(req, subreq); }
struct smb_request *smbd_smb2_fake_smb_request(struct smbd_smb2_request *req) { struct smb_request *smbreq; const uint8_t *inhdr = SMBD_SMB2_IN_HDR_PTR(req); if (req->smb1req) { smbreq = req->smb1req; } else { smbreq = talloc_zero(req, struct smb_request); if (smbreq == NULL) { return NULL; } } smbreq->request_time = req->request_time; smbreq->vuid = req->session->compat->vuid; smbreq->tid = req->tcon->compat->cnum; smbreq->conn = req->tcon->compat; smbreq->sconn = req->sconn; smbreq->xconn = req->xconn; smbreq->smbpid = (uint16_t)IVAL(inhdr, SMB2_HDR_PID); smbreq->flags2 = FLAGS2_UNICODE_STRINGS | FLAGS2_32_BIT_ERROR_CODES | FLAGS2_LONG_PATH_COMPONENTS | FLAGS2_IS_LONG_NAME; if (IVAL(inhdr, SMB2_HDR_FLAGS) & SMB2_HDR_FLAG_DFS) { smbreq->flags2 |= FLAGS2_DFS_PATHNAMES; } smbreq->mid = BVAL(inhdr, SMB2_HDR_MESSAGE_ID); smbreq->chain_fsp = req->compat_chain_fsp; smbreq->smb2req = req; req->smb1req = smbreq; return smbreq; }
void smb2srv_read_recv(struct smb2srv_request *req) { union smb_read *io; SMB2SRV_CHECK_BODY_SIZE(req, 0x30, true); /* MS-SMB2 2.2.19 read must have a single byte of zero */ if (req->in.body_size - req->in.body_fixed < 1) { smb2srv_send_error(req, NT_STATUS_INVALID_PARAMETER); return; } SMB2SRV_TALLOC_IO_PTR(io, union smb_read); SMB2SRV_SETUP_NTVFS_REQUEST(smb2srv_read_send, NTVFS_ASYNC_STATE_MAY_ASYNC); io->smb2.level = RAW_READ_SMB2; io->smb2.in._pad = SVAL(req->in.body, 0x02); io->smb2.in.length = IVAL(req->in.body, 0x04); io->smb2.in.offset = BVAL(req->in.body, 0x08); io->smb2.in.file.ntvfs = smb2srv_pull_handle(req, req->in.body, 0x10); io->smb2.in.min_count = IVAL(req->in.body, 0x20); io->smb2.in.channel = IVAL(req->in.body, 0x24); io->smb2.in.remaining = IVAL(req->in.body, 0x28); io->smb2.in.channel_offset = SVAL(req->in.body, 0x2C); io->smb2.in.channel_length = SVAL(req->in.body, 0x2E); SMB2SRV_CHECK_FILE_HANDLE(io->smb2.in.file.ntvfs); /* preallocate the buffer for the backends */ io->smb2.out.data = data_blob_talloc(io, NULL, io->smb2.in.length); if (io->smb2.out.data.length != io->smb2.in.length) { SMB2SRV_CHECK(NT_STATUS_NO_MEMORY); } SMB2SRV_CALL_NTVFS_BACKEND(ntvfs_read(req->ntvfs, io)); }
void smb2srv_ioctl_recv(struct smb2srv_request *req) { union smb_ioctl *io; struct smb2_handle h; SMB2SRV_CHECK_BODY_SIZE(req, 0x38, True); SMB2SRV_TALLOC_IO_PTR(io, union smb_ioctl); SMB2SRV_SETUP_NTVFS_REQUEST(smb2srv_ioctl_send, NTVFS_ASYNC_STATE_MAY_ASYNC); /* TODO: avoid the memcpy */ io->smb2.in._pad = SVAL(req->in.body, 0x02); io->smb2.in.function = IVAL(req->in.body, 0x04); /* file handle ... */ SMB2SRV_CHECK(smb2_pull_o32s32_blob(&req->in, io, req->in.body+0x18, &io->smb2.in.out)); io->smb2.in.unknown2 = IVAL(req->in.body, 0x20); SMB2SRV_CHECK(smb2_pull_o32s32_blob(&req->in, io, req->in.body+0x24, &io->smb2.in.in)); io->smb2.in.max_response_size = IVAL(req->in.body, 0x2C); io->smb2.in.flags = BVAL(req->in.body, 0x30); smb2_pull_handle(req->in.body + 0x08, &h); if (h.data[0] == UINT64_MAX && h.data[1] == UINT64_MAX) { io->smb2.level = RAW_IOCTL_SMB2_NO_HANDLE; } else { io->smb2.level = RAW_IOCTL_SMB2; io->smb2.in.file.ntvfs = smb2srv_pull_handle(req, req->in.body, 0x08); SMB2SRV_CHECK_FILE_HANDLE(io->smb2.in.file.ntvfs); } SMB2SRV_CALL_NTVFS_BACKEND(ntvfs_ioctl(req->ntvfs, io)); }
/* 0 on success, nonzero on error */ int check_types(struct lp_block *b) { int c = 0; /* we'll do all of the type checking here so that * the per-mod loaders only have to sanitize values */ for(c = 0; c < b->params_len; c++) { if(b->params[c]) { if(lp_param_name(b->type, b->params[c]->name) == -1) { fprintf(stderr, "*** warning: parameter %s not valid in context %s\n", b->params[c]->name, lp_modules[b->type]->name); } else if(lp_modules[b->type]->modvars[lp_param_name(b->type, b->params[c]->name)].type != PTYPE(b->params[c])) { /* implicitly convert ints to doubles */ if((lp_modules[b->type]->modvars[lp_param_name(b->type, b->params[c]->name)].type == D) && (PTYPE(b->params[c]) == I)) { b->params[c]->v->t = D; DVAL(b->params[c]) = (double) IVAL(b->params[c]); } else { fprintf(stderr, "*** error: type error: %s::\"%s\" cannot take type ", lp_modules[b->type]->name, b->params[c]->name); /* unparse_type(PTYPE(b->params[c]), stderr); */ fprintf(stderr, "\n"); die("check_types() failed"); } } if(PTYPE(b->params[c]) >= BLOCK) { check_types(BVAL(b->params[c])); } else if(PTYPE(b->params[c]) == LIST) { int d; struct lp_list *l = LVAL(b->params[c]); for(d = 0; d < l->values_len; d++) { if(l->values[d]) { if(l->values[d]->t >= BLOCK) { check_types(l->values[d]->v.b); } } } } } } return 0; }
void canblend(canvas *dst, canvas *src, float fr, float fg, float fb, float fa) { if(!cansizecheck(dst, src, "canmult: canvases must be the same size\n")) return; unsigned int *dptr = dst->data; unsigned int *sptr = src->data; int npix = dst->sizex*dst->sizey; while(npix--) { float fas = fa*AVAL(*sptr)/255.0; int rd = round(fr*RVAL(*sptr) + (1.0-fas)*RVAL(*dptr)); int gd = round(fg*GVAL(*sptr) + (1.0-fas)*GVAL(*dptr)); int bd = round(fb*BVAL(*sptr) + (1.0-fas)*BVAL(*dptr)); int ad = round(fa*AVAL(*sptr) + (1.0-fas)*AVAL(*dptr)); *dptr++ = CPACK(rd, gd, bd, ad); sptr++; } }
void on_bool_toggled (GtkToggleButton *togglebutton, gpointer user_data) { PluginParam *param = (PluginParam*)gtk_object_get_data (GTK_OBJECT(togglebutton),"param"); BVAL(*param) = gtk_toggle_button_get_active(togglebutton); param->changed(param); }