32 |
32 |
33 COSTProtocol::~COSTProtocol() |
33 COSTProtocol::~COSTProtocol() |
34 { |
34 { |
35 |
35 |
36 } |
36 } |
37 BOOL COSTProtocol::DecodeMessage(BYTE* fullMessage, DWORD& fullMessageLength, BYTE& msgId, BYTE*& rawMessage, DWORD& rawLength) |
37 int COSTProtocol::DecodeMessage(BYTE* fullMessage, DWORD& fullMessageLength, BYTE& msgId, BYTE*& rawMessage, DWORD& rawLength) |
38 { |
38 { |
39 BOOL found = FALSE; |
39 int result = DECODE_MESSAGE_NOT_FOUND; |
40 |
40 |
41 WORD msgLen = MAKEWORD(fullMessage[OST_LEN_BYTE_1+1], fullMessage[OST_LEN_BYTE_1]); |
41 WORD msgLen = MAKEWORD(fullMessage[OST_LEN_BYTE_1+1], fullMessage[OST_LEN_BYTE_1]); |
42 if (fullMessageLength >= (WORD)(msgLen + OST_HDR_LEN_1)) |
42 if (fullMessageLength >= (WORD)(msgLen + OST_HDR_LEN_1)) |
43 { |
43 { |
44 msgId = fullMessage[OST_PROT_BYTE_1]; |
44 msgId = fullMessage[OST_PROT_BYTE_1]; |
45 rawMessage = &fullMessage[OST_MSG_BYTE_1]; |
45 rawMessage = &fullMessage[OST_MSG_BYTE_1]; |
46 rawLength = msgLen; |
46 rawLength = msgLen; |
47 fullMessageLength = msgLen+OST_HDR_LEN_1; |
47 fullMessageLength = msgLen+OST_HDR_LEN_1; |
48 found = TRUE; |
48 result = DECODE_MESSAGE_FOUND; |
|
49 } |
|
50 else |
|
51 { |
|
52 result = DECODE_NOT_ENOUGH_BYTES_TO_SEARCH; |
49 } |
53 } |
50 |
54 |
51 return found; |
55 return result; |
52 } |
56 } |
53 |
57 |
54 DWORD COSTProtocol::EncodeMessage(BYTE* rawMessage, DWORD rawLength, BYTE protocolVersion, BYTE msgId, BYTE* fullMessage, DWORD maxFullLength) |
58 DWORD COSTProtocol::EncodeMessage(BYTE* rawMessage, DWORD rawLength, BYTE protocolVersion, BYTE msgId, BYTE* fullMessage, DWORD maxFullLength) |
55 { |
59 { |
56 DWORD outLength = 0; |
60 DWORD outLength = 0; |