title: Creating SCSI 10 byte CDB
body: <p>I am new to SCSI CDB programming . I have some piece of code written for write command using 6byte CDB </p>
  
  <pre><code>ccb = (Exec_IO_CCB *)(buffer + header_size);   
  ccb-&gt;ccb_length = sizeof(Exec_IO_CCB);          
  ccb-&gt;cam_opcode = 0x1;    
  ccb-&gt;connect_id = 0;    
  ccb-&gt;data_buf_ptr = (long)(header_size + ccb-&gt;ccb_length + MAX_SENSE_LEN);    
  ccb-&gt;data_xfer_length = (long)(XFER_BUFSIZE - ccb-&gt;data_buf_ptr);    
  ccb-&gt;sense_buf_ptr = (long)(header_size + ccb-&gt;ccb_length);    
  ccb-&gt;sense_buf_length = MAX_SENSE_LEN;    
  ccb-&gt;time_out = CAM_TIMEOUT;    
  ccb-&gt;cdb_length = 6;    
  ccb-&gt;cam_flags = DATA_OUT;    
  ccb-&gt;cdb[0] = 0xA;   /*  0xA SCSI Opcode for write operation */    
  ccb-&gt;cdb[1] = 0;    
  ccb-&gt;cdb[2] = (ccb-&gt;data_xfer_length &amp; 0xFF0000) &gt;&gt; 16;    
  ccb-&gt;cdb[3] = (ccb-&gt;data_xfer_length &amp; 0xFF00) &gt;&gt; 8;    
  ccb-&gt;cdb[4] = (ccb-&gt;data_xfer_length &amp; 0xFF);    
  ccb-&gt;cdb[5] = 0;
  </code></pre>
  
  <p>From the above code I did not understand how cdb[2] and cdb[3] are derived ?</p>
  
  <p>On a similar line, I am trying to develope 10 Byte CDB for write command.
  How to fill in the data for cdb[2-5] which accounts for LBA?</p>
  
  <pre><code>ccb-&gt;cam_flags = DATA_OUT;    
  ccb-&gt;cdb[0] = 0x2A;     /*  0x2A SCSI Opcode for write10  CDB */    
  ccb-&gt;cdb[1] = 0;    
  ccb-&gt;cdb[2] =  ??    
  ccb-&gt;cdb[3] =  ??    
  ccb-&gt;cdb[4] =  ??    
  ccb-&gt;cdb[5] =  ??    
  ccb-&gt;cdb[6] = 0;    
  ccb-&gt;cdb[7] = (ccb-&gt;data_xfer_length &amp; 0xFF);    
  ccb-&gt;cdb[8] = (ccb-&gt;data_xfer_length &amp; 0xFF);    
  ccb-&gt;cdb[9] = 0;
  </code></pre>