Export (0) Print
Expand All

4.1.10.5.18 TransformOutput

procedure TransformOutput(
  msgOut: DRS_MSG_GETCHGREPLY_V6,
  flags: DRS_OPTIONS,
  pdwOutVersion: ADDRESS OF DWORD,
  pmsgOut: ADDRESS OF DRS_MSG_GETCHGREPLY): ULONG

Informative summary of behavior: The TransformOutput procedure transforms the V6 reply (a superset of all supported reply messages) into the reply version supported by the client, optionally compressing it. The compression algorithms used for the DRS_COMP_ALG_WIN2K3 algorithm type are specified in section 4.1.10.5.19. The compression algorithm used for the DRS_COMP_ALG_MSZIP algorithm type is specified in [RFC1951].

pickled: sequence of BYTE
compressed: sequence of BYTE
allowedAlgs: set of DRS_COMP_ALG_TYPE
compressAlg: DRS_COMP_ALG_TYPE
compress: boolean

/* The SMTP transport [MS-SRPL] performs its own compression. */
compress := DRS_USE_COMPRESSION in flags 
            and not DRS_MAIL_REP in flags

if pdwOutVersion^ < dc.minimumGetChangesReplyVersion
    return ERROR_REVISION_MISMATCH

if pdwOutVersion^ = 6 then
  /* Return V6 (uncompressed) or V7 (compressed V6). */
  if compress then
    /* Return V7 (compressed V6). */
    if not DRS_EXT_GETCHGREPLY_V7 in ext.dwFlags then
      return ERROR_REVISION_MISMATCH
    endif

    /* Serialize msgOut into a byte stream. */
    pickled := Pickling of msgOut, as specified by
        [C311] Part 2, "IDL/NDR Pickles", and
        [MS-RPCE] sections 2.2.6 and 2.2.7, "Type Serialization
        Version 1" and "Type Serialization Version 2"

    /* Select a compression algorithm. */
    allowedAlgs := {DRS_COMP_ALG_NONE, DRS_COMP_ALG_MSZIP}
    if DRS_EXT_W2K3_DEFLATE in ext.dwFlags then
      allowedAlgs := allowedAlgs + {DRS_COMP_ALG_WIN2K3}
    endif
    compressAlg := One of allowedAlgs, selected by an
        implementation-defined policy.

    /* Compress the serialized msgOut. */
    if (compressionAlg = DRS_COMP_ALG_MSZIP) then
      compressed :=
        Compress pickled in accordance
        with [RFC1951].
    else
      CompressOrDecompressWin2k3(pickled, compressed, pickled.length, TRUE)
    endif
    pdwOutVersion^ := 7
    pmsgOut^.V7.dwCompressedVersion := 6
    pmsgOut^.V7.CompressionAlg := compressAlg
    pmsgOut^.V7.CompressedAny.cbUncompressedSize := pickled.length
    pmsgOut^.V7.CompressedAny.cbCompressedSize := compressed.length
    pmsgOut^.V7.CompressedAny.pbCompressedData := bytes in compressed
  else
    /* Return V6 (uncompressed). */
    pdwOutVersion^ := 6
    pmsgOut^.V6 := msgOut
  endif  
else
  /* Return V1 (uncompressed) or V2 (compressed V1). */ 
  /* First, convert to V1. */
  pdwOutVersion^ := 1
  pmsgOut^.V1 := msgOut
  pmsgOut^.V1.pUpToDateVecSrc := Convert msgOut.pUpToDateVecSrc (of
      type UPTODATE_VECTOR_V1_EXT) to UPTODATE_VECTOR_V2_EXT by
      creating a new UPTODATE_VECTOR_V1_EXT with a V1 cursor for each
      V2 cursor, sans the timeLastSyncSuccess field.
  /* V1 has the NC size in the ulExtendedRet field. */
  if msgOut.cNumNcSizeObjects > 0 then
    pmsgOut^.V1.ulExtendedRet := msgOut.cNumNcSizeObjects
  endif

  if compress then
    /* Serialize msgOut into a byte stream. */
    pickled := Pickling of pmsgOut^.V1, as specified by
        [C311] Part 2, "IDL/NDR Pickles" and
        [MS-RPCE] sections 2.2.6 and 2.2.7, "Type Serialization
        Version 1" and "Type Serialization Version 2"

    /* Select a compression algorithm. */
    allowedAlgs := {DRS_COMP_ALG_NONE, DRS_COMP_ALG_MSZIP}
    compressAlg := One of allowedAlgs, selected by an 
                   implementation-defined policy.

    /* Compress the serialized msgOut. */
    if (compressionAlg = DRS_COMP_ALG_MSZIP) then
      compressed :=
        Compress pickled in accordance
        with [RFC1951].
    else
      CompressOrDecompressWin2k3(pickled, compressed, pickled.length, TRUE)
    endif
    pdwOutVersion^ := 2
    pmsgOut^.V2.CompressedV1.cbUncompressedSize := pickled.length
    pmsgOut^.V2.CompressedV1.cbCompressedSize := compressed.length
    pmsgOut^.V2.CompressedV1.pbCompressedData := bytes in compressed
  endif
endif

return 0
 
Show:
© 2015 Microsoft