BOOL tpdu_read_connection_confirm(wStream* s, BYTE* li) { BYTE code; int position; int bytes_read = 0; /* save the position to determine the number of bytes read */ position = Stream_GetPosition(s); if (!tpdu_read_header(s, &code, li)) return FALSE; if (code != X224_TPDU_CONNECTION_CONFIRM) { fprintf(stderr, "Error: expected X224_TPDU_CONNECTION_CONFIRM\n"); return FALSE; } /* * To ensure that there are enough bytes remaining for processing * check against the length indicator (li). Already read bytes need * to be taken into account. * The -1 is because li was read but isn't included in the TPDU size. * For reference see ITU-T Rec. X.224 - 13.2.1 */ bytes_read = (Stream_GetPosition(s) - position) - 1; return (Stream_GetRemainingLength(s) >= (*li - bytes_read)); }
UINT16 tpdu_read_data(STREAM* s) { BYTE code; UINT16 li; li = tpdu_read_header(s, &code); if (code != X224_TPDU_DATA) return 0; return li; }
uint16 tpdu_read_data(STREAM* s) { uint8 code; uint16 li; li = tpdu_read_header(s, &code); if (code != X224_TPDU_DATA) return 0; return li; }
BYTE tpdu_read_connection_confirm(STREAM* s) { BYTE li; BYTE code; li = tpdu_read_header(s, &code); if (code != X224_TPDU_CONNECTION_CONFIRM) { printf("Error: expected X224_TPDU_CONNECTION_CONFIRM\n"); return 0; } return li; }
BYTE tpdu_read_connection_request(STREAM* s) { BYTE li; BYTE code; li = tpdu_read_header(s, &code); if (code != X224_TPDU_CONNECTION_REQUEST) { printf("Error: expected X224_TPDU_CONNECTION_REQUEST\n"); return 0; } return li; }
BOOL tpdu_read_data(wStream* s, UINT16* LI) { BYTE code; BYTE li; if (!tpdu_read_header(s, &code, &li)) return FALSE; if (code != X224_TPDU_DATA) return FALSE; *LI = li; return TRUE; }
BOOL tpdu_read_connection_confirm(wStream* s, BYTE *li) { BYTE code; if(!tpdu_read_header(s, &code, li)) return FALSE; if (code != X224_TPDU_CONNECTION_CONFIRM) { fprintf(stderr, "Error: expected X224_TPDU_CONNECTION_CONFIRM\n"); return FALSE; } return (Stream_GetRemainingLength(s) >= *li); }
BOOL tpdu_read_connection_request(wStream* s, BYTE *li) { BYTE code; if(!tpdu_read_header(s, &code, li)) return FALSE; if (code != X224_TPDU_CONNECTION_REQUEST) { fprintf(stderr, "Error: expected X224_TPDU_CONNECTION_REQUEST\n"); return FALSE; } return TRUE; }