libfreerdp-core: documented BER, PER, GCC, TPDU, TPKT, NEGO

This commit is contained in:
Marc-André Moreau 2011-07-04 21:35:32 -04:00
parent 25a5bc53b1
commit bd172ff55f
8 changed files with 152 additions and 20 deletions

4
.gitignore vendored
View File

@ -11,8 +11,12 @@ Makefile
*.project
*.cproject
# Doxygen
docs/api
# Binaries
*.so
*.so.*
*.dylib
cunit/test_freerdp
freerdp-ui/test/freerdp-test

View File

@ -19,6 +19,12 @@
#include "ber.h"
/**
* Write BER length.
* @param s stream
* @param length length
*/
void
ber_write_length(STREAM* s, int length)
{
@ -33,6 +39,13 @@ ber_write_length(STREAM* s, int length)
}
}
/**
* Write BER Universal tag.
* @param s stream
* @param tag BER universally-defined tag
* @param length length
*/
void
ber_write_universal_tag(STREAM* s, uint8 tag, int length)
{
@ -40,6 +53,13 @@ ber_write_universal_tag(STREAM* s, uint8 tag, int length)
ber_write_length(s, length);
}
/**
* Write BER Application tag.
* @param s stream
* @param tag BER application-defined tag
* @param length length
*/
void
ber_write_application_tag(STREAM* s, uint8 tag, int length)
{

View File

@ -91,8 +91,6 @@
*
*/
/* http://msdn.microsoft.com/en-us/library/cc240836/ */
/*
* OID = 0.0.20.124.0.1
* { itu-t(0) recommendation(0) t(20) t124(124) version(0) 1 }
@ -100,6 +98,13 @@
*/
uint8 t124_02_98_oid[6] = { 0, 0, 20, 124, 0, 1 };
/**
* Write a GCC Conference Create Request.\n
* @msdn{cc240836}
* @param s stream
* @param user_data client data blocks
*/
void
gcc_write_create_conference_request(STREAM* s, STREAM* user_data)
{

View File

@ -182,9 +182,11 @@ void nego_attempt_rdp(rdpNego *nego)
}
/**
* Receive protocol security negotiation message.
* @param nego
* @param s
* Receive protocol security negotiation message.\n
* @msdn{cc240501}
* @param transport transport
* @param s stream
* @param extra nego pointer
*/
int nego_recv(rdpTransport * transport, STREAM* s, void * extra)
@ -234,6 +236,13 @@ void nego_send(rdpNego *nego)
nego_attempt_rdp(nego);
}
/**
* Send RDP Negotiation Request (RDP_NEG_REQ).\n
* @msdn{cc240500}\n
* @msdn{cc240470}
* @param nego
*/
void nego_send_negotiation_request(rdpNego *nego)
{
STREAM* s;

View File

@ -19,6 +19,12 @@
#include "per.h"
/**
* Write PER length.
* @param s stream
* @param length length
*/
void
per_write_length(STREAM* s, int length)
{
@ -28,24 +34,48 @@ per_write_length(STREAM* s, int length)
stream_write_uint8(s, length);
}
/**
* Write PER CHOICE.
* @param s stream
* @param choice index of chosen field
*/
void
per_write_choice(STREAM* s, uint8 choice)
{
stream_write_uint8(s, choice);
}
/**
* Write PER selection for OPTIONAL fields.
* @param s stream
* @param selection bit map of selected fields
*/
void
per_write_selection(STREAM* s, uint8 selection)
{
stream_write_uint8(s, selection);
}
/**
* Write PER number of sets for SET OF.
* @param s stream
* @param number number of sets
*/
void
per_write_number_of_sets(STREAM* s, uint8 number)
{
stream_write_uint8(s, number);
}
/**
* Write PER padding with zeros.
* @param s stream
* @param length
*/
void
per_write_padding(STREAM* s, int length)
{
@ -55,6 +85,12 @@ per_write_padding(STREAM* s, int length)
stream_write_uint8(s, 0);
}
/**
* Write PER OBJECT_IDENTIFIER (OID)
* @param s stream
* @param oid object identifier (oid)
*/
void
per_write_object_identifier(STREAM* s, uint8 oid[6])
{
@ -67,6 +103,13 @@ per_write_object_identifier(STREAM* s, uint8 oid[6])
stream_write_uint8(s, oid[5]); /* tuple 6 */
}
/**
* Write PER string.
* @param s stream
* @param str string
* @param length string length
*/
void
per_write_string(STREAM* s, uint8* str, int length)
{
@ -76,6 +119,14 @@ per_write_string(STREAM* s, uint8* str, int length)
stream_write_uint8(s, str[i]);
}
/**
* Write PER OCTET_STRING
* @param s stream
* @param oct_str octet string
* @param length string length
* @param min minimum string length
*/
void
per_write_octet_string(STREAM* s, uint8* oct_str, int length, int min)
{
@ -90,6 +141,14 @@ per_write_octet_string(STREAM* s, uint8* oct_str, int length, int min)
stream_write_uint8(s, oct_str[i]);
}
/**
* Write PER NumericString.
* @param s stream
* @param num_str numeric string
* @param length string length
* @param min minimum string length
*/
void
per_write_numeric_string(STREAM* s, uint8* num_str, int length, int min)
{

View File

@ -55,6 +55,13 @@
* | ... |
*/
/**
* Read TPDU header.
* @param s stream
* @param code variable pointer to receive TPDU code
* @return TPDU length indicator (LI)
*/
uint8
tpdu_read_header(STREAM* s, uint8* code)
{
@ -77,6 +84,13 @@ tpdu_read_header(STREAM* s, uint8* code)
return li;
}
/**
* Write TDPU header.
* @param s stream
* @param length length
* @param code TPDU code
*/
void
tpdu_write_header(STREAM* s, uint16 length, uint8 code)
{
@ -95,12 +109,24 @@ tpdu_write_header(STREAM* s, uint16 length, uint8 code)
}
}
/**
* Write Connection Request TPDU.
* @param s stream
* @param length TPDU length
*/
void
tpdu_write_connection_request(STREAM* s, uint16 length)
{
tpdu_write_header(s, length, X224_TPDU_CONNECTION_REQUEST);
}
/**
* Read Connection Confirm TPDU.
* @param s stream
* @return length indicator (LI)
*/
uint8
tpdu_read_connection_confirm(STREAM* s)
{
@ -118,12 +144,24 @@ tpdu_read_connection_confirm(STREAM* s)
return li;
}
/**
* Write Disconnect Request TPDU.
* @param s stream
* @param length TPDU length
*/
void
tpdu_write_disconnect_request(STREAM* s, uint16 length)
{
tpdu_write_header(s, length, X224_TPDU_DISCONNECT_REQUEST);
}
/**
* Write Data TPDU.
* @param s stream
* @param length TPDU length
*/
void
tpdu_write_data(STREAM* s, uint16 length)
{

View File

@ -53,6 +53,12 @@
* length includes the TPKT header (4 bytes), the maximum X.224 TPDU length is 65531.
*/
/**
* Read a TPKT header.\n
* @param s
* @return length
*/
uint16
tpkt_read_header(STREAM* s)
{
@ -75,6 +81,12 @@ tpkt_read_header(STREAM* s)
return length;
}
/**
* Write a TPKT header.\n
* @param s
* @param length
*/
void
tpkt_write_header(STREAM* s, int length)
{
@ -82,13 +94,3 @@ tpkt_write_header(STREAM* s, int length)
stream_write_uint8(s, 0); /* reserved */
stream_write_uint16_be(s, length); /* length */
}
int
tpkt_recv(rdpTransport * transport, STREAM* s)
{
uint16 length;
length = tpkt_read_header(s);
freerdp_hexdump(s->buffer, length);
}

View File

@ -32,9 +32,4 @@ tpkt_read_header(STREAM* s);
void
tpkt_write_header(STREAM* s, int length);
void
tpkt_send_connection_request(rdpTransport * transport);
int
tpkt_recv(rdpTransport * transport, STREAM* s);
#endif /* __TPKT_H */