Export (0) Print
Expand All

6.3.7 Name Compression and Decompression

The server can choose any compression algorithm, as long as the compressed stream can be decompressed using the following name decompression algorithm. When the server compresses the names for the LDAP ping response, if compression fails, the response of the server is documented in "Response to Invalid filter" (section 6.3.3.3). When the server compresses the names for the mailslot ping response, if compression fails, the server does not send any response back to the client.

Name Decompression Algorithm

--
--  On Entry: InputBuffer - a buffer of compressed data, treated as 
--                bytes
--            InputBufferSize - The number of bytes in the InputBuffer
--            StringCount - number of strings needed to be 
--                decompressed from InputBuffer
--            Current – Index into the buffer that contains the first 
--                byte of the compressed strings
--
--  On Exit:  OutputBuffers - an array of decompressed strings
--            Success -  Set to TRUE if decompression succeeds, set to
--                FALSE if decompression fails.
--            Current – Index of the byte in the message succeeding the last
--                byte of the compressed string block



SET deCompressedCount = 0
SET localCurrent = 0
FOR i = 1 to StringCount
    SET dnsNameLen = 0
    SET firstLabel = 0
    allocate a buffer s[InputBufferSize]
    WHILE Current < InputBufferSize
        SET labelSize = InputBuffer[Current]
        IF labelSize == '\0' THEN                           
            s[dnsNameLen] = '\0'
            OutputBuffers[deCompressedCount] = s
            deCompressedCount++
            Current++
            BREAK
        ELSE IF (labelSize & 0xC0) != 0 THEN
            Current++
            localCurrent = Current + 1
            labelSize = InputBuffer[Current]
            IF labelSize > InputBufferSize THEN
                Success = FALSE  
                RETURN        
            END IF
            Current = labelSize
            CONTINUE
        ELSE
            IF (labelSize + Current) >= InputBufferSize THEN
                Success = FALSE  
                RETURN
            END IF
            IF firstLabel == 0 THEN
                firstLabel = 1
            ELSE
                s[dnsNameLen] = '.'
                dnsNameLen++
            ENDIF

            Append
              substring InputBuffer[Current + 1, Current + labelSize]
                to s
            dnsNameLen += labelSize       
            IF localCurrent != 0 THEN
                Current = localCurrent
                localCurrent = 0       
            ELSE
                Current = Current + 1 + labelSize     
            END IF
        END IF                                    
    END WHILE
    If i <> deCompressedCount THEN
        Success = FALSE
        RETURN
    ENDIF
END FOR
Success = TRUE
RETURN
 
Show:
© 2014 Microsoft