16 #ifdef USE_CMP_TRANSPORT
32 #define CMP_TCP_VERSION 10
33 #define CMP_HEADER_SIZE 7
34 #define CMP_MIN_PACKET_SIZE 7
36 enum { CMPMSG_PKIREQ, CMPMSG_POLLREP, CMPMSG_POLLREQ, CMPMSG_FINREP,
37 CMPMSG_DUMMY, CMPMSG_PKIREP, CMPMSG_ERRORMSGREP };
43 const long lengthVal = length + 3;
52 *bufPtr++ = CMP_TCP_VERSION;
53 *bufPtr++ = lastMessage;
54 *bufPtr++ = CMPMSG_PKIREQ;
56 return( CMP_HEADER_SIZE );
70 status = stream->bufferedTransportReadFunction( stream, bufPtr,
76 if( headerLength < CMP_MIN_PACKET_SIZE || headerLength > maxLength || \
77 *bufPtr++ != CMP_TCP_VERSION )
84 headerType = *bufPtr++;
85 if( headerType < CMPMSG_PKIREQ || headerType > CMPMSG_ERRORMSGREP )
87 assert( CMP_MIN_PACKET_SIZE > 3 );
91 if( headerType == CMPMSG_PKIREQ || headerType == CMPMSG_PKIREP )
97 if( headerType == CMPMSG_ERRORMSGREP )
99 int unknownDataLength;
128 status = stream->bufferedTransportReadFunction( stream, bufPtr,
133 stream->errorInfo->errorCode = mgetWord( bufPtr );
134 unknownDataLength = mgetWord( bufPtr );
135 if( unknownDataLength < 0 )
138 headerLength -=
sizeof( WORD ) +
sizeof( WORD ) + unknownDataLength;
139 if( headerLength > 0 )
141 const int errorMessageLength = \
144 bufPtr += unknownDataLength;
145 memcpy( stream->errorInfo->errorMessage, bufPtr,
146 errorMessageLength );
147 stream->errorInfo->errorMessage[ errorMessageLength ] =
'\0';
152 "CMP transport-level protocol error encountered" );
159 return( ( ( stream->errorInfo->errorCode & 0x0F00 ) == 0x0300 ) ? \
175 static int readFunction(
STREAM *stream,
void *buffer,
int length )
180 status = readHeader( stream, buffer, &localLength, length );
185 return( stream->bufferedTransportReadFunction( stream, buffer,
192 static int writeFunction(
STREAM *stream,
const void *buffer,
195 BYTE headerBuffer[ 64 + 8 ];
199 headerLength = writeHeader( headerBuffer, length,
202 status = stream->bufferedTransportWriteFunction( stream, headerBuffer,
209 return( stream->bufferedTransportWriteFunction( stream, buffer, length,
213 int setStreamLayerCMP(
STREAM *stream )
216 stream->writeFunction = writeFunction;
217 stream->readFunction = readFunction;