def compose( self ):
    # Marshall the SMB2 header fields into a stream of bytes.
    #
    # Output: A string of bytes; the wire format of the SMB2 header.
    #
    # Notes:  It's probably okay if the dialect version isn't
    #         specified.  The default values of <channelSeq> and
    #         <reserved1> are zero, so the encoded format would be
    #         zero for either interpretation.
    #
    if( self.flagReply or (self._dialect < 0x0300) ):
      # Bytes 8..11 are <status>
      if( self.flagAsync ):
        # Bytes 32..39 are <async>
        msg = self._format_SMB2_StatAsync.pack( self._protocolId,
                                                self._headerSize,
                                                self._creditCharge,
                                                self._status,
                                                self._command,
                                                self._creditReqResp,
                                                self._flags,
                                                self._nextCommand,
                                                self._messageId,
                                                self._asyncId,
                                                self._sessionId,
                                                self._signature )
      else:
        # Bytes 32..39 are <reserved2>/<treeId>
        msg = self._format_SMB2_StatTreeId.pack( self._protocolId,
                                                 self._headerSize,
                                                 self._creditCharge,
                                                 self._status,
                                                 self._command,
                                                 self._creditReqResp,
                                                 self._flags,
                                                 self._nextCommand,
                                                 self._messageId,
                                                 self._reserved2,
                                                 self._treeId,
                                                 self._sessionId,
                                                 self._signature )
    else:
      # Bytes 8..11 are <channelSeq>/<reserved1>
      if( self.flagAsync ):
        # Bytes 32..39 are <async>
        msg = self._format_SMB2_cSeqAsync.pack( self._protocolId,
                                                self._headerSize,
                                                self._creditCharge,
                                                self._channelSeq,
                                                self._reserved1,
                                                self._command,
                                                self._creditReqResp,
                                                self._flags,
                                                self._nextCommand,
                                                self._messageId,
                                                self._asyncId,
                                                self._sessionId,
                                                self._signature )
      else:
        # Bytes 32..39 are <reserved2>/<treeId>
        msg = self._format_SMB2_cSeqTreeId.pack( self._protocolId,
                                                 self._headerSize,
                                                 self._creditCharge,
                                                 self._channelSeq,
                                                 self._reserved1,
                                                 self._command,
                                                 self._creditReqResp,
                                                 self._flags,
                                                 self._nextCommand,
                                                 self._messageId,
                                                 self._reserved2,
                                                 self._treeId,
                                                 self._sessionId,
                                                 self._signature )
    return( msg )