diff --git a/libfreerdp-core/CMakeLists.txt b/libfreerdp-core/CMakeLists.txt index b2894a769..00d35b2b7 100644 --- a/libfreerdp-core/CMakeLists.txt +++ b/libfreerdp-core/CMakeLists.txt @@ -24,6 +24,10 @@ add_definitions(-DL_ENDIAN=1) add_definitions(-DEXT_PATH="/usr/lib/freerdp/extensions") set(LIBFREERDP_CORE_SRCS + ber.c + ber.h + mcs.c + mcs.h nego.c nego.h # credssp.c diff --git a/libfreerdp-core/ber.c b/libfreerdp-core/ber.c new file mode 100644 index 000000000..cc5c756bb --- /dev/null +++ b/libfreerdp-core/ber.c @@ -0,0 +1,49 @@ +/** + * FreeRDP: A Remote Desktop Protocol Client + * ASN.1 Basic Encoding Rules (BER) + * + * Copyright 2011 Marc-Andre Moreau + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ber.h" + +void +ber_write_length(STREAM* s, int length) +{ + if (length > 0xFF) + { + stream_write_uint8(s, 0x82); + stream_write_uint16_be(s, length); + } + else + { + stream_write_uint8(s, length); + } +} + +void +ber_write_universal_tag(STREAM* s, uint8 tag, int length) +{ + stream_write_uint8(s, (BER_CLASS_UNIV | BER_PRIMITIVE) & (BER_TAG_MASK & tag)); + ber_write_length(s, length); +} + +void +ber_write_application_tag(STREAM* s, uint8 tag, int length) +{ + stream_write_uint8(s, (BER_CLASS_APPL | BER_CONSTRUCT) & BER_TAG_MASK); + stream_write_uint8(s, tag); + ber_write_length(s, length); +} diff --git a/libfreerdp-core/ber.h b/libfreerdp-core/ber.h new file mode 100644 index 000000000..2bbfa2713 --- /dev/null +++ b/libfreerdp-core/ber.h @@ -0,0 +1,52 @@ +/** + * FreeRDP: A Remote Desktop Protocol Client + * ASN.1 Basic Encoding Rules (BER) + * + * Copyright 2011 Marc-Andre Moreau + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __BER_H +#define __BER_H + +#include + +/* BER type */ + +/* Class - bits 8 and 7 */ +#define BER_CLASS_MASK 0xC0 +#define BER_CLASS_UNIV 0x00 /* 0 0 */ +#define BER_CLASS_APPL 0x40 /* 0 1 */ +#define BER_CLASS_CTXT 0x80 /* 1 0 */ +#define BER_CLASS_PRIV 0xC0 /* 1 1 */ + +/* P/C - bit 6 */ +#define BER_PC_MASK 0x20 +#define BER_PRIMITIVE 0x00 /* 0 */ +#define BER_CONSTRUCT 0x20 /* 1 */ + +/* Tag - bits 5 to 1 */ +#define BER_TAG_MASK 0x1F +#define BER_TAG_BOOLEAN 0x01 +#define BER_TAG_INTEGER 0x02 +#define BER_TAG_OCTET_STRING 0x04 + +void +ber_write_length(STREAM* s, int length); +void +ber_write_universal_tag(STREAM* s, uint8 tag, int length); +void +ber_write_application_tag(STREAM* s, uint8 tag, int length); + +#endif /* __BER_H */ diff --git a/libfreerdp-core/mcs.c b/libfreerdp-core/mcs.c new file mode 100644 index 000000000..5a2004fa6 --- /dev/null +++ b/libfreerdp-core/mcs.c @@ -0,0 +1,28 @@ +/** + * FreeRDP: A Remote Desktop Protocol Client + * T.125 Multipoint Communication Service (MCS) Protocol + * + * Copyright 2011 Marc-Andre Moreau + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "mcs.h" + +/** + * T.125 MCS is defined in: + * + * http://www.itu.int/rec/T-REC-T.125-199802-I/ + * ITU-T T.125 Multipoint Communication Service Protocol Specification + */ + diff --git a/libfreerdp-core/mcs.h b/libfreerdp-core/mcs.h new file mode 100644 index 000000000..7457b798e --- /dev/null +++ b/libfreerdp-core/mcs.h @@ -0,0 +1,30 @@ +/** + * FreeRDP: A Remote Desktop Protocol Client + * T.125 Multipoint Communication Service (MCS) Protocol + * + * Copyright 2011 Marc-Andre Moreau + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __MCS_H +#define __MCS_H + +#include "ber.h" + +#include + +#define MCS_BER_CONNECT_INITIAL 0x65 +#define MCS_BER_CONNECT_RESPONSE 0x66 + +#endif /* __MCS_H */