o moved from GNU General Public License to Apache License, Version 2.0
o applied new coding standards to all .c files o moved some files around
This commit is contained in:
@@ -1,372 +1,176 @@
|
||||
Apache License, Version 2.0
|
||||
|
||||
special clause for libxrdp and librdp, both based on rdesktop
|
||||
these libraries link to openssl
|
||||
Version 2.0, January 2004
|
||||
|
||||
This software is released under the GNU General Public License
|
||||
(reproduced below) with the additional exemption that compiling,
|
||||
linking, and/or using OpenSSL together with this software is
|
||||
allowed.
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
---
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
special clause for xrdp, that main executable
|
||||
for linking with proprietary modules
|
||||
1. Definitions.
|
||||
|
||||
Linking this library statically or dynamically with other modules
|
||||
is making a combined work based on this library. Thus, the terms
|
||||
and conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
"License" shall mean the terms and conditions for use, reproduction, and
|
||||
distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
As a special exception, the copyright holders of this library
|
||||
give you permission to link this library with independent modules
|
||||
to produce an executable, regardless of the license terms of
|
||||
these independent modules, and to copy and distribute the resulting
|
||||
executable under terms of your choice, provided that you also meet,
|
||||
for each linked independent module, the terms and conditions of the
|
||||
license of that module. An independent module is a module which is
|
||||
not derived from or based on this library. If you modify this
|
||||
library, you may extend this exception to your version of the
|
||||
library, but you are not obliged to do so. If you do not wish
|
||||
to do so, delete this exception statement from your version.
|
||||
"Licensor" shall mean the copyright owner or entity authorized by the
|
||||
copyright owner that is granting the License.
|
||||
|
||||
---
|
||||
"Legal Entity" shall mean the union of the acting entity and all other
|
||||
entities that control, are controlled by, or are under common control
|
||||
with that entity. For the purposes of this definition, "control" means
|
||||
(i) the power, direct or indirect, to cause the direction or management
|
||||
of such entity, whether by contract or otherwise, or (ii) ownership of
|
||||
fifty percent (50%) or more of the outstanding shares, or
|
||||
(iii) beneficial ownership of such entity.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
"You" (or "Your") shall mean an individual or Legal Entity exercising
|
||||
permissions granted by this License.
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
675 Mass Ave, Cambridge, MA 02139, USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation source,
|
||||
and configuration files.
|
||||
|
||||
Preamble
|
||||
"Object" form shall mean any form resulting from mechanical transformation
|
||||
or translation of a Source form, including but not limited to compiled
|
||||
object code, generated documentation, and conversions to other media types.
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Library General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
"Work" shall mean the work of authorship, whether in Source or Object form,
|
||||
made available under the License, as indicated by a copyright notice that is
|
||||
included in or attached to the work (an example is provided in the Appendix below).
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
"Derivative Works" shall mean any work, whether in Source or Object form,
|
||||
that is based on (or derived from) the Work and for which the editorial
|
||||
revisions, annotations, elaborations, or other modifications represent, as a
|
||||
whole, an original work of authorship. For the purposes of this License,
|
||||
Derivative Works shall not include works that remain separable from, or
|
||||
merely link (or bind by name) to the interfaces of, the Work and
|
||||
Derivative Works thereof.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
"Contribution" shall mean any work of authorship, including the original
|
||||
version of the Work and any modifications or additions to that Work or Derivative
|
||||
Works thereof, that is intentionally submitted to Licensor for inclusion in the
|
||||
Work by the copyright owner or by an individual or Legal Entity authorized to
|
||||
submit on behalf of the copyright owner. For the purposes of this definition,
|
||||
"submitted" means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems, and
|
||||
issue tracking systems that are managed by, or on behalf of, the Licensor for
|
||||
the purpose of discussing and improving the Work, but excluding communication
|
||||
that is conspicuously marked or otherwise designated in writing by the copyright
|
||||
owner as "Not a Contribution."
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf
|
||||
of whom a Contribution has been received by Licensor and subsequently incorporated
|
||||
within the Work.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of this License,
|
||||
each Contributor hereby grants to You a perpetual, worldwide, non-exclusive,
|
||||
no-charge, royalty-free, irrevocable copyright license to reproduce, prepare
|
||||
Derivative Works of, publicly display, publicly perform, sublicense, and distribute
|
||||
the Work and such Derivative Works in Source or Object form.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
3. Grant of Patent License. Subject to the terms and conditions of this License,
|
||||
each Contributor hereby grants to You a perpetual, worldwide, non-exclusive,
|
||||
no-charge, royalty-free, irrevocable (except as stated in this section) patent
|
||||
license to make, have made, use, offer to sell, sell, import, and otherwise transfer
|
||||
the Work, where such license applies only to those patent claims licensable by such
|
||||
Contributor that are necessarily infringed by their Contribution(s) alone or by
|
||||
combination of their Contribution(s) with the Work to which such Contribution(s) was
|
||||
submitted. If You institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution
|
||||
incorporated within the Work constitutes direct or contributory patent infringement,
|
||||
then any patent licenses granted to You under this License for that Work shall
|
||||
terminate as of the date such litigation is filed.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative
|
||||
Works thereof in any medium, with or without modifications, and in Source or Object
|
||||
form, provided that You meet the following conditions:
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
You must give any other recipients of the Work or Derivative Works a copy of this
|
||||
License; and
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
You must cause any modified files to carry prominent notices stating that You changed
|
||||
the files; and
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
You must retain, in the Source form of any Derivative Works that You distribute,
|
||||
all copyright, patent, trademark, and attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of the Derivative Works; and
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
If the Work includes a "NOTICE" text file as part of its distribution, then any
|
||||
Derivative Works that You distribute must include a readable copy of the attribution
|
||||
notices contained within such NOTICE file, excluding those notices that do not pertain
|
||||
to any part of the Derivative Works, in at least one of the following places: within a
|
||||
NOTICE text file distributed as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or, within a display
|
||||
generated by the Derivative Works, if and wherever such third-party notices normally
|
||||
appear. The contents of the NOTICE file are for informational purposes only and do not
|
||||
modify the License. You may add Your own attribution notices within Derivative Works
|
||||
that You distribute, alongside or as an addendum to the NOTICE text from the Work,
|
||||
provided that such additional attribution notices cannot be construed as modifying
|
||||
the License. You may add Your own copyright statement to Your modifications and may
|
||||
provide additional or different license terms and conditions for use, reproduction,
|
||||
or distribution of Your modifications, or for any such Derivative Works as a whole,
|
||||
provided Your use, reproduction, and distribution of the Work otherwise complies
|
||||
with the conditions stated in this License.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution
|
||||
intentionally submitted for inclusion in the Work by You to the Licensor shall be under
|
||||
the terms and conditions of this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify the terms of any
|
||||
separate license agreement you may have executed with Licensor regarding such Contributions.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
6. Trademarks. This License does not grant permission to use the trade names, trademarks,
|
||||
service marks, or product names of the Licensor, except as required for reasonable and
|
||||
customary use in describing the origin of the Work and reproducing the content of
|
||||
the NOTICE file.
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing,
|
||||
Licensor provides the Work (and each Contributor provides its Contributions) on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
|
||||
including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT,
|
||||
MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for
|
||||
determining the appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
8. Limitation of Liability. In no event and under no legal theory, whether in tort
|
||||
(including negligence), contract, or otherwise, unless required by applicable law
|
||||
(such as deliberate and grossly negligent acts) or agreed to in writing, shall any
|
||||
Contributor be liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a result of this
|
||||
License or out of the use or inability to use the Work (including but not limited to
|
||||
damages for loss of goodwill, work stoppage, computer failure or malfunction, or any
|
||||
and all other commercial damages or losses), even if such Contributor has been advised
|
||||
of the possibility of such damages.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
9. Accepting Warranty or Additional Liability. While redistributing the Work or
|
||||
Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance
|
||||
of support, warranty, indemnity, or other liability obligations and/or rights consistent
|
||||
with this License. However, in accepting such obligations, You may act only on Your
|
||||
own behalf and on Your sole responsibility, not on behalf of any other Contributor,
|
||||
and only if You agree to indemnify, defend, and hold each Contributor harmless for any
|
||||
liability incurred by, or claims asserted against, such Contributor by reason of your
|
||||
accepting any such warranty or additional liability.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
APPENDIX: How to apply the Apache License to your work
|
||||
To apply the Apache License to your work, attach the following boilerplate notice,
|
||||
with the fields enclosed by brackets "[]" replaced with your own identifying
|
||||
information. (Don't include the brackets!) The text should be enclosed in the
|
||||
appropriate comment syntax for the file format. We also recommend that a file or class
|
||||
name and description of purpose be included on the same "printed page" as the
|
||||
copyright notice for easier identification within third-party archives.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
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
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
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.
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
Appendix: How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) 19yy <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) 19yy name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Library General
|
||||
Public License instead of this License.
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,59 @@
|
||||
|
||||
# detached brackets
|
||||
--style=allman
|
||||
|
||||
# 4 spaces, no tabs
|
||||
--indent=spaces=4
|
||||
|
||||
# for C++ files only
|
||||
--indent-classes
|
||||
|
||||
# Indent 'switch' blocks so that the 'case X:' statements are indented in the switch block.
|
||||
# The entire case block is indented.
|
||||
--indent-switches
|
||||
|
||||
# Add extra indentation to namespace blocks. This option has no effect on Java files.
|
||||
--indent-namespaces
|
||||
|
||||
# Converts tabs into spaces in the non-indentation part of the line.
|
||||
--convert-tabs
|
||||
|
||||
# requires --convert-tabs to work properly
|
||||
--indent-preprocessor
|
||||
|
||||
--indent-col1-comments
|
||||
|
||||
--min-conditional-indent=2
|
||||
|
||||
--max-instatement-indent=40
|
||||
|
||||
# Pad empty lines around header blocks (e.g. 'if', 'for', 'while'...).
|
||||
--break-blocks
|
||||
|
||||
# Insert space padding around operators.
|
||||
--pad-oper
|
||||
|
||||
# Insert space padding after paren headers only (e.g. 'if', 'for', 'while'...).
|
||||
--pad-header
|
||||
|
||||
|
||||
# Add brackets to unbracketed one line conditional statements (e.g. 'if', 'for', 'while'...).
|
||||
--add-brackets
|
||||
|
||||
--align-pointer=name
|
||||
|
||||
# Do not retain a backup of the original file. The original file is purged after it is formatted.
|
||||
--suffix=none
|
||||
|
||||
# For each directory in the command line, process all subdirectories recursively.
|
||||
--recursive
|
||||
|
||||
# Preserve the original file's date and time modified.
|
||||
--preserve-date
|
||||
|
||||
# Formatted files display mode. Display only the files that have been formatted.
|
||||
# Do not display files that are unchanged.
|
||||
--formatted
|
||||
|
||||
--lineend=linux
|
||||
|
||||
+17
-22
@@ -1,25 +1,20 @@
|
||||
/*
|
||||
Copyright (c) 2004-2010 Jay Sorg
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#if !defined(ARCH_H)
|
||||
#define ARCH_H
|
||||
|
||||
+130
-52
@@ -43,33 +43,43 @@ static unsigned char Df_Key[24] = {
|
||||
0x89,0xab,0xcd,0xef,0x01,0x23,0x45,0x67 };
|
||||
*/
|
||||
|
||||
static unsigned short bytebit[8] = {
|
||||
01, 02, 04, 010, 020, 040, 0100, 0200 };
|
||||
static unsigned short bytebit[8] =
|
||||
{
|
||||
01, 02, 04, 010, 020, 040, 0100, 0200
|
||||
};
|
||||
|
||||
static unsigned long bigbyte[24] = {
|
||||
static unsigned long bigbyte[24] =
|
||||
{
|
||||
0x800000L, 0x400000L, 0x200000L, 0x100000L,
|
||||
0x80000L, 0x40000L, 0x20000L, 0x10000L,
|
||||
0x8000L, 0x4000L, 0x2000L, 0x1000L,
|
||||
0x800L, 0x400L, 0x200L, 0x100L,
|
||||
0x80L, 0x40L, 0x20L, 0x10L,
|
||||
0x8L, 0x4L, 0x2L, 0x1L };
|
||||
0x8L, 0x4L, 0x2L, 0x1L
|
||||
};
|
||||
|
||||
/* Use the key schedule specified in the Standard (ANSI X3.92-1981). */
|
||||
|
||||
static unsigned char pc1[56] = {
|
||||
static unsigned char pc1[56] =
|
||||
{
|
||||
56, 48, 40, 32, 24, 16, 8, 0, 57, 49, 41, 33, 25, 17,
|
||||
9, 1, 58, 50, 42, 34, 26, 18, 10, 2, 59, 51, 43, 35,
|
||||
62, 54, 46, 38, 30, 22, 14, 6, 61, 53, 45, 37, 29, 21,
|
||||
13, 5, 60, 52, 44, 36, 28, 20, 12, 4, 27, 19, 11, 3 };
|
||||
13, 5, 60, 52, 44, 36, 28, 20, 12, 4, 27, 19, 11, 3
|
||||
};
|
||||
|
||||
static unsigned char totrot[16] = {
|
||||
1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28 };
|
||||
static unsigned char totrot[16] =
|
||||
{
|
||||
1, 2, 4, 6, 8, 10, 12, 14, 15, 17, 19, 21, 23, 25, 27, 28
|
||||
};
|
||||
|
||||
static unsigned char pc2[48] = {
|
||||
static unsigned char pc2[48] =
|
||||
{
|
||||
13, 16, 10, 23, 0, 4, 2, 27, 14, 5, 20, 9,
|
||||
22, 18, 11, 3, 25, 7, 15, 6, 26, 19, 12, 1,
|
||||
40, 51, 30, 36, 46, 54, 29, 39, 50, 44, 32, 47,
|
||||
43, 48, 38, 55, 33, 52, 45, 41, 49, 35, 28, 31 };
|
||||
43, 48, 38, 55, 33, 52, 45, 41, 49, 35, 28, 31
|
||||
};
|
||||
|
||||
/* Thanks to James Gillogly & Phil Karn! */
|
||||
void rfbDesKey(unsigned char *key, int edf)
|
||||
@@ -78,34 +88,72 @@ void rfbDesKey(unsigned char *key, int edf)
|
||||
unsigned char pc1m[56], pcr[56];
|
||||
unsigned long kn[32];
|
||||
|
||||
for ( j = 0; j < 56; j++ ) {
|
||||
for ( j = 0; j < 56; j++ )
|
||||
{
|
||||
l = pc1[j];
|
||||
m = l & 07;
|
||||
pc1m[j] = (key[l >> 3] & bytebit[m]) ? 1 : 0;
|
||||
}
|
||||
for( i = 0; i < 16; i++ ) {
|
||||
if( edf == DE1 ) m = (15 - i) << 1;
|
||||
else m = i << 1;
|
||||
|
||||
for ( i = 0; i < 16; i++ )
|
||||
{
|
||||
if ( edf == DE1 )
|
||||
{
|
||||
m = (15 - i) << 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
m = i << 1;
|
||||
}
|
||||
|
||||
n = m + 1;
|
||||
kn[m] = kn[n] = 0L;
|
||||
for( j = 0; j < 28; j++ ) {
|
||||
|
||||
for ( j = 0; j < 28; j++ )
|
||||
{
|
||||
l = j + totrot[i];
|
||||
if( l < 28 ) pcr[j] = pc1m[l];
|
||||
else pcr[j] = pc1m[l - 28];
|
||||
|
||||
if ( l < 28 )
|
||||
{
|
||||
pcr[j] = pc1m[l];
|
||||
}
|
||||
for( j = 28; j < 56; j++ ) {
|
||||
else
|
||||
{
|
||||
pcr[j] = pc1m[l - 28];
|
||||
}
|
||||
}
|
||||
|
||||
for ( j = 28; j < 56; j++ )
|
||||
{
|
||||
l = j + totrot[i];
|
||||
if( l < 56 ) pcr[j] = pc1m[l];
|
||||
else pcr[j] = pc1m[l - 28];
|
||||
|
||||
if ( l < 56 )
|
||||
{
|
||||
pcr[j] = pc1m[l];
|
||||
}
|
||||
for( j = 0; j < 24; j++ ) {
|
||||
if( pcr[pc2[j]] ) kn[m] |= bigbyte[j];
|
||||
if( pcr[pc2[j+24]] ) kn[n] |= bigbyte[j];
|
||||
else
|
||||
{
|
||||
pcr[j] = pc1m[l - 28];
|
||||
}
|
||||
}
|
||||
|
||||
for ( j = 0; j < 24; j++ )
|
||||
{
|
||||
if ( pcr[pc2[j]] )
|
||||
{
|
||||
kn[m] |= bigbyte[j];
|
||||
}
|
||||
|
||||
if ( pcr[pc2[j + 24]] )
|
||||
{
|
||||
kn[n] |= bigbyte[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cookey(kn);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static void cookey(register unsigned long *raw1)
|
||||
{
|
||||
@@ -114,7 +162,9 @@ static void cookey(register unsigned long *raw1)
|
||||
register int i;
|
||||
|
||||
cook = dough;
|
||||
for( i = 0; i < 16; i++, raw1++ ) {
|
||||
|
||||
for ( i = 0; i < 16; i++, raw1++ )
|
||||
{
|
||||
raw0 = raw1++;
|
||||
*cook = (*raw0 & 0x00fc0000L) << 6;
|
||||
*cook |= (*raw0 & 0x00000fc0L) << 10;
|
||||
@@ -125,28 +175,39 @@ static void cookey(register unsigned long *raw1)
|
||||
*cook |= (*raw1 & 0x0003f000L) >> 4;
|
||||
*cook++ |= (*raw1 & 0x0000003fL);
|
||||
}
|
||||
|
||||
rfbUseKey(dough);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void rfbCPKey(register unsigned long *into)
|
||||
{
|
||||
register unsigned long *from, *endp;
|
||||
|
||||
from = KnL, endp = &KnL[32];
|
||||
while( from < endp ) *into++ = *from++;
|
||||
return;
|
||||
|
||||
while ( from < endp )
|
||||
{
|
||||
*into++ = *from++;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void rfbUseKey(register unsigned long *from)
|
||||
{
|
||||
register unsigned long *to, *endp;
|
||||
|
||||
to = KnL, endp = &KnL[32];
|
||||
while( to < endp ) *to++ = *from++;
|
||||
return;
|
||||
|
||||
while ( to < endp )
|
||||
{
|
||||
*to++ = *from++;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void rfbDes(unsigned char *inblock, unsigned char *outblock)
|
||||
{
|
||||
unsigned long work[2];
|
||||
@@ -155,7 +216,7 @@ void rfbDes(unsigned char *inblock, unsigned char *outblock)
|
||||
desfunc(work, KnL);
|
||||
unscrun(work, outblock);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static void scrunch(register unsigned char *outof, register unsigned long *into)
|
||||
{
|
||||
@@ -168,7 +229,7 @@ static void scrunch(register unsigned char *outof, register unsigned long *into)
|
||||
*into |= (*outof++ & 0xffL) << 8;
|
||||
*into |= (*outof & 0xffL);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static void unscrun(register unsigned long *outof, register unsigned char *into)
|
||||
{
|
||||
@@ -181,9 +242,10 @@ static void unscrun(register unsigned long *outof, register unsigned char *into)
|
||||
*into++ = (unsigned char)((*outof >> 8) & 0xffL);
|
||||
*into = (unsigned char)( *outof & 0xffL);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static unsigned long SP1[64] = {
|
||||
static unsigned long SP1[64] =
|
||||
{
|
||||
0x01010400L, 0x00000000L, 0x00010000L, 0x01010404L,
|
||||
0x01010004L, 0x00010404L, 0x00000004L, 0x00010000L,
|
||||
0x00000400L, 0x01010400L, 0x01010404L, 0x00000400L,
|
||||
@@ -199,9 +261,11 @@ static unsigned long SP1[64] = {
|
||||
0x01010404L, 0x00010004L, 0x01010000L, 0x01000404L,
|
||||
0x01000004L, 0x00000404L, 0x00010404L, 0x01010400L,
|
||||
0x00000404L, 0x01000400L, 0x01000400L, 0x00000000L,
|
||||
0x00010004L, 0x00010400L, 0x00000000L, 0x01010004L };
|
||||
0x00010004L, 0x00010400L, 0x00000000L, 0x01010004L
|
||||
};
|
||||
|
||||
static unsigned long SP2[64] = {
|
||||
static unsigned long SP2[64] =
|
||||
{
|
||||
0x80108020L, 0x80008000L, 0x00008000L, 0x00108020L,
|
||||
0x00100000L, 0x00000020L, 0x80100020L, 0x80008020L,
|
||||
0x80000020L, 0x80108020L, 0x80108000L, 0x80000000L,
|
||||
@@ -217,9 +281,11 @@ static unsigned long SP2[64] = {
|
||||
0x00008020L, 0x80108000L, 0x00100000L, 0x80000020L,
|
||||
0x00100020L, 0x80008020L, 0x80000020L, 0x00100020L,
|
||||
0x00108000L, 0x00000000L, 0x80008000L, 0x00008020L,
|
||||
0x80000000L, 0x80100020L, 0x80108020L, 0x00108000L };
|
||||
0x80000000L, 0x80100020L, 0x80108020L, 0x00108000L
|
||||
};
|
||||
|
||||
static unsigned long SP3[64] = {
|
||||
static unsigned long SP3[64] =
|
||||
{
|
||||
0x00000208L, 0x08020200L, 0x00000000L, 0x08020008L,
|
||||
0x08000200L, 0x00000000L, 0x00020208L, 0x08000200L,
|
||||
0x00020008L, 0x08000008L, 0x08000008L, 0x00020000L,
|
||||
@@ -235,9 +301,11 @@ static unsigned long SP3[64] = {
|
||||
0x08000208L, 0x00020000L, 0x08000000L, 0x08020208L,
|
||||
0x00000008L, 0x00020208L, 0x00020200L, 0x08000008L,
|
||||
0x08020000L, 0x08000208L, 0x00000208L, 0x08020000L,
|
||||
0x00020208L, 0x00000008L, 0x08020008L, 0x00020200L };
|
||||
0x00020208L, 0x00000008L, 0x08020008L, 0x00020200L
|
||||
};
|
||||
|
||||
static unsigned long SP4[64] = {
|
||||
static unsigned long SP4[64] =
|
||||
{
|
||||
0x00802001L, 0x00002081L, 0x00002081L, 0x00000080L,
|
||||
0x00802080L, 0x00800081L, 0x00800001L, 0x00002001L,
|
||||
0x00000000L, 0x00802000L, 0x00802000L, 0x00802081L,
|
||||
@@ -253,9 +321,11 @@ static unsigned long SP4[64] = {
|
||||
0x00802081L, 0x00000081L, 0x00000001L, 0x00002000L,
|
||||
0x00800001L, 0x00002001L, 0x00802080L, 0x00800081L,
|
||||
0x00002001L, 0x00002080L, 0x00800000L, 0x00802001L,
|
||||
0x00000080L, 0x00800000L, 0x00002000L, 0x00802080L };
|
||||
0x00000080L, 0x00800000L, 0x00002000L, 0x00802080L
|
||||
};
|
||||
|
||||
static unsigned long SP5[64] = {
|
||||
static unsigned long SP5[64] =
|
||||
{
|
||||
0x00000100L, 0x02080100L, 0x02080000L, 0x42000100L,
|
||||
0x00080000L, 0x00000100L, 0x40000000L, 0x02080000L,
|
||||
0x40080100L, 0x00080000L, 0x02000100L, 0x40080100L,
|
||||
@@ -271,9 +341,11 @@ static unsigned long SP5[64] = {
|
||||
0x42080100L, 0x00080100L, 0x42000000L, 0x42080100L,
|
||||
0x02080000L, 0x00000000L, 0x40080000L, 0x42000000L,
|
||||
0x00080100L, 0x02000100L, 0x40000100L, 0x00080000L,
|
||||
0x00000000L, 0x40080000L, 0x02080100L, 0x40000100L };
|
||||
0x00000000L, 0x40080000L, 0x02080100L, 0x40000100L
|
||||
};
|
||||
|
||||
static unsigned long SP6[64] = {
|
||||
static unsigned long SP6[64] =
|
||||
{
|
||||
0x20000010L, 0x20400000L, 0x00004000L, 0x20404010L,
|
||||
0x20400000L, 0x00000010L, 0x20404010L, 0x00400000L,
|
||||
0x20004000L, 0x00404010L, 0x00400000L, 0x20000010L,
|
||||
@@ -289,9 +361,11 @@ static unsigned long SP6[64] = {
|
||||
0x00404010L, 0x20404000L, 0x00000000L, 0x20400010L,
|
||||
0x00000010L, 0x00004000L, 0x20400000L, 0x00404010L,
|
||||
0x00004000L, 0x00400010L, 0x20004010L, 0x00000000L,
|
||||
0x20404000L, 0x20000000L, 0x00400010L, 0x20004010L };
|
||||
0x20404000L, 0x20000000L, 0x00400010L, 0x20004010L
|
||||
};
|
||||
|
||||
static unsigned long SP7[64] = {
|
||||
static unsigned long SP7[64] =
|
||||
{
|
||||
0x00200000L, 0x04200002L, 0x04000802L, 0x00000000L,
|
||||
0x00000800L, 0x04000802L, 0x00200802L, 0x04200800L,
|
||||
0x04200802L, 0x00200000L, 0x00000000L, 0x04000002L,
|
||||
@@ -307,9 +381,11 @@ static unsigned long SP7[64] = {
|
||||
0x00000802L, 0x04000002L, 0x04200802L, 0x04200000L,
|
||||
0x00200800L, 0x00000000L, 0x00000002L, 0x04200802L,
|
||||
0x00000000L, 0x00200802L, 0x04200000L, 0x00000800L,
|
||||
0x04000002L, 0x04000800L, 0x00000800L, 0x00200002L };
|
||||
0x04000002L, 0x04000800L, 0x00000800L, 0x00200002L
|
||||
};
|
||||
|
||||
static unsigned long SP8[64] = {
|
||||
static unsigned long SP8[64] =
|
||||
{
|
||||
0x10001040L, 0x00001000L, 0x00040000L, 0x10041040L,
|
||||
0x10000000L, 0x10001040L, 0x00000040L, 0x10000000L,
|
||||
0x00040040L, 0x10040000L, 0x10041040L, 0x00041000L,
|
||||
@@ -325,9 +401,10 @@ static unsigned long SP8[64] = {
|
||||
0x00000000L, 0x10041040L, 0x00040040L, 0x10000040L,
|
||||
0x10040000L, 0x10001000L, 0x10001040L, 0x00000000L,
|
||||
0x10041040L, 0x00041000L, 0x00041000L, 0x00001040L,
|
||||
0x00001040L, 0x00040040L, 0x10000000L, 0x10041000L };
|
||||
0x00001040L, 0x00040040L, 0x10000000L, 0x10041000L
|
||||
};
|
||||
|
||||
static void desfunc(register unsigned long* block, register unsigned long *keys)
|
||||
static void desfunc(register unsigned long *block, register unsigned long *keys)
|
||||
{
|
||||
register unsigned long fval, work, right, leftt;
|
||||
register int round;
|
||||
@@ -352,7 +429,8 @@ static void desfunc(register unsigned long* block, register unsigned long *keys)
|
||||
right ^= work;
|
||||
leftt = ((leftt << 1) | ((leftt >> 31) & 1L)) & 0xffffffffL;
|
||||
|
||||
for( round = 0; round < 8; round++ ) {
|
||||
for ( round = 0; round < 8; round++ )
|
||||
{
|
||||
work = (right << 28) | (right >> 4);
|
||||
work ^= *keys++;
|
||||
fval = SP7[ work & 0x3fL];
|
||||
@@ -399,7 +477,7 @@ static void desfunc(register unsigned long* block, register unsigned long *keys)
|
||||
*block++ = right;
|
||||
*block = leftt;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Validation sets:
|
||||
*
|
||||
|
||||
+19
-21
@@ -1,24 +1,22 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2004-2009
|
||||
|
||||
main define/macro file
|
||||
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* main define/macro file
|
||||
*/
|
||||
|
||||
#ifndef DEFINES_H
|
||||
#define DEFINES_H
|
||||
|
||||
+68
-38
@@ -1,26 +1,22 @@
|
||||
/*
|
||||
Copyright (c) 2004-2012 Jay Sorg
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
|
||||
read a config file
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* read a config file
|
||||
*/
|
||||
|
||||
#include "arch.h"
|
||||
#include "os_calls.h"
|
||||
@@ -33,9 +29,9 @@
|
||||
returns 0 if everything is ok
|
||||
returns 1 if problem reading file */
|
||||
static int APP_CC
|
||||
l_file_read_sections(int fd, int max_file_size, struct list* names)
|
||||
l_file_read_sections(int fd, int max_file_size, struct list *names)
|
||||
{
|
||||
struct stream* s;
|
||||
struct stream *s;
|
||||
char text[256];
|
||||
char c;
|
||||
int in_it;
|
||||
@@ -53,12 +49,15 @@ l_file_read_sections(int fd, int max_file_size, struct list* names)
|
||||
make_stream(s);
|
||||
init_stream(s, max_file_size);
|
||||
len = g_file_read(fd, s->data, max_file_size);
|
||||
|
||||
if (len > 0)
|
||||
{
|
||||
s->end = s->p + len;
|
||||
|
||||
for (index = 0; index < len; index++)
|
||||
{
|
||||
in_uint8(s, c);
|
||||
|
||||
if (c == '[')
|
||||
{
|
||||
in_it = 1;
|
||||
@@ -81,39 +80,45 @@ l_file_read_sections(int fd, int max_file_size, struct list* names)
|
||||
{
|
||||
rv = 1;
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
static int APP_CC
|
||||
file_read_line(struct stream* s, char* text)
|
||||
file_read_line(struct stream *s, char *text)
|
||||
{
|
||||
int i;
|
||||
int skip_to_end;
|
||||
int at_end;
|
||||
char c;
|
||||
char* hold;
|
||||
char *hold;
|
||||
|
||||
skip_to_end = 0;
|
||||
|
||||
if (!s_check_rem(s, 1))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
hold = s->p;
|
||||
i = 0;
|
||||
in_uint8(s, c);
|
||||
|
||||
while (c != 10 && c != 13)
|
||||
{
|
||||
if (c == '#' || c == '!' || c == ';')
|
||||
{
|
||||
skip_to_end = 1;
|
||||
}
|
||||
|
||||
if (!skip_to_end)
|
||||
{
|
||||
text[i] = c;
|
||||
i++;
|
||||
}
|
||||
|
||||
if (s_check_rem(s, 1))
|
||||
{
|
||||
in_uint8(s, c);
|
||||
@@ -124,9 +129,11 @@ file_read_line(struct stream* s, char* text)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (c == 10 || c == 13)
|
||||
{
|
||||
at_end = 0;
|
||||
|
||||
while (c == 10 || c == 13)
|
||||
{
|
||||
if (s_check_rem(s, 1))
|
||||
@@ -139,24 +146,28 @@ file_read_line(struct stream* s, char* text)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!at_end)
|
||||
{
|
||||
s->p--;
|
||||
}
|
||||
}
|
||||
|
||||
text[i] = 0;
|
||||
|
||||
if (text[0] == '[')
|
||||
{
|
||||
s->p = hold;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
static int APP_CC
|
||||
file_split_name_value(char* text, char* name, char* value)
|
||||
file_split_name_value(char *text, char *name, char *value)
|
||||
{
|
||||
int len;
|
||||
int i;
|
||||
@@ -170,6 +181,7 @@ file_split_name_value(char* text, char* name, char* value)
|
||||
name[0] = 0;
|
||||
value[0] = 0;
|
||||
len = g_strlen(text);
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
if (text[i] == '=')
|
||||
@@ -189,6 +201,7 @@ file_split_name_value(char* text, char* name, char* value)
|
||||
name[name_index] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
g_strtrim(name, 3); /* trim both right and left */
|
||||
g_strtrim(value, 3); /* trim both right and left */
|
||||
return 0;
|
||||
@@ -197,14 +210,14 @@ file_split_name_value(char* text, char* name, char* value)
|
||||
/*****************************************************************************/
|
||||
/* return error */
|
||||
static int APP_CC
|
||||
l_file_read_section(int fd, int max_file_size, const char* section,
|
||||
struct list* names, struct list* values)
|
||||
l_file_read_section(int fd, int max_file_size, const char *section,
|
||||
struct list *names, struct list *values)
|
||||
{
|
||||
struct stream* s;
|
||||
struct stream *s;
|
||||
char text[512];
|
||||
char name[512];
|
||||
char value[512];
|
||||
char* lvalue;
|
||||
char *lvalue;
|
||||
char c;
|
||||
int in_it;
|
||||
int in_it_index;
|
||||
@@ -222,12 +235,15 @@ l_file_read_section(int fd, int max_file_size, const char* section,
|
||||
make_stream(s);
|
||||
init_stream(s, file_size);
|
||||
len = g_file_read(fd, s->data, file_size);
|
||||
|
||||
if (len > 0)
|
||||
{
|
||||
s->end = s->p + len;
|
||||
|
||||
for (index = 0; index < len; index++)
|
||||
{
|
||||
in_uint8(s, c);
|
||||
|
||||
if (c == '[')
|
||||
{
|
||||
in_it = 1;
|
||||
@@ -237,15 +253,18 @@ l_file_read_section(int fd, int max_file_size, const char* section,
|
||||
if (g_strcasecmp(section, text) == 0)
|
||||
{
|
||||
file_read_line(s, text);
|
||||
|
||||
while (file_read_line(s, text) == 0)
|
||||
{
|
||||
if (g_strlen(text) > 0)
|
||||
{
|
||||
file_split_name_value(text, name, value);
|
||||
list_add_item(names, (tbus)g_strdup(name));
|
||||
|
||||
if (value[0] == '$')
|
||||
{
|
||||
lvalue = g_getenv(value + 1);
|
||||
|
||||
if (lvalue != 0)
|
||||
{
|
||||
list_add_item(values, (tbus)g_strdup(lvalue));
|
||||
@@ -261,9 +280,11 @@ l_file_read_section(int fd, int max_file_size, const char* section,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
return 0;
|
||||
}
|
||||
|
||||
in_it = 0;
|
||||
in_it_index = 0;
|
||||
g_memset(text, 0, 512);
|
||||
@@ -275,6 +296,7 @@ l_file_read_section(int fd, int max_file_size, const char* section,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
@@ -285,7 +307,7 @@ l_file_read_section(int fd, int max_file_size, const char* section,
|
||||
returns 1 if problem reading file */
|
||||
/* 32 K file size limit */
|
||||
int APP_CC
|
||||
file_read_sections(int fd, struct list* names)
|
||||
file_read_sections(int fd, struct list *names)
|
||||
{
|
||||
return l_file_read_sections(fd, 32 * 1024, names);
|
||||
}
|
||||
@@ -295,22 +317,26 @@ file_read_sections(int fd, struct list* names)
|
||||
/* this function should be prefered over file_read_sections because it can
|
||||
read any file size */
|
||||
int APP_CC
|
||||
file_by_name_read_sections(const char* file_name, struct list* names)
|
||||
file_by_name_read_sections(const char *file_name, struct list *names)
|
||||
{
|
||||
int fd;
|
||||
int file_size;
|
||||
int rv;
|
||||
|
||||
file_size = g_file_get_size(file_name);
|
||||
|
||||
if (file_size < 1)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
fd = g_file_open(file_name);
|
||||
|
||||
if (fd < 1)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
rv = l_file_read_sections(fd, file_size, names);
|
||||
g_file_close(fd);
|
||||
return rv;
|
||||
@@ -320,8 +346,8 @@ file_by_name_read_sections(const char* file_name, struct list* names)
|
||||
/* return error */
|
||||
/* 32 K file size limit */
|
||||
int APP_CC
|
||||
file_read_section(int fd, const char* section,
|
||||
struct list* names, struct list* values)
|
||||
file_read_section(int fd, const char *section,
|
||||
struct list *names, struct list *values)
|
||||
{
|
||||
return l_file_read_section(fd, 32 * 1024, section, names, values);
|
||||
}
|
||||
@@ -331,23 +357,27 @@ file_read_section(int fd, const char* section,
|
||||
/* this function should be prefered over file_read_section because it can
|
||||
read any file size */
|
||||
int APP_CC
|
||||
file_by_name_read_section(const char* file_name, const char* section,
|
||||
struct list* names, struct list* values)
|
||||
file_by_name_read_section(const char *file_name, const char *section,
|
||||
struct list *names, struct list *values)
|
||||
{
|
||||
int fd;
|
||||
int file_size;
|
||||
int rv;
|
||||
|
||||
file_size = g_file_get_size(file_name);
|
||||
|
||||
if (file_size < 1)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
fd = g_file_open(file_name);
|
||||
|
||||
if (fd < 1)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
rv = l_file_read_section(fd, file_size, section, names, values);
|
||||
g_file_close(fd);
|
||||
return rv;
|
||||
|
||||
+19
-23
@@ -1,26 +1,22 @@
|
||||
/*
|
||||
Copyright (c) 2004-2010 Jay Sorg
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
|
||||
read a config file
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* read a config file
|
||||
*/
|
||||
|
||||
#if !defined(FILE_H)
|
||||
#define FILE_H
|
||||
|
||||
+19
-21
@@ -1,24 +1,22 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2004-2010
|
||||
|
||||
default file locations for log, config, etc
|
||||
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* default file locations for log, config, etc
|
||||
*/
|
||||
|
||||
#if !defined(FILE_LOC_H)
|
||||
#define FILE_LOC_H
|
||||
|
||||
+55
-46
@@ -1,47 +1,43 @@
|
||||
/*
|
||||
Copyright (c) 2004-2010 Jay Sorg
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
|
||||
simple list
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* simple list
|
||||
*/
|
||||
|
||||
#include "arch.h"
|
||||
#include "os_calls.h"
|
||||
#include "list.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
struct list* APP_CC
|
||||
struct list *APP_CC
|
||||
list_create(void)
|
||||
{
|
||||
struct list* self;
|
||||
struct list *self;
|
||||
|
||||
self = (struct list*)g_malloc(sizeof(struct list), 1);
|
||||
self = (struct list *)g_malloc(sizeof(struct list), 1);
|
||||
self->grow_by = 10;
|
||||
self->alloc_size = 10;
|
||||
self->items = (tbus*)g_malloc(sizeof(tbus) * 10, 1);
|
||||
self->items = (tbus *)g_malloc(sizeof(tbus) * 10, 1);
|
||||
return self;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void APP_CC
|
||||
list_delete(struct list* self)
|
||||
list_delete(struct list *self)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -49,52 +45,56 @@ list_delete(struct list* self)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (self->auto_free)
|
||||
{
|
||||
for (i = 0; i < self->count; i++)
|
||||
{
|
||||
g_free((void*)self->items[i]);
|
||||
g_free((void *)self->items[i]);
|
||||
self->items[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
g_free(self->items);
|
||||
g_free(self);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void APP_CC
|
||||
list_add_item(struct list* self, tbus item)
|
||||
list_add_item(struct list *self, tbus item)
|
||||
{
|
||||
tbus* p;
|
||||
tbus *p;
|
||||
int i;
|
||||
|
||||
if (self->count >= self->alloc_size)
|
||||
{
|
||||
i = self->alloc_size;
|
||||
self->alloc_size += self->grow_by;
|
||||
p = (tbus*)g_malloc(sizeof(tbus) * self->alloc_size, 1);
|
||||
p = (tbus *)g_malloc(sizeof(tbus) * self->alloc_size, 1);
|
||||
g_memcpy(p, self->items, sizeof(tbus) * i);
|
||||
g_free(self->items);
|
||||
self->items = p;
|
||||
}
|
||||
|
||||
self->items[self->count] = item;
|
||||
self->count++;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
tbus APP_CC
|
||||
list_get_item(struct list* self, int index)
|
||||
list_get_item(struct list *self, int index)
|
||||
{
|
||||
if (index < 0 || index >= self->count)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return self->items[index];
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void APP_CC
|
||||
list_clear(struct list* self)
|
||||
list_clear(struct list *self)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -102,20 +102,21 @@ list_clear(struct list* self)
|
||||
{
|
||||
for (i = 0; i < self->count; i++)
|
||||
{
|
||||
g_free((void*)self->items[i]);
|
||||
g_free((void *)self->items[i]);
|
||||
self->items[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
g_free(self->items);
|
||||
self->count = 0;
|
||||
self->grow_by = 10;
|
||||
self->alloc_size = 10;
|
||||
self->items = (tbus*)g_malloc(sizeof(tbus) * 10, 1);
|
||||
self->items = (tbus *)g_malloc(sizeof(tbus) * 10, 1);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
int APP_CC
|
||||
list_index_of(struct list* self, tbus item)
|
||||
list_index_of(struct list *self, tbus item)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -126,12 +127,13 @@ list_index_of(struct list* self, tbus item)
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void APP_CC
|
||||
list_remove_item(struct list* self, int index)
|
||||
list_remove_item(struct list *self, int index)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -139,22 +141,24 @@ list_remove_item(struct list* self, int index)
|
||||
{
|
||||
if (self->auto_free)
|
||||
{
|
||||
g_free((void*)self->items[index]);
|
||||
g_free((void *)self->items[index]);
|
||||
self->items[index] = 0;
|
||||
}
|
||||
|
||||
for (i = index; i < (self->count - 1); i++)
|
||||
{
|
||||
self->items[i] = self->items[i + 1];
|
||||
}
|
||||
|
||||
self->count--;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void APP_CC
|
||||
list_insert_item(struct list* self, int index, tbus item)
|
||||
list_insert_item(struct list *self, int index, tbus item)
|
||||
{
|
||||
tbus* p;
|
||||
tbus *p;
|
||||
int i;
|
||||
|
||||
if (index == self->count)
|
||||
@@ -162,22 +166,26 @@ list_insert_item(struct list* self, int index, tbus item)
|
||||
list_add_item(self, item);
|
||||
return;
|
||||
}
|
||||
|
||||
if (index >= 0 && index < self->count)
|
||||
{
|
||||
self->count++;
|
||||
|
||||
if (self->count > self->alloc_size)
|
||||
{
|
||||
i = self->alloc_size;
|
||||
self->alloc_size += self->grow_by;
|
||||
p = (tbus*)g_malloc(sizeof(tbus) * self->alloc_size, 1);
|
||||
p = (tbus *)g_malloc(sizeof(tbus) * self->alloc_size, 1);
|
||||
g_memcpy(p, self->items, sizeof(tbus) * i);
|
||||
g_free(self->items);
|
||||
self->items = p;
|
||||
}
|
||||
|
||||
for (i = (self->count - 2); i >= index; i--)
|
||||
{
|
||||
self->items[i + 1] = self->items[i];
|
||||
}
|
||||
|
||||
self->items[index] = item;
|
||||
}
|
||||
}
|
||||
@@ -186,23 +194,23 @@ list_insert_item(struct list* self, int index, tbus item)
|
||||
/* append one list to another using strdup for each item in the list */
|
||||
/* begins copy at start_index, a zero based index on the soure list */
|
||||
void APP_CC
|
||||
list_append_list_strdup(struct list* self, struct list* dest, int start_index)
|
||||
list_append_list_strdup(struct list *self, struct list *dest, int start_index)
|
||||
{
|
||||
int index;
|
||||
tbus item;
|
||||
char* dup;
|
||||
char *dup;
|
||||
|
||||
for (index = start_index; index < self->count; index++)
|
||||
{
|
||||
item = list_get_item(self, index);
|
||||
dup = g_strdup((char*)item);
|
||||
dup = g_strdup((char *)item);
|
||||
list_add_item(dest, (tbus)dup);
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void APP_CC
|
||||
list_dump_items(struct list* self)
|
||||
list_dump_items(struct list *self)
|
||||
{
|
||||
int index;
|
||||
|
||||
@@ -210,6 +218,7 @@ list_dump_items(struct list* self)
|
||||
{
|
||||
g_writeln("List is empty");
|
||||
}
|
||||
|
||||
for (index = 0; index < self->count; index++)
|
||||
{
|
||||
g_writeln("%d: %s", index, list_get_item(self, index));
|
||||
|
||||
+19
-23
@@ -1,26 +1,22 @@
|
||||
/*
|
||||
Copyright (c) 2004-2010 Jay Sorg
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
|
||||
simple list
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* simple list
|
||||
*/
|
||||
|
||||
#if !defined(LIST_H)
|
||||
#define LIST_H
|
||||
|
||||
+90
-51
@@ -1,25 +1,20 @@
|
||||
/*
|
||||
Copyright (c) 2005-2012 Jay Sorg
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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 <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
@@ -41,7 +36,7 @@
|
||||
#include "log.h"
|
||||
|
||||
/* Here we store the current state and configuration of the log */
|
||||
static struct log_config* staticLogConfig = NULL;
|
||||
static struct log_config *staticLogConfig = NULL;
|
||||
|
||||
/* This file first start with all private functions.
|
||||
In the end of the file the public functions is defined */
|
||||
@@ -54,14 +49,16 @@ static struct log_config* staticLogConfig = NULL;
|
||||
*
|
||||
*/
|
||||
int DEFAULT_CC
|
||||
internal_log_file_open(const char* fname)
|
||||
internal_log_file_open(const char *fname)
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
if (fname != NULL)
|
||||
{
|
||||
ret = open(fname, O_WRONLY | O_CREAT | O_APPEND | O_SYNC,
|
||||
S_IRUSR | S_IWUSR);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -101,7 +98,7 @@ internal_log_xrdp2syslog(const enum logLevels lvl)
|
||||
*
|
||||
*/
|
||||
void DEFAULT_CC
|
||||
internal_log_lvl2str(const enum logLevels lvl, char* str)
|
||||
internal_log_lvl2str(const enum logLevels lvl, char *str)
|
||||
{
|
||||
switch (lvl)
|
||||
{
|
||||
@@ -128,9 +125,10 @@ internal_log_lvl2str(const enum logLevels lvl, char* str)
|
||||
|
||||
/******************************************************************************/
|
||||
enum logReturns DEFAULT_CC
|
||||
internal_log_start(struct log_config* l_cfg)
|
||||
internal_log_start(struct log_config *l_cfg)
|
||||
{
|
||||
enum logReturns ret = LOG_GENERAL_ERROR;
|
||||
|
||||
if (0 == l_cfg)
|
||||
{
|
||||
ret = LOG_ERROR_MALLOC;
|
||||
@@ -175,9 +173,10 @@ internal_log_start(struct log_config* l_cfg)
|
||||
|
||||
/******************************************************************************/
|
||||
enum logReturns DEFAULT_CC
|
||||
internal_log_end(struct log_config* l_cfg)
|
||||
internal_log_end(struct log_config *l_cfg)
|
||||
{
|
||||
enum logReturns ret = LOG_GENERAL_ERROR;
|
||||
|
||||
/* if log is closed, quit silently */
|
||||
if (0 == l_cfg)
|
||||
{
|
||||
@@ -205,11 +204,13 @@ internal_log_end(struct log_config* l_cfg)
|
||||
g_free(l_cfg->log_file);
|
||||
l_cfg->log_file = 0;
|
||||
}
|
||||
|
||||
if (0 != l_cfg->program_name)
|
||||
{
|
||||
g_free(l_cfg->program_name);
|
||||
l_cfg->program_name = 0;
|
||||
}
|
||||
|
||||
ret = LOG_STARTUP_OK;
|
||||
return ret;
|
||||
}
|
||||
@@ -220,7 +221,7 @@ internal_log_end(struct log_config* l_cfg)
|
||||
* @return
|
||||
*/
|
||||
enum logLevels DEFAULT_CC
|
||||
internal_log_text2level(char* buf)
|
||||
internal_log_text2level(char *buf)
|
||||
{
|
||||
if (0 == g_strcasecmp(buf, "0") ||
|
||||
0 == g_strcasecmp(buf, "core"))
|
||||
@@ -248,34 +249,39 @@ internal_log_text2level(char* buf)
|
||||
{
|
||||
return LOG_LEVEL_DEBUG;
|
||||
}
|
||||
|
||||
g_writeln("Your configured log level is corrupt - we use debug log level");
|
||||
return LOG_LEVEL_DEBUG;
|
||||
}
|
||||
|
||||
enum logReturns DEFAULT_CC
|
||||
internalReadConfiguration(const char* inFilename, const char* applicationName)
|
||||
internalReadConfiguration(const char *inFilename, const char *applicationName)
|
||||
{
|
||||
int fd;
|
||||
enum logReturns ret = LOG_GENERAL_ERROR;
|
||||
struct list* sec;
|
||||
struct list* param_n;
|
||||
struct list* param_v;
|
||||
struct list *sec;
|
||||
struct list *param_n;
|
||||
struct list *param_v;
|
||||
|
||||
if (inFilename == NULL)
|
||||
{
|
||||
g_writeln("The inifile is null to readConfiguration!");
|
||||
return ret;
|
||||
}
|
||||
|
||||
fd = g_file_open(inFilename);
|
||||
|
||||
if (-1 == fd)
|
||||
{
|
||||
ret = LOG_ERROR_NO_CFG;
|
||||
g_writeln("We could not open the configuration file to read log parameters");
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* we initialize the memory for the configuration and set all content
|
||||
to zero. */
|
||||
ret = internalInitAndAllocStruct();
|
||||
|
||||
if (ret != LOG_STARTUP_OK)
|
||||
{
|
||||
return ret;
|
||||
@@ -292,10 +298,12 @@ internalReadConfiguration(const char* inFilename, const char* applicationName)
|
||||
/* read logging config */
|
||||
ret = internal_config_read_logging(fd, staticLogConfig, param_n,
|
||||
param_v, applicationName);
|
||||
|
||||
if (ret != LOG_STARTUP_OK)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* cleanup */
|
||||
list_delete(sec);
|
||||
list_delete(param_v);
|
||||
@@ -306,14 +314,14 @@ internalReadConfiguration(const char* inFilename, const char* applicationName)
|
||||
|
||||
/******************************************************************************/
|
||||
enum logReturns DEFAULT_CC
|
||||
internal_config_read_logging(int file, struct log_config* lc,
|
||||
struct list* param_n,
|
||||
struct list* param_v,
|
||||
const char* applicationName)
|
||||
internal_config_read_logging(int file, struct log_config *lc,
|
||||
struct list *param_n,
|
||||
struct list *param_v,
|
||||
const char *applicationName)
|
||||
{
|
||||
int i;
|
||||
char* buf;
|
||||
char* temp_buf;
|
||||
char *buf;
|
||||
char *temp_buf;
|
||||
|
||||
list_clear(param_v);
|
||||
list_clear(param_n);
|
||||
@@ -327,34 +335,40 @@ internal_config_read_logging(int file, struct log_config* lc,
|
||||
lc->syslog_level = LOG_LEVEL_DEBUG;
|
||||
|
||||
file_read_section(file, SESMAN_CFG_LOGGING, param_n, param_v);
|
||||
|
||||
for (i = 0; i < param_n->count; i++)
|
||||
{
|
||||
buf = (char*)list_get_item(param_n, i);
|
||||
buf = (char *)list_get_item(param_n, i);
|
||||
|
||||
if (0 == g_strcasecmp(buf, SESMAN_CFG_LOG_FILE))
|
||||
{
|
||||
lc->log_file = g_strdup((char*)list_get_item(param_v, i));
|
||||
lc->log_file = g_strdup((char *)list_get_item(param_v, i));
|
||||
|
||||
if (lc->log_file != NULL)
|
||||
{
|
||||
if (lc->log_file[0] != '/')
|
||||
{
|
||||
temp_buf = (char*)g_malloc(512, 0);
|
||||
temp_buf = (char *)g_malloc(512, 0);
|
||||
g_snprintf(temp_buf, 511, "%s/%s", XRDP_LOG_PATH, lc->log_file);
|
||||
g_free(lc->log_file);
|
||||
lc->log_file = temp_buf;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (0 == g_strcasecmp(buf, SESMAN_CFG_LOG_LEVEL))
|
||||
{
|
||||
lc->log_level = internal_log_text2level((char*)list_get_item(param_v, i));
|
||||
lc->log_level = internal_log_text2level((char *)list_get_item(param_v, i));
|
||||
}
|
||||
|
||||
if (0 == g_strcasecmp(buf, SESMAN_CFG_LOG_ENABLE_SYSLOG))
|
||||
{
|
||||
lc->enable_syslog = text2bool((char*)list_get_item(param_v, i));
|
||||
lc->enable_syslog = text2bool((char *)list_get_item(param_v, i));
|
||||
}
|
||||
|
||||
if (0 == g_strcasecmp(buf, SESMAN_CFG_LOG_SYSLOG_LEVEL))
|
||||
{
|
||||
lc->syslog_level = internal_log_text2level((char*)list_get_item(param_v, i));
|
||||
lc->syslog_level = internal_log_text2level((char *)list_get_item(param_v, i));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -379,6 +393,7 @@ internalInitAndAllocStruct(void)
|
||||
{
|
||||
enum logReturns ret = LOG_GENERAL_ERROR;
|
||||
staticLogConfig = g_malloc(sizeof(struct log_config), 1);
|
||||
|
||||
if (staticLogConfig != NULL)
|
||||
{
|
||||
staticLogConfig->fd = -1;
|
||||
@@ -390,6 +405,7 @@ internalInitAndAllocStruct(void)
|
||||
g_writeln("could not allocate memory for log struct");
|
||||
ret = LOG_ERROR_MALLOC;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -406,7 +422,7 @@ internalInitAndAllocStruct(void)
|
||||
*
|
||||
*/
|
||||
int APP_CC
|
||||
text2bool(char* s)
|
||||
text2bool(char *s)
|
||||
{
|
||||
if (0 == g_strcasecmp(s, "1") ||
|
||||
0 == g_strcasecmp(s, "true") ||
|
||||
@@ -414,18 +430,21 @@ text2bool(char* s)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
enum logReturns DEFAULT_CC
|
||||
log_start_from_param(const struct log_config* iniParams)
|
||||
log_start_from_param(const struct log_config *iniParams)
|
||||
{
|
||||
enum logReturns ret = LOG_GENERAL_ERROR;
|
||||
|
||||
if (staticLogConfig != NULL)
|
||||
{
|
||||
log_message(LOG_LEVEL_ALWAYS, "Log already initialized");
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (iniParams == NULL)
|
||||
{
|
||||
g_writeln("inparam to log_start_from_param is NULL");
|
||||
@@ -435,11 +454,13 @@ log_start_from_param(const struct log_config* iniParams)
|
||||
{
|
||||
/*Copy the struct information*/
|
||||
ret = internalInitAndAllocStruct();
|
||||
|
||||
if (ret != LOG_STARTUP_OK)
|
||||
{
|
||||
g_writeln("internalInitAndAllocStruct failed");
|
||||
return ret;
|
||||
}
|
||||
|
||||
staticLogConfig->enable_syslog = iniParams->enable_syslog;
|
||||
staticLogConfig->fd = iniParams->fd;
|
||||
staticLogConfig->log_file = g_strdup(iniParams->log_file);
|
||||
@@ -449,9 +470,11 @@ log_start_from_param(const struct log_config* iniParams)
|
||||
staticLogConfig->program_name = g_strdup(iniParams->program_name);
|
||||
staticLogConfig->syslog_level = iniParams->syslog_level;
|
||||
ret = internal_log_start(staticLogConfig);
|
||||
|
||||
if (ret != LOG_STARTUP_OK)
|
||||
{
|
||||
g_writeln("Could not start log");
|
||||
|
||||
if (staticLogConfig != NULL)
|
||||
{
|
||||
g_free(staticLogConfig);
|
||||
@@ -459,6 +482,7 @@ log_start_from_param(const struct log_config* iniParams)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -470,21 +494,26 @@ log_start_from_param(const struct log_config* iniParams)
|
||||
* @return 0 on success
|
||||
*/
|
||||
enum logReturns DEFAULT_CC
|
||||
log_start(const char* iniFile, const char* applicationName)
|
||||
log_start(const char *iniFile, const char *applicationName)
|
||||
{
|
||||
enum logReturns ret = LOG_GENERAL_ERROR;
|
||||
|
||||
if (applicationName == NULL)
|
||||
{
|
||||
g_writeln("Programming error your application name cannot be null");
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = internalReadConfiguration(iniFile, applicationName);
|
||||
|
||||
if (ret == LOG_STARTUP_OK)
|
||||
{
|
||||
ret = internal_log_start(staticLogConfig);
|
||||
|
||||
if (ret != LOG_STARTUP_OK)
|
||||
{
|
||||
g_writeln("Could not start log");
|
||||
|
||||
if (staticLogConfig != NULL)
|
||||
{
|
||||
g_free(staticLogConfig);
|
||||
@@ -497,6 +526,7 @@ log_start(const char* iniFile, const char* applicationName)
|
||||
g_writeln("Error reading configuration for log based on config: %s",
|
||||
iniFile);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -509,16 +539,18 @@ log_end(void)
|
||||
{
|
||||
enum logReturns ret = LOG_GENERAL_ERROR;
|
||||
ret = internal_log_end(staticLogConfig);
|
||||
|
||||
if (staticLogConfig != NULL)
|
||||
{
|
||||
g_free(staticLogConfig);
|
||||
staticLogConfig = NULL;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
enum logReturns DEFAULT_CC
|
||||
log_message(const enum logLevels lvl, const char* msg, ...)
|
||||
log_message(const enum logLevels lvl, const char *msg, ...)
|
||||
{
|
||||
char buff[LOG_BUFFER_SIZE + 31]; /* 19 (datetime) 4 (space+cr+lf+\0) */
|
||||
va_list ap;
|
||||
@@ -526,12 +558,14 @@ log_message(const enum logLevels lvl, const char* msg, ...)
|
||||
enum logReturns rv = LOG_STARTUP_OK;
|
||||
int writereply = 0;
|
||||
time_t now_t;
|
||||
struct tm* now;
|
||||
struct tm *now;
|
||||
|
||||
if (staticLogConfig == NULL)
|
||||
{
|
||||
g_writeln("The log reference is NULL - log not initialized properly");
|
||||
return LOG_ERROR_NO_CFG;
|
||||
}
|
||||
|
||||
if (0 > staticLogConfig->fd && staticLogConfig->enable_syslog == 0)
|
||||
{
|
||||
return LOG_ERROR_FILE_NOT_OPEN;
|
||||
@@ -588,18 +622,22 @@ log_message(const enum logLevels lvl, const char* msg, ...)
|
||||
#ifdef LOG_ENABLE_THREAD
|
||||
pthread_mutex_lock(&(staticLogConfig->log_lock));
|
||||
#endif
|
||||
|
||||
if (staticLogConfig->fd > 0)
|
||||
{
|
||||
writereply = g_file_write(staticLogConfig->fd, buff, g_strlen(buff));
|
||||
|
||||
if (writereply <= 0)
|
||||
{
|
||||
rv = LOG_ERROR_NULL_FILE;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef LOG_ENABLE_THREAD
|
||||
pthread_mutex_unlock(&(staticLogConfig->log_lock));
|
||||
#endif
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
@@ -607,8 +645,8 @@ log_message(const enum logLevels lvl, const char* msg, ...)
|
||||
* Return the configured log file name
|
||||
* @return
|
||||
*/
|
||||
char* DEFAULT_CC
|
||||
getLogFile(char* replybuf, int bufsize)
|
||||
char *DEFAULT_CC
|
||||
getLogFile(char *replybuf, int bufsize)
|
||||
{
|
||||
if (staticLogConfig)
|
||||
{
|
||||
@@ -625,5 +663,6 @@ getLogFile(char* replybuf, int bufsize)
|
||||
{
|
||||
g_snprintf(replybuf, bufsize, "The log is not properly started");
|
||||
}
|
||||
|
||||
return replybuf;
|
||||
}
|
||||
|
||||
+17
-22
@@ -1,25 +1,20 @@
|
||||
/*
|
||||
Copyright (c) 2005-2012 Jay Sorg
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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 LOG_H
|
||||
#define LOG_H
|
||||
|
||||
+366
-172
File diff suppressed because it is too large
Load Diff
+19
-23
@@ -1,26 +1,22 @@
|
||||
/*
|
||||
Copyright (c) 2004-2012 Jay Sorg
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
|
||||
generic operating system calls
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* generic operating system calls
|
||||
*/
|
||||
|
||||
#if !defined(OS_CALLS_H)
|
||||
#define OS_CALLS_H
|
||||
|
||||
+23
-27
@@ -1,30 +1,26 @@
|
||||
/*
|
||||
Copyright (c) 2004-2010 Jay Sorg
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Parsing structs and macros
|
||||
|
||||
based on parse.h from rdesktop
|
||||
this is a super fast stream method, you bet
|
||||
needed functions g_malloc, g_free, g_memset, g_memcpy
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Parsing structs and macros
|
||||
*
|
||||
* based on parse.h from rdesktop
|
||||
* this is a super fast stream method, you bet
|
||||
* needed functions g_malloc, g_free, g_memset, g_memcpy
|
||||
*/
|
||||
|
||||
#if !defined(PARSE_H)
|
||||
#define PARSE_H
|
||||
|
||||
+98
-83
@@ -1,24 +1,22 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2004-2010
|
||||
|
||||
ssl calls
|
||||
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* ssl calls
|
||||
*/
|
||||
|
||||
#include <stdlib.h> /* needed for openssl headers */
|
||||
#include <openssl/ssl.h>
|
||||
@@ -58,7 +56,7 @@ ssl_finish(void)
|
||||
/* rc4 stuff */
|
||||
|
||||
/*****************************************************************************/
|
||||
void* APP_CC
|
||||
void *APP_CC
|
||||
ssl_rc4_info_create(void)
|
||||
{
|
||||
return g_malloc(sizeof(RC4_KEY), 1);
|
||||
@@ -66,29 +64,29 @@ ssl_rc4_info_create(void)
|
||||
|
||||
/*****************************************************************************/
|
||||
void APP_CC
|
||||
ssl_rc4_info_delete(void* rc4_info)
|
||||
ssl_rc4_info_delete(void *rc4_info)
|
||||
{
|
||||
g_free(rc4_info);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void APP_CC
|
||||
ssl_rc4_set_key(void* rc4_info, char* key, int len)
|
||||
ssl_rc4_set_key(void *rc4_info, char *key, int len)
|
||||
{
|
||||
RC4_set_key((RC4_KEY*)rc4_info, len, (tui8*)key);
|
||||
RC4_set_key((RC4_KEY *)rc4_info, len, (tui8 *)key);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void APP_CC
|
||||
ssl_rc4_crypt(void* rc4_info, char* data, int len)
|
||||
ssl_rc4_crypt(void *rc4_info, char *data, int len)
|
||||
{
|
||||
RC4((RC4_KEY*)rc4_info, len, (tui8*)data, (tui8*)data);
|
||||
RC4((RC4_KEY *)rc4_info, len, (tui8 *)data, (tui8 *)data);
|
||||
}
|
||||
|
||||
/* sha1 stuff */
|
||||
|
||||
/*****************************************************************************/
|
||||
void* APP_CC
|
||||
void *APP_CC
|
||||
ssl_sha1_info_create(void)
|
||||
{
|
||||
return g_malloc(sizeof(SHA_CTX), 1);
|
||||
@@ -96,36 +94,36 @@ ssl_sha1_info_create(void)
|
||||
|
||||
/*****************************************************************************/
|
||||
void APP_CC
|
||||
ssl_sha1_info_delete(void* sha1_info)
|
||||
ssl_sha1_info_delete(void *sha1_info)
|
||||
{
|
||||
g_free(sha1_info);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void APP_CC
|
||||
ssl_sha1_clear(void* sha1_info)
|
||||
ssl_sha1_clear(void *sha1_info)
|
||||
{
|
||||
SHA1_Init((SHA_CTX*)sha1_info);
|
||||
SHA1_Init((SHA_CTX *)sha1_info);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void APP_CC
|
||||
ssl_sha1_transform(void* sha1_info, char* data, int len)
|
||||
ssl_sha1_transform(void *sha1_info, char *data, int len)
|
||||
{
|
||||
SHA1_Update((SHA_CTX*)sha1_info, data, len);
|
||||
SHA1_Update((SHA_CTX *)sha1_info, data, len);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void APP_CC
|
||||
ssl_sha1_complete(void* sha1_info, char* data)
|
||||
ssl_sha1_complete(void *sha1_info, char *data)
|
||||
{
|
||||
SHA1_Final((tui8*)data, (SHA_CTX*)sha1_info);
|
||||
SHA1_Final((tui8 *)data, (SHA_CTX *)sha1_info);
|
||||
}
|
||||
|
||||
/* md5 stuff */
|
||||
|
||||
/*****************************************************************************/
|
||||
void* APP_CC
|
||||
void *APP_CC
|
||||
ssl_md5_info_create(void)
|
||||
{
|
||||
return g_malloc(sizeof(MD5_CTX), 1);
|
||||
@@ -133,35 +131,35 @@ ssl_md5_info_create(void)
|
||||
|
||||
/*****************************************************************************/
|
||||
void APP_CC
|
||||
ssl_md5_info_delete(void* md5_info)
|
||||
ssl_md5_info_delete(void *md5_info)
|
||||
{
|
||||
g_free(md5_info);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void APP_CC
|
||||
ssl_md5_clear(void* md5_info)
|
||||
ssl_md5_clear(void *md5_info)
|
||||
{
|
||||
MD5_Init((MD5_CTX*)md5_info);
|
||||
MD5_Init((MD5_CTX *)md5_info);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void APP_CC
|
||||
ssl_md5_transform(void* md5_info, char* data, int len)
|
||||
ssl_md5_transform(void *md5_info, char *data, int len)
|
||||
{
|
||||
MD5_Update((MD5_CTX*)md5_info, data, len);
|
||||
MD5_Update((MD5_CTX *)md5_info, data, len);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void APP_CC
|
||||
ssl_md5_complete(void* md5_info, char* data)
|
||||
ssl_md5_complete(void *md5_info, char *data)
|
||||
{
|
||||
MD5_Final((tui8*)data, (MD5_CTX*)md5_info);
|
||||
MD5_Final((tui8 *)data, (MD5_CTX *)md5_info);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
static void APP_CC
|
||||
ssl_reverse_it(char* p, int len)
|
||||
ssl_reverse_it(char *p, int len)
|
||||
{
|
||||
int i;
|
||||
int j;
|
||||
@@ -169,6 +167,7 @@ ssl_reverse_it(char* p, int len)
|
||||
|
||||
i = 0;
|
||||
j = len - 1;
|
||||
|
||||
while (i < j)
|
||||
{
|
||||
temp = p[i];
|
||||
@@ -181,24 +180,24 @@ ssl_reverse_it(char* p, int len)
|
||||
|
||||
/*****************************************************************************/
|
||||
int APP_CC
|
||||
ssl_mod_exp(char* out, int out_len, char* in, int in_len,
|
||||
char* mod, int mod_len, char* exp, int exp_len)
|
||||
ssl_mod_exp(char *out, int out_len, char *in, int in_len,
|
||||
char *mod, int mod_len, char *exp, int exp_len)
|
||||
{
|
||||
BN_CTX* ctx;
|
||||
BN_CTX *ctx;
|
||||
BIGNUM lmod;
|
||||
BIGNUM lexp;
|
||||
BIGNUM lin;
|
||||
BIGNUM lout;
|
||||
int rv;
|
||||
char* l_out;
|
||||
char* l_in;
|
||||
char* l_mod;
|
||||
char* l_exp;
|
||||
char *l_out;
|
||||
char *l_in;
|
||||
char *l_mod;
|
||||
char *l_exp;
|
||||
|
||||
l_out = (char*)g_malloc(out_len, 1);
|
||||
l_in = (char*)g_malloc(in_len, 1);
|
||||
l_mod = (char*)g_malloc(mod_len, 1);
|
||||
l_exp = (char*)g_malloc(exp_len, 1);
|
||||
l_out = (char *)g_malloc(out_len, 1);
|
||||
l_in = (char *)g_malloc(in_len, 1);
|
||||
l_mod = (char *)g_malloc(mod_len, 1);
|
||||
l_exp = (char *)g_malloc(exp_len, 1);
|
||||
g_memcpy(l_in, in, in_len);
|
||||
g_memcpy(l_mod, mod, mod_len);
|
||||
g_memcpy(l_exp, exp, exp_len);
|
||||
@@ -210,11 +209,12 @@ ssl_mod_exp(char* out, int out_len, char* in, int in_len,
|
||||
BN_init(&lexp);
|
||||
BN_init(&lin);
|
||||
BN_init(&lout);
|
||||
BN_bin2bn((tui8*)l_mod, mod_len, &lmod);
|
||||
BN_bin2bn((tui8*)l_exp, exp_len, &lexp);
|
||||
BN_bin2bn((tui8*)l_in, in_len, &lin);
|
||||
BN_bin2bn((tui8 *)l_mod, mod_len, &lmod);
|
||||
BN_bin2bn((tui8 *)l_exp, exp_len, &lexp);
|
||||
BN_bin2bn((tui8 *)l_in, in_len, &lin);
|
||||
BN_mod_exp(&lout, &lin, &lexp, &lmod, ctx);
|
||||
rv = BN_bn2bin(&lout, (tui8*)l_out);
|
||||
rv = BN_bn2bin(&lout, (tui8 *)l_out);
|
||||
|
||||
if (rv <= out_len)
|
||||
{
|
||||
ssl_reverse_it(l_out, rv);
|
||||
@@ -224,6 +224,7 @@ ssl_mod_exp(char* out, int out_len, char* in, int in_len,
|
||||
{
|
||||
rv = 0;
|
||||
}
|
||||
|
||||
BN_free(&lin);
|
||||
BN_free(&lout);
|
||||
BN_free(&lexp);
|
||||
@@ -242,14 +243,14 @@ ssl_mod_exp(char* out, int out_len, char* in, int in_len,
|
||||
generates a new rsa key
|
||||
exp is passed in and mod and pri are passed out */
|
||||
int APP_CC
|
||||
ssl_gen_key_xrdp1(int key_size_in_bits, char* exp, int exp_len,
|
||||
char* mod, int mod_len, char* pri, int pri_len)
|
||||
ssl_gen_key_xrdp1(int key_size_in_bits, char *exp, int exp_len,
|
||||
char *mod, int mod_len, char *pri, int pri_len)
|
||||
{
|
||||
int my_e;
|
||||
RSA* my_key;
|
||||
char* lmod;
|
||||
char* lpri;
|
||||
tui8* lexp;
|
||||
RSA *my_key;
|
||||
char *lmod;
|
||||
char *lpri;
|
||||
tui8 *lexp;
|
||||
int error;
|
||||
int len;
|
||||
|
||||
@@ -257,9 +258,10 @@ ssl_gen_key_xrdp1(int key_size_in_bits, char* exp, int exp_len,
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
lmod = (char*)g_malloc(mod_len, 0);
|
||||
lpri = (char*)g_malloc(pri_len, 0);
|
||||
lexp = (tui8*)exp;
|
||||
|
||||
lmod = (char *)g_malloc(mod_len, 0);
|
||||
lpri = (char *)g_malloc(pri_len, 0);
|
||||
lexp = (tui8 *)exp;
|
||||
my_e = lexp[0];
|
||||
my_e |= lexp[1] << 8;
|
||||
my_e |= lexp[2] << 16;
|
||||
@@ -268,31 +270,37 @@ ssl_gen_key_xrdp1(int key_size_in_bits, char* exp, int exp_len,
|
||||
srand(g_time1());
|
||||
my_key = RSA_generate_key(key_size_in_bits, my_e, 0, 0);
|
||||
error = my_key == 0;
|
||||
|
||||
if (error == 0)
|
||||
{
|
||||
len = BN_num_bytes(my_key->n);
|
||||
error = len != mod_len;
|
||||
}
|
||||
|
||||
if (error == 0)
|
||||
{
|
||||
BN_bn2bin(my_key->n, (tui8*)lmod);
|
||||
BN_bn2bin(my_key->n, (tui8 *)lmod);
|
||||
ssl_reverse_it(lmod, mod_len);
|
||||
}
|
||||
|
||||
if (error == 0)
|
||||
{
|
||||
len = BN_num_bytes(my_key->d);
|
||||
error = len != pri_len;
|
||||
}
|
||||
|
||||
if (error == 0)
|
||||
{
|
||||
BN_bn2bin(my_key->d, (tui8*)lpri);
|
||||
BN_bn2bin(my_key->d, (tui8 *)lpri);
|
||||
ssl_reverse_it(lpri, pri_len);
|
||||
}
|
||||
|
||||
if (error == 0)
|
||||
{
|
||||
g_memcpy(mod, lmod, mod_len);
|
||||
g_memcpy(pri, lpri, pri_len);
|
||||
}
|
||||
|
||||
RSA_free(my_key);
|
||||
g_free(lmod);
|
||||
g_free(lpri);
|
||||
@@ -304,14 +312,14 @@ ssl_gen_key_xrdp1(int key_size_in_bits, char* exp, int exp_len,
|
||||
generates a new rsa key
|
||||
exp is passed in and mod and pri are passed out */
|
||||
int APP_CC
|
||||
ssl_gen_key_xrdp1(int key_size_in_bits, char* exp, int exp_len,
|
||||
char* mod, int mod_len, char* pri, int pri_len)
|
||||
ssl_gen_key_xrdp1(int key_size_in_bits, char *exp, int exp_len,
|
||||
char *mod, int mod_len, char *pri, int pri_len)
|
||||
{
|
||||
BIGNUM* my_e;
|
||||
RSA* my_key;
|
||||
char* lexp;
|
||||
char* lmod;
|
||||
char* lpri;
|
||||
BIGNUM *my_e;
|
||||
RSA *my_key;
|
||||
char *lexp;
|
||||
char *lmod;
|
||||
char *lpri;
|
||||
int error;
|
||||
int len;
|
||||
|
||||
@@ -319,40 +327,47 @@ ssl_gen_key_xrdp1(int key_size_in_bits, char* exp, int exp_len,
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
lexp = (char*)g_malloc(exp_len, 0);
|
||||
lmod = (char*)g_malloc(mod_len, 0);
|
||||
lpri = (char*)g_malloc(pri_len, 0);
|
||||
|
||||
lexp = (char *)g_malloc(exp_len, 0);
|
||||
lmod = (char *)g_malloc(mod_len, 0);
|
||||
lpri = (char *)g_malloc(pri_len, 0);
|
||||
g_memcpy(lexp, exp, exp_len);
|
||||
ssl_reverse_it(lexp, exp_len);
|
||||
my_e = BN_new();
|
||||
BN_bin2bn((tui8*)lexp, exp_len, my_e);
|
||||
BN_bin2bn((tui8 *)lexp, exp_len, my_e);
|
||||
my_key = RSA_new();
|
||||
error = RSA_generate_key_ex(my_key, key_size_in_bits, my_e, 0) == 0;
|
||||
|
||||
if (error == 0)
|
||||
{
|
||||
len = BN_num_bytes(my_key->n);
|
||||
error = len != mod_len;
|
||||
}
|
||||
|
||||
if (error == 0)
|
||||
{
|
||||
BN_bn2bin(my_key->n, (tui8*)lmod);
|
||||
BN_bn2bin(my_key->n, (tui8 *)lmod);
|
||||
ssl_reverse_it(lmod, mod_len);
|
||||
}
|
||||
|
||||
if (error == 0)
|
||||
{
|
||||
len = BN_num_bytes(my_key->d);
|
||||
error = len != pri_len;
|
||||
}
|
||||
|
||||
if (error == 0)
|
||||
{
|
||||
BN_bn2bin(my_key->d, (tui8*)lpri);
|
||||
BN_bn2bin(my_key->d, (tui8 *)lpri);
|
||||
ssl_reverse_it(lpri, pri_len);
|
||||
}
|
||||
|
||||
if (error == 0)
|
||||
{
|
||||
g_memcpy(mod, lmod, mod_len);
|
||||
g_memcpy(pri, lpri, pri_len);
|
||||
}
|
||||
|
||||
BN_free(my_e);
|
||||
RSA_free(my_key);
|
||||
g_free(lexp);
|
||||
|
||||
+17
-19
@@ -1,22 +1,20 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2004-2010
|
||||
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#if !defined(SSL_CALLS_H)
|
||||
#define SSL_CALLS_H
|
||||
|
||||
+39
-38
@@ -1,27 +1,22 @@
|
||||
/*
|
||||
Copyright (c) 2004-2010 Jay Sorg
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
|
||||
thread calls
|
||||
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* thread calls
|
||||
*/
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include <windows.h>
|
||||
@@ -38,7 +33,7 @@
|
||||
/* returns error */
|
||||
#if defined(_WIN32)
|
||||
int APP_CC
|
||||
tc_thread_create(unsigned long (__stdcall * start_routine)(void*), void* arg)
|
||||
tc_thread_create(unsigned long (__stdcall *start_routine)(void *), void *arg)
|
||||
{
|
||||
int rv = 0;
|
||||
DWORD thread_id = 0;
|
||||
@@ -52,7 +47,7 @@ tc_thread_create(unsigned long (__stdcall * start_routine)(void*), void* arg)
|
||||
}
|
||||
#else
|
||||
int APP_CC
|
||||
tc_thread_create(void* (* start_routine)(void *), void* arg)
|
||||
tc_thread_create(void * (* start_routine)(void *), void *arg)
|
||||
{
|
||||
int rv = 0;
|
||||
pthread_t thread = (pthread_t)0;
|
||||
@@ -61,9 +56,12 @@ tc_thread_create(void* (* start_routine)(void *), void* arg)
|
||||
|
||||
/* pthread_create returns error */
|
||||
rv = pthread_create(&thread, 0, start_routine, arg);
|
||||
if (!rv) {
|
||||
|
||||
if (!rv)
|
||||
{
|
||||
rv = pthread_detach(thread);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
#endif
|
||||
@@ -98,9 +96,9 @@ tc_mutex_create(void)
|
||||
#if defined(_WIN32)
|
||||
return (tbus)CreateMutex(0, 0, 0);
|
||||
#else
|
||||
pthread_mutex_t* lmutex;
|
||||
pthread_mutex_t *lmutex;
|
||||
|
||||
lmutex = (pthread_mutex_t*)g_malloc(sizeof(pthread_mutex_t), 0);
|
||||
lmutex = (pthread_mutex_t *)g_malloc(sizeof(pthread_mutex_t), 0);
|
||||
pthread_mutex_init(lmutex, 0);
|
||||
return (tbus)lmutex;
|
||||
#endif
|
||||
@@ -113,9 +111,9 @@ tc_mutex_delete(tbus mutex)
|
||||
#if defined(_WIN32)
|
||||
CloseHandle((HANDLE)mutex);
|
||||
#else
|
||||
pthread_mutex_t* lmutex;
|
||||
pthread_mutex_t *lmutex;
|
||||
|
||||
lmutex = (pthread_mutex_t*)mutex;
|
||||
lmutex = (pthread_mutex_t *)mutex;
|
||||
pthread_mutex_destroy(lmutex);
|
||||
g_free(lmutex);
|
||||
#endif
|
||||
@@ -129,7 +127,7 @@ tc_mutex_lock(tbus mutex)
|
||||
WaitForSingleObject((HANDLE)mutex, INFINITE);
|
||||
return 0;
|
||||
#else
|
||||
pthread_mutex_lock((pthread_mutex_t*)mutex);
|
||||
pthread_mutex_lock((pthread_mutex_t *)mutex);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
@@ -142,9 +140,12 @@ tc_mutex_unlock(tbus mutex)
|
||||
#if defined(_WIN32)
|
||||
ReleaseMutex((HANDLE)mutex);
|
||||
#else
|
||||
if (mutex != 0) {
|
||||
|
||||
if (mutex != 0)
|
||||
{
|
||||
rv = pthread_mutex_unlock((pthread_mutex_t *)mutex);
|
||||
}
|
||||
|
||||
#endif
|
||||
return rv;
|
||||
}
|
||||
@@ -159,7 +160,7 @@ tc_sem_create(int init_count)
|
||||
sem = CreateSemaphore(0, init_count, init_count + 10, 0);
|
||||
return (tbus)sem;
|
||||
#else
|
||||
sem_t * sem = (sem_t *)NULL;
|
||||
sem_t *sem = (sem_t *)NULL;
|
||||
|
||||
sem = (sem_t *)g_malloc(sizeof(sem_t), 0);
|
||||
sem_init(sem, 0, init_count);
|
||||
@@ -174,9 +175,9 @@ tc_sem_delete(tbus sem)
|
||||
#if defined(_WIN32)
|
||||
CloseHandle((HANDLE)sem);
|
||||
#else
|
||||
sem_t* lsem;
|
||||
sem_t *lsem;
|
||||
|
||||
lsem = (sem_t*)sem;
|
||||
lsem = (sem_t *)sem;
|
||||
sem_destroy(lsem);
|
||||
g_free(lsem);
|
||||
#endif
|
||||
@@ -190,7 +191,7 @@ tc_sem_dec(tbus sem)
|
||||
WaitForSingleObject((HANDLE)sem, INFINITE);
|
||||
return 0;
|
||||
#else
|
||||
sem_wait((sem_t*)sem);
|
||||
sem_wait((sem_t *)sem);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
@@ -203,7 +204,7 @@ tc_sem_inc(tbus sem)
|
||||
ReleaseSemaphore((HANDLE)sem, 1, 0);
|
||||
return 0;
|
||||
#else
|
||||
sem_post((sem_t*)sem);
|
||||
sem_post((sem_t *)sem);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
+19
-24
@@ -1,27 +1,22 @@
|
||||
/*
|
||||
Copyright (c) 2004-2010 Jay Sorg
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
|
||||
thread calls
|
||||
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* thread calls
|
||||
*/
|
||||
|
||||
#if !defined(THREAD_CALLS_H)
|
||||
#define THREAD_CALLS_H
|
||||
|
||||
+91
-50
@@ -1,27 +1,22 @@
|
||||
/*
|
||||
Copyright (c) 2008-2010 Jay Sorg
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
|
||||
generic transport
|
||||
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* generic transport
|
||||
*/
|
||||
|
||||
#include "os_calls.h"
|
||||
#include "trans.h"
|
||||
@@ -29,56 +24,67 @@
|
||||
#include "parse.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
struct trans* APP_CC
|
||||
struct trans *APP_CC
|
||||
trans_create(int mode, int in_size, int out_size)
|
||||
{
|
||||
struct trans* self = (struct trans *)NULL;
|
||||
struct trans *self = (struct trans *)NULL;
|
||||
|
||||
self = (struct trans*)g_malloc(sizeof(struct trans), 1);
|
||||
if (self != NULL) {
|
||||
self = (struct trans *)g_malloc(sizeof(struct trans), 1);
|
||||
|
||||
if (self != NULL)
|
||||
{
|
||||
make_stream(self->in_s);
|
||||
init_stream(self->in_s, in_size);
|
||||
make_stream(self->out_s);
|
||||
init_stream(self->out_s, out_size);
|
||||
self->mode = mode;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void APP_CC
|
||||
trans_delete(struct trans* self)
|
||||
trans_delete(struct trans *self)
|
||||
{
|
||||
if (self == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
free_stream(self->in_s);
|
||||
free_stream(self->out_s);
|
||||
if (self->sck > 0) {
|
||||
|
||||
if (self->sck > 0)
|
||||
{
|
||||
g_tcp_close(self->sck);
|
||||
}
|
||||
|
||||
self->sck = 0;
|
||||
|
||||
if (self->listen_filename != 0)
|
||||
{
|
||||
g_file_delete(self->listen_filename);
|
||||
g_free(self->listen_filename);
|
||||
}
|
||||
|
||||
g_free(self);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
int APP_CC
|
||||
trans_get_wait_objs(struct trans* self, tbus* objs, int* count)
|
||||
trans_get_wait_objs(struct trans *self, tbus *objs, int *count)
|
||||
{
|
||||
if (self == 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (self->status != TRANS_STATUS_UP)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
objs[*count] = self->sck;
|
||||
(*count)++;
|
||||
return 0;
|
||||
@@ -86,10 +92,10 @@ trans_get_wait_objs(struct trans* self, tbus* objs, int* count)
|
||||
|
||||
/*****************************************************************************/
|
||||
int APP_CC
|
||||
trans_check_wait_objs(struct trans* self)
|
||||
trans_check_wait_objs(struct trans *self)
|
||||
{
|
||||
tbus in_sck = (tbus)0;
|
||||
struct trans* in_trans = (struct trans *)NULL;
|
||||
struct trans *in_trans = (struct trans *)NULL;
|
||||
int read_bytes = 0;
|
||||
int to_read = 0;
|
||||
int read_so_far = 0;
|
||||
@@ -99,16 +105,20 @@ trans_check_wait_objs(struct trans* self)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (self->status != TRANS_STATUS_UP)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
rv = 0;
|
||||
|
||||
if (self->type1 == TRANS_TYPE_LISTENER) /* listening */
|
||||
{
|
||||
if (g_tcp_can_recv(self->sck, 0))
|
||||
{
|
||||
in_sck = g_tcp_accept(self->sck);
|
||||
|
||||
if (in_sck == -1)
|
||||
{
|
||||
if (g_tcp_last_error_would_block(self->sck))
|
||||
@@ -122,6 +132,7 @@ trans_check_wait_objs(struct trans* self)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (in_sck != -1)
|
||||
{
|
||||
if (self->trans_conn_in != 0) /* is function assigned */
|
||||
@@ -131,6 +142,7 @@ trans_check_wait_objs(struct trans* self)
|
||||
in_trans->sck = in_sck;
|
||||
in_trans->type1 = TRANS_TYPE_SERVER;
|
||||
in_trans->status = TRANS_STATUS_UP;
|
||||
|
||||
if (self->trans_conn_in(self, in_trans) != 0)
|
||||
{
|
||||
trans_delete(in_trans);
|
||||
@@ -149,9 +161,11 @@ trans_check_wait_objs(struct trans* self)
|
||||
{
|
||||
read_so_far = (int)(self->in_s->end - self->in_s->data);
|
||||
to_read = self->header_size - read_so_far;
|
||||
|
||||
if (to_read > 0)
|
||||
{
|
||||
read_bytes = g_tcp_recv(self->sck, self->in_s->end, to_read, 0);
|
||||
|
||||
if (read_bytes == -1)
|
||||
{
|
||||
if (g_tcp_last_error_would_block(self->sck))
|
||||
@@ -176,7 +190,9 @@ trans_check_wait_objs(struct trans* self)
|
||||
self->in_s->end += read_bytes;
|
||||
}
|
||||
}
|
||||
|
||||
read_so_far = (int)(self->in_s->end - self->in_s->data);
|
||||
|
||||
if (read_so_far == self->header_size)
|
||||
{
|
||||
if (self->trans_data_in != 0)
|
||||
@@ -187,12 +203,13 @@ trans_check_wait_objs(struct trans* self)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
int APP_CC
|
||||
trans_force_read_s(struct trans* self, struct stream* in_s, int size)
|
||||
trans_force_read_s(struct trans *self, struct stream *in_s, int size)
|
||||
{
|
||||
int rcvd;
|
||||
|
||||
@@ -200,9 +217,11 @@ trans_force_read_s(struct trans* self, struct stream* in_s, int size)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
while (size > 0)
|
||||
{
|
||||
rcvd = g_tcp_recv(self->sck, in_s->end, size, 0);
|
||||
|
||||
if (rcvd == -1)
|
||||
{
|
||||
if (g_tcp_last_error_would_block(self->sck))
|
||||
@@ -231,19 +250,20 @@ trans_force_read_s(struct trans* self, struct stream* in_s, int size)
|
||||
size -= rcvd;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
int APP_CC
|
||||
trans_force_read(struct trans* self, int size)
|
||||
trans_force_read(struct trans *self, int size)
|
||||
{
|
||||
return trans_force_read_s(self, self->in_s, size);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
int APP_CC
|
||||
trans_force_write_s(struct trans* self, struct stream* out_s)
|
||||
trans_force_write_s(struct trans *self, struct stream *out_s)
|
||||
{
|
||||
int size;
|
||||
int total;
|
||||
@@ -253,11 +273,14 @@ trans_force_write_s(struct trans* self, struct stream* out_s)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
size = (int)(out_s->end - out_s->data);
|
||||
total = 0;
|
||||
|
||||
while (total < size)
|
||||
{
|
||||
sent = g_tcp_send(self->sck, out_s->data + total, size - total, 0);
|
||||
|
||||
if (sent == -1)
|
||||
{
|
||||
if (g_tcp_last_error_would_block(self->sck))
|
||||
@@ -285,19 +308,20 @@ trans_force_write_s(struct trans* self, struct stream* out_s)
|
||||
total = total + sent;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
int APP_CC
|
||||
trans_force_write(struct trans* self)
|
||||
trans_force_write(struct trans *self)
|
||||
{
|
||||
return trans_force_write_s(self, self->out_s);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
int APP_CC
|
||||
trans_connect(struct trans* self, const char* server, const char* port,
|
||||
trans_connect(struct trans *self, const char *server, const char *port,
|
||||
int timeout)
|
||||
{
|
||||
int error;
|
||||
@@ -306,6 +330,7 @@ trans_connect(struct trans* self, const char* server, const char* port,
|
||||
{
|
||||
g_tcp_close(self->sck);
|
||||
}
|
||||
|
||||
if (self->mode == TRANS_MODE_TCP) /* tcp */
|
||||
{
|
||||
self->sck = g_tcp_socket();
|
||||
@@ -323,6 +348,7 @@ trans_connect(struct trans* self, const char* server, const char* port,
|
||||
self->status = TRANS_STATUS_DOWN;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (error == -1)
|
||||
{
|
||||
if (g_tcp_last_error_would_block(self->sck))
|
||||
@@ -334,8 +360,10 @@ trans_connect(struct trans* self, const char* server, const char* port,
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
self->status = TRANS_STATUS_UP; /* ok */
|
||||
self->type1 = TRANS_TYPE_CLIENT; /* client */
|
||||
return 0;
|
||||
@@ -343,16 +371,18 @@ trans_connect(struct trans* self, const char* server, const char* port,
|
||||
|
||||
/*****************************************************************************/
|
||||
int APP_CC
|
||||
trans_listen_address(struct trans* self, char* port, const char* address)
|
||||
trans_listen_address(struct trans *self, char *port, const char *address)
|
||||
{
|
||||
if (self->sck != 0)
|
||||
{
|
||||
g_tcp_close(self->sck);
|
||||
}
|
||||
|
||||
if (self->mode == TRANS_MODE_TCP) /* tcp */
|
||||
{
|
||||
self->sck = g_tcp_socket();
|
||||
g_tcp_set_non_blocking(self->sck);
|
||||
|
||||
if (g_tcp_bind_address(self->sck, port, address) == 0)
|
||||
{
|
||||
if (g_tcp_listen(self->sck) == 0)
|
||||
@@ -370,9 +400,11 @@ trans_listen_address(struct trans* self, char* port, const char* address)
|
||||
g_file_delete(port);
|
||||
self->sck = g_tcp_local_socket();
|
||||
g_tcp_set_non_blocking(self->sck);
|
||||
|
||||
if (g_tcp_local_bind(self->sck, port) == 0)
|
||||
{
|
||||
self->listen_filename = g_strdup(port);
|
||||
|
||||
if (g_tcp_listen(self->sck) == 0)
|
||||
{
|
||||
g_chmod_hex(port, 0xffff);
|
||||
@@ -382,41 +414,50 @@ trans_listen_address(struct trans* self, char* port, const char* address)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
int APP_CC
|
||||
trans_listen(struct trans* self, char* port)
|
||||
trans_listen(struct trans *self, char *port)
|
||||
{
|
||||
return trans_listen_address(self, port, "0.0.0.0");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
struct stream* APP_CC
|
||||
trans_get_in_s(struct trans* self)
|
||||
struct stream *APP_CC
|
||||
trans_get_in_s(struct trans *self)
|
||||
{
|
||||
struct stream * rv = (struct stream *)NULL;
|
||||
if (self == NULL) {
|
||||
struct stream *rv = (struct stream *)NULL;
|
||||
|
||||
if (self == NULL)
|
||||
{
|
||||
rv = (struct stream *)NULL;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
rv = self->in_s;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
struct stream* APP_CC
|
||||
trans_get_out_s(struct trans* self, int size)
|
||||
struct stream *APP_CC
|
||||
trans_get_out_s(struct trans *self, int size)
|
||||
{
|
||||
struct stream * rv = (struct stream *)NULL;
|
||||
if (self == NULL) {
|
||||
struct stream *rv = (struct stream *)NULL;
|
||||
|
||||
if (self == NULL)
|
||||
{
|
||||
rv = (struct stream *)NULL;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
init_stream(self->out_s, size);
|
||||
rv = self->out_s;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
+19
-24
@@ -1,27 +1,22 @@
|
||||
/*
|
||||
Copyright (c) 2008-2010 Jay Sorg
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
|
||||
generic transport
|
||||
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* generic transport
|
||||
*/
|
||||
|
||||
#if !defined(TRANS_H)
|
||||
#define TRANS_H
|
||||
|
||||
+19
-24
@@ -1,27 +1,22 @@
|
||||
/*
|
||||
Copyright (c) 2012 Jay Sorg
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
|
||||
xrdp / xserver info / caps
|
||||
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* xrdp / xserver info / caps
|
||||
*/
|
||||
|
||||
#if !defined(XRDP_CLIENT_INFO_H)
|
||||
#define XRDP_CLIENT_INFO_H
|
||||
|
||||
+102
-26
@@ -1,3 +1,20 @@
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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 <windows.h>
|
||||
#include <tchar.h>
|
||||
@@ -33,12 +50,13 @@ check_messages(void)
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
static int
|
||||
msg(char* msg1, ...)
|
||||
msg(char *msg1, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char text1[512];
|
||||
@@ -76,13 +94,13 @@ font_dump(void)
|
||||
HGDIOBJ saved;
|
||||
HBITMAP bitmap;
|
||||
BITMAPINFO bi;
|
||||
char* bits;
|
||||
char *bits;
|
||||
ABC abc;
|
||||
SIZE sz;
|
||||
char filename[256];
|
||||
TCHAR text[256];
|
||||
char zero1;
|
||||
char* bmtext;
|
||||
char *bmtext;
|
||||
int bmtextindex;
|
||||
int fd;
|
||||
int x1;
|
||||
@@ -105,25 +123,30 @@ font_dump(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
g_running = 1;
|
||||
msg("starting");
|
||||
g_font_name[0] = 0;
|
||||
SendMessageA(g_font_list, WM_GETTEXT, 255, (LPARAM)g_font_name);
|
||||
|
||||
if (g_strlen(g_font_name) == 0)
|
||||
{
|
||||
msg("error font not set");
|
||||
g_running = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
dc = GetDC(g_wnd);
|
||||
height = -MulDiv(g_font_size, GetDeviceCaps(dc, LOGPIXELSY), 72);
|
||||
g_font = CreateFontA(height, 0, 0, 0, FW_DONTCARE, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, g_font_name);
|
||||
ReleaseDC(g_wnd, dc);
|
||||
|
||||
if (g_font == 0)
|
||||
{
|
||||
msg("error - Font creation failed");
|
||||
}
|
||||
|
||||
zero1 = 0;
|
||||
g_snprintf(filename, 255, "%s-%d.fv1", g_font_name, g_font_size);
|
||||
msg("creating file %s", filename);
|
||||
@@ -133,73 +156,86 @@ font_dump(void)
|
||||
strlen1 = g_strlen(g_font_name);
|
||||
g_file_write(fd, g_font_name, strlen1);
|
||||
x1 = strlen1;
|
||||
|
||||
while (x1 < 32)
|
||||
{
|
||||
g_file_write(fd, &zero1, 1);
|
||||
x1++;
|
||||
}
|
||||
|
||||
x2 = g_font_size; /* font size */
|
||||
g_file_write(fd, (char*)&x2, 2);
|
||||
g_file_write(fd, (char *)&x2, 2);
|
||||
x2 = 1; /* style */
|
||||
g_file_write(fd, (char*)&x2, 2);
|
||||
g_file_write(fd, (char *)&x2, 2);
|
||||
/* pad */
|
||||
index1 = 0;
|
||||
|
||||
while (index1 < 8)
|
||||
{
|
||||
g_file_write(fd, &zero1, 1);
|
||||
index1++;
|
||||
}
|
||||
|
||||
for (x1 = 32; x1 < 0x4e00; x1++)
|
||||
{
|
||||
check_messages();
|
||||
dc = GetWindowDC(g_wnd);
|
||||
saved = SelectObject(dc, g_font);
|
||||
|
||||
if (!GetCharABCWidths(dc, x1, x1, &abc))
|
||||
{
|
||||
show_last_error();
|
||||
}
|
||||
|
||||
text[0] = (TCHAR)x1;
|
||||
text[1] = 0;
|
||||
|
||||
if (!GetTextExtentPoint32(dc, text, 1, &sz))
|
||||
{
|
||||
show_last_error();
|
||||
}
|
||||
|
||||
SelectObject(dc, saved);
|
||||
ReleaseDC(g_wnd, dc);
|
||||
|
||||
if ((sz.cx > 0) && (sz.cy > 0))
|
||||
{
|
||||
dc = GetWindowDC(g_wnd);
|
||||
saved = SelectObject(dc, g_font);
|
||||
SetBkColor(dc, RGB(255, 255, 255));
|
||||
|
||||
if (!ExtTextOut(dc, 50, 50, ETO_OPAQUE, 0, text, 1, 0))
|
||||
{
|
||||
show_last_error();
|
||||
}
|
||||
|
||||
SelectObject(dc, saved);
|
||||
ReleaseDC(g_wnd, dc);
|
||||
Sleep(10);
|
||||
/* width */
|
||||
x2 = abc.abcB;
|
||||
g_file_write(fd, (char*)&x2, 2);
|
||||
g_file_write(fd, (char *)&x2, 2);
|
||||
/* height */
|
||||
x2 = sz.cy;
|
||||
g_file_write(fd, (char*)&x2, 2);
|
||||
g_file_write(fd, (char *)&x2, 2);
|
||||
/* baseline */
|
||||
x2 = -sz.cy;
|
||||
g_file_write(fd, (char*)&x2, 2);
|
||||
g_file_write(fd, (char *)&x2, 2);
|
||||
/* offset */
|
||||
x2 = abc.abcA;
|
||||
g_file_write(fd, (char*)&x2, 2);
|
||||
g_file_write(fd, (char *)&x2, 2);
|
||||
/* incby */
|
||||
x2 = sz.cx;
|
||||
g_file_write(fd, (char*)&x2, 2);
|
||||
g_file_write(fd, (char *)&x2, 2);
|
||||
/* pad */
|
||||
index1 = 0;
|
||||
|
||||
while (index1 < 6)
|
||||
{
|
||||
g_file_write(fd, &zero1, 1);
|
||||
index1++;
|
||||
}
|
||||
|
||||
dc = GetWindowDC(g_wnd);
|
||||
rect.left = 50 + abc.abcA;
|
||||
rect.top = 50;
|
||||
@@ -213,7 +249,8 @@ font_dump(void)
|
||||
bi.bmiHeader.biHeight = height;
|
||||
bi.bmiHeader.biPlanes = 1;
|
||||
bi.bmiHeader.biBitCount = 32;
|
||||
bitmap = CreateDIBSection(dc, &bi, DIB_RGB_COLORS, (void*)&bits, 0, 0);
|
||||
bitmap = CreateDIBSection(dc, &bi, DIB_RGB_COLORS, (void *)&bits, 0, 0);
|
||||
|
||||
if (bitmap == 0)
|
||||
{
|
||||
msg("error - CreateDIBSection failed");
|
||||
@@ -223,20 +260,24 @@ font_dump(void)
|
||||
memset(bits, 0, width * height * 4);
|
||||
dc1 = CreateCompatibleDC(dc);
|
||||
SelectObject(dc1, bitmap);
|
||||
|
||||
if (!BitBlt(dc1, 0, 0, width, height, dc, rect.left, rect.top, SRCCOPY))
|
||||
{
|
||||
show_last_error();
|
||||
}
|
||||
bmtext = (char*)g_malloc(width * height + 16, 1);
|
||||
|
||||
bmtext = (char *)g_malloc(width * height + 16, 1);
|
||||
bmtextindex = 0;
|
||||
|
||||
for (index1 = (height - 1); index1 >= 0; index1--)
|
||||
{
|
||||
for (index2 = 0; index2 < width; index2++)
|
||||
{
|
||||
pixel = ((int*)bits)[index1 * width + index2];
|
||||
pixel = ((int *)bits)[index1 * width + index2];
|
||||
red = (pixel >> 16) & 0xff;
|
||||
green = (pixel >> 8) & 0xff;
|
||||
blue = (pixel >> 0) & 0xff;
|
||||
|
||||
if (red == 0 && green == 0 && blue == 0)
|
||||
{
|
||||
bmtext[bmtextindex] = '1';
|
||||
@@ -249,27 +290,47 @@ font_dump(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
outlen = 0;
|
||||
b1 = 0;
|
||||
roller = 0;
|
||||
len = g_strlen(bmtext);
|
||||
|
||||
for (index2 = 0; index2 < len; index2++)
|
||||
{
|
||||
if (bmtext[index2] == '1')
|
||||
{
|
||||
switch (roller)
|
||||
{
|
||||
case 0: b1 = b1 | 0x80; break;
|
||||
case 1: b1 = b1 | 0x40; break;
|
||||
case 2: b1 = b1 | 0x20; break;
|
||||
case 3: b1 = b1 | 0x10; break;
|
||||
case 4: b1 = b1 | 0x08; break;
|
||||
case 5: b1 = b1 | 0x04; break;
|
||||
case 6: b1 = b1 | 0x02; break;
|
||||
case 7: b1 = b1 | 0x01; break;
|
||||
case 0:
|
||||
b1 = b1 | 0x80;
|
||||
break;
|
||||
case 1:
|
||||
b1 = b1 | 0x40;
|
||||
break;
|
||||
case 2:
|
||||
b1 = b1 | 0x20;
|
||||
break;
|
||||
case 3:
|
||||
b1 = b1 | 0x10;
|
||||
break;
|
||||
case 4:
|
||||
b1 = b1 | 0x08;
|
||||
break;
|
||||
case 5:
|
||||
b1 = b1 | 0x04;
|
||||
break;
|
||||
case 6:
|
||||
b1 = b1 | 0x02;
|
||||
break;
|
||||
case 7:
|
||||
b1 = b1 | 0x01;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
roller++;
|
||||
|
||||
if (roller == 8)
|
||||
{
|
||||
roller = 0;
|
||||
@@ -278,19 +339,23 @@ font_dump(void)
|
||||
b1 = 0;
|
||||
}
|
||||
}
|
||||
|
||||
while ((outlen % 4) != 0)
|
||||
{
|
||||
g_file_write(fd, &zero1, 1);
|
||||
outlen++;
|
||||
}
|
||||
|
||||
free(bmtext);
|
||||
DeleteDC(dc1);
|
||||
DeleteObject(bitmap);
|
||||
}
|
||||
|
||||
if (sz.cx != (long)(abc.abcA + abc.abcB + abc.abcC))
|
||||
{
|
||||
msg("error - width not right 1");
|
||||
}
|
||||
|
||||
brush = CreateSolidBrush(RGB(255, 255, 255));
|
||||
FillRect(dc, &rect, brush);
|
||||
DeleteObject(brush);
|
||||
@@ -301,28 +366,31 @@ font_dump(void)
|
||||
/* write out a blank glyph here */
|
||||
/* width */
|
||||
x2 = 1;
|
||||
g_file_write(fd, (char*)&x2, 2);
|
||||
g_file_write(fd, (char *)&x2, 2);
|
||||
/* height */
|
||||
x2 = 1;
|
||||
g_file_write(fd, (char*)&x2, 2);
|
||||
g_file_write(fd, (char *)&x2, 2);
|
||||
/* baseline */
|
||||
x2 = 0;
|
||||
g_file_write(fd, (char*)&x2, 2);
|
||||
g_file_write(fd, (char *)&x2, 2);
|
||||
/* offset */
|
||||
x2 = 0;
|
||||
g_file_write(fd, (char*)&x2, 2);
|
||||
g_file_write(fd, (char *)&x2, 2);
|
||||
/* incby */
|
||||
x2 = 1;
|
||||
g_file_write(fd, (char*)&x2, 2);
|
||||
g_file_write(fd, (char *)&x2, 2);
|
||||
/* pad */
|
||||
index1 = 0;
|
||||
|
||||
while (index1 < 6)
|
||||
{
|
||||
g_file_write(fd, &zero1, 1);
|
||||
index1++;
|
||||
}
|
||||
|
||||
/* blank bitmap */
|
||||
index1 = 0;
|
||||
|
||||
while (index1 < 4)
|
||||
{
|
||||
g_file_write(fd, &zero1, 1);
|
||||
@@ -330,6 +398,7 @@ font_dump(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
g_file_close(fd);
|
||||
msg("done");
|
||||
g_running = 0;
|
||||
@@ -366,6 +435,7 @@ wnd_proc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
font_dump();
|
||||
break;
|
||||
case WM_COMMAND:
|
||||
|
||||
if ((HWND)lParam == g_exit_button)
|
||||
{
|
||||
PostMessage(g_wnd, WM_CLOSE, 0, 0);
|
||||
@@ -376,10 +446,13 @@ wnd_proc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
SendMessage(g_lb, LB_DELETESTRING, 0, 0);
|
||||
}
|
||||
|
||||
SetTimer(g_wnd, 1, 1000, 0);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||
}
|
||||
|
||||
@@ -399,11 +472,13 @@ create_window(void)
|
||||
/* name of window class */
|
||||
wc.lpszClassName = _T("fontdump");
|
||||
wc.hCursor = LoadCursor(0, IDC_ARROW);
|
||||
|
||||
/* Register the window class. */
|
||||
if (!RegisterClass(&wc))
|
||||
{
|
||||
return 0; /* Failed to register window class */
|
||||
}
|
||||
|
||||
style = WS_OVERLAPPED | WS_CAPTION | WS_POPUP | WS_MINIMIZEBOX |
|
||||
WS_SYSMENU | WS_SIZEBOX | WS_MAXIMIZEBOX;
|
||||
left = GetSystemMetrics(SM_CXSCREEN) / 2 - 640 / 2;
|
||||
@@ -444,6 +519,7 @@ main_loop(void)
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
|
||||
return (int)(msg.wParam);
|
||||
}
|
||||
|
||||
|
||||
+85
-50
@@ -1,34 +1,32 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2010
|
||||
|
||||
freerdp wrapper
|
||||
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* freerdp wrapper
|
||||
*/
|
||||
|
||||
#include "xrdp-freerdp.h"
|
||||
|
||||
char* APP_CC
|
||||
convert_bitmap(int in_bpp, int out_bpp, char* bmpdata,
|
||||
int width, int height, int* palette)
|
||||
char *APP_CC
|
||||
convert_bitmap(int in_bpp, int out_bpp, char *bmpdata,
|
||||
int width, int height, int *palette)
|
||||
{
|
||||
char* out;
|
||||
char* src;
|
||||
char* dst;
|
||||
char *out;
|
||||
char *src;
|
||||
char *dst;
|
||||
int i;
|
||||
int j;
|
||||
int red;
|
||||
@@ -38,14 +36,15 @@ convert_bitmap(int in_bpp, int out_bpp, char* bmpdata,
|
||||
|
||||
if ((in_bpp == 8) && (out_bpp == 8))
|
||||
{
|
||||
out = (char*)g_malloc(width * height, 0);
|
||||
out = (char *)g_malloc(width * height, 0);
|
||||
src = bmpdata;
|
||||
dst = out;
|
||||
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
for (j = 0; j < width; j++)
|
||||
{
|
||||
pixel = *((tui8*)src);
|
||||
pixel = *((tui8 *)src);
|
||||
pixel = palette[pixel];
|
||||
SPLITCOLOR32(red, green, blue, pixel);
|
||||
pixel = COLOR8(red, green, blue);
|
||||
@@ -54,143 +53,167 @@ convert_bitmap(int in_bpp, int out_bpp, char* bmpdata,
|
||||
dst++;
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
if ((in_bpp == 8) && (out_bpp == 16))
|
||||
{
|
||||
out = (char*)g_malloc(width * height * 2, 0);
|
||||
out = (char *)g_malloc(width * height * 2, 0);
|
||||
src = bmpdata;
|
||||
dst = out;
|
||||
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
for (j = 0; j < width; j++)
|
||||
{
|
||||
pixel = *((tui8*)src);
|
||||
pixel = *((tui8 *)src);
|
||||
pixel = palette[pixel];
|
||||
SPLITCOLOR32(red, green, blue, pixel);
|
||||
pixel = COLOR16(red, green, blue);
|
||||
*((tui16*)dst) = pixel;
|
||||
*((tui16 *)dst) = pixel;
|
||||
src++;
|
||||
dst += 2;
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
if ((in_bpp == 8) && (out_bpp == 24))
|
||||
{
|
||||
out = (char*)g_malloc(width * height * 4, 0);
|
||||
out = (char *)g_malloc(width * height * 4, 0);
|
||||
src = bmpdata;
|
||||
dst = out;
|
||||
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
for (j = 0; j < width; j++)
|
||||
{
|
||||
pixel = *((tui8*)src);
|
||||
pixel = *((tui8 *)src);
|
||||
pixel = palette[pixel];
|
||||
SPLITCOLOR32(red, green, blue, pixel);
|
||||
pixel = COLOR24RGB(red, green, blue);
|
||||
*((tui32*)dst) = pixel;
|
||||
*((tui32 *)dst) = pixel;
|
||||
src++;
|
||||
dst += 4;
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
if ((in_bpp == 15) && (out_bpp == 16))
|
||||
{
|
||||
out = (char*)g_malloc(width * height * 2, 0);
|
||||
out = (char *)g_malloc(width * height * 2, 0);
|
||||
src = bmpdata;
|
||||
dst = out;
|
||||
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
for (j = 0; j < width; j++)
|
||||
{
|
||||
pixel = *((tui16*)src);
|
||||
pixel = *((tui16 *)src);
|
||||
SPLITCOLOR15(red, green, blue, pixel);
|
||||
pixel = COLOR16(red, green, blue);
|
||||
*((tui16*)dst) = pixel;
|
||||
*((tui16 *)dst) = pixel;
|
||||
src += 2;
|
||||
dst += 2;
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
if ((in_bpp == 15) && (out_bpp == 24))
|
||||
{
|
||||
out = (char*)g_malloc(width * height * 4, 0);
|
||||
out = (char *)g_malloc(width * height * 4, 0);
|
||||
src = bmpdata;
|
||||
dst = out;
|
||||
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
for (j = 0; j < width; j++)
|
||||
{
|
||||
pixel = *((tui16*)src);
|
||||
pixel = *((tui16 *)src);
|
||||
SPLITCOLOR15(red, green, blue, pixel);
|
||||
pixel = COLOR24RGB(red, green, blue);
|
||||
*((tui32*)dst) = pixel;
|
||||
*((tui32 *)dst) = pixel;
|
||||
src += 2;
|
||||
dst += 4;
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
if ((in_bpp == 16) && (out_bpp == 16))
|
||||
{
|
||||
return bmpdata;
|
||||
}
|
||||
|
||||
if ((in_bpp == 16) && (out_bpp == 24))
|
||||
{
|
||||
out = (char*)g_malloc(width * height * 4, 0);
|
||||
out = (char *)g_malloc(width * height * 4, 0);
|
||||
src = bmpdata;
|
||||
dst = out;
|
||||
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
for (j = 0; j < width; j++)
|
||||
{
|
||||
pixel = *((tui16*)src);
|
||||
pixel = *((tui16 *)src);
|
||||
SPLITCOLOR16(red, green, blue, pixel);
|
||||
pixel = COLOR24RGB(red, green, blue);
|
||||
*((tui32*)dst) = pixel;
|
||||
*((tui32 *)dst) = pixel;
|
||||
src += 2;
|
||||
dst += 4;
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
if ((in_bpp == 24) && (out_bpp == 24))
|
||||
{
|
||||
out = (char*)g_malloc(width * height * 4, 0);
|
||||
out = (char *)g_malloc(width * height * 4, 0);
|
||||
src = bmpdata;
|
||||
dst = out;
|
||||
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
for (j = 0; j < width; j++)
|
||||
{
|
||||
blue = *((tui8*)src);
|
||||
blue = *((tui8 *)src);
|
||||
src++;
|
||||
green = *((tui8*)src);
|
||||
green = *((tui8 *)src);
|
||||
src++;
|
||||
red = *((tui8*)src);
|
||||
red = *((tui8 *)src);
|
||||
src++;
|
||||
pixel = COLOR24RGB(red, green, blue);
|
||||
*((tui32*)dst) = pixel;
|
||||
*((tui32 *)dst) = pixel;
|
||||
dst += 4;
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
if ((in_bpp == 32) && (out_bpp == 24))
|
||||
{
|
||||
return bmpdata;
|
||||
}
|
||||
|
||||
if ((in_bpp == 32) && (out_bpp == 32))
|
||||
{
|
||||
return bmpdata;
|
||||
}
|
||||
|
||||
if ((in_bpp == 15) && (out_bpp == 15))
|
||||
{
|
||||
return bmpdata;
|
||||
}
|
||||
|
||||
g_writeln("convert_bitmap: error unknown conversion from %d to %d",
|
||||
in_bpp, out_bpp);
|
||||
return 0;
|
||||
@@ -199,7 +222,7 @@ convert_bitmap(int in_bpp, int out_bpp, char* bmpdata,
|
||||
/*****************************************************************************/
|
||||
/* returns color or 0 */
|
||||
int APP_CC
|
||||
convert_color(int in_bpp, int out_bpp, int in_color, int* palette)
|
||||
convert_color(int in_bpp, int out_bpp, int in_color, int *palette)
|
||||
{
|
||||
int pixel;
|
||||
int red;
|
||||
@@ -211,6 +234,7 @@ convert_color(int in_bpp, int out_bpp, int in_color, int* palette)
|
||||
pixel = in_color == 0 ? 0 : 0xffffff;
|
||||
return pixel;
|
||||
}
|
||||
|
||||
if ((in_bpp == 8) && (out_bpp == 8))
|
||||
{
|
||||
pixel = palette[in_color];
|
||||
@@ -218,6 +242,7 @@ convert_color(int in_bpp, int out_bpp, int in_color, int* palette)
|
||||
pixel = COLOR8(red, green, blue);
|
||||
return pixel;
|
||||
}
|
||||
|
||||
if ((in_bpp == 8) && (out_bpp == 16))
|
||||
{
|
||||
pixel = palette[in_color];
|
||||
@@ -225,6 +250,7 @@ convert_color(int in_bpp, int out_bpp, int in_color, int* palette)
|
||||
pixel = COLOR16(red, green, blue);
|
||||
return pixel;
|
||||
}
|
||||
|
||||
if ((in_bpp == 8) && (out_bpp == 24))
|
||||
{
|
||||
pixel = palette[in_color];
|
||||
@@ -232,6 +258,7 @@ convert_color(int in_bpp, int out_bpp, int in_color, int* palette)
|
||||
pixel = COLOR24BGR(red, green, blue);
|
||||
return pixel;
|
||||
}
|
||||
|
||||
if ((in_bpp == 15) && (out_bpp == 16))
|
||||
{
|
||||
pixel = in_color;
|
||||
@@ -239,6 +266,7 @@ convert_color(int in_bpp, int out_bpp, int in_color, int* palette)
|
||||
pixel = COLOR16(red, green, blue);
|
||||
return pixel;
|
||||
}
|
||||
|
||||
if ((in_bpp == 15) && (out_bpp == 24))
|
||||
{
|
||||
pixel = in_color;
|
||||
@@ -246,10 +274,12 @@ convert_color(int in_bpp, int out_bpp, int in_color, int* palette)
|
||||
pixel = COLOR24BGR(red, green, blue);
|
||||
return pixel;
|
||||
}
|
||||
|
||||
if ((in_bpp == 16) && (out_bpp == 16))
|
||||
{
|
||||
return in_color;
|
||||
}
|
||||
|
||||
if ((in_bpp == 16) && (out_bpp == 24))
|
||||
{
|
||||
pixel = in_color;
|
||||
@@ -257,22 +287,27 @@ convert_color(int in_bpp, int out_bpp, int in_color, int* palette)
|
||||
pixel = COLOR24BGR(red, green, blue);
|
||||
return pixel;
|
||||
}
|
||||
|
||||
if ((in_bpp == 24) && (out_bpp == 24))
|
||||
{
|
||||
return in_color;
|
||||
}
|
||||
|
||||
if ((in_bpp == 32) && (out_bpp == 24))
|
||||
{
|
||||
return in_color;
|
||||
}
|
||||
|
||||
if ((in_bpp == 32) && (out_bpp == 32))
|
||||
{
|
||||
return in_color;
|
||||
}
|
||||
|
||||
if ((in_bpp == 15) && (out_bpp == 15))
|
||||
{
|
||||
return in_color;
|
||||
}
|
||||
|
||||
g_writeln("convert_color: error unknown conversion from %d to %d",
|
||||
in_bpp, out_bpp);
|
||||
return 0;
|
||||
|
||||
+17
-19
@@ -1,22 +1,20 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2010
|
||||
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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 __XRDP_COLOR_H
|
||||
#define __XRDP_COLOR_H
|
||||
|
||||
+182
-153
@@ -1,24 +1,22 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2010
|
||||
|
||||
freerdp wrapper
|
||||
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* freerdp wrapper
|
||||
*/
|
||||
|
||||
#include "xrdp-freerdp.h"
|
||||
#include "xrdp-color.h"
|
||||
@@ -28,7 +26,7 @@
|
||||
|
||||
struct my_bitmap
|
||||
{
|
||||
char* data;
|
||||
char *data;
|
||||
int width;
|
||||
int height;
|
||||
int bpp;
|
||||
@@ -36,9 +34,9 @@ struct my_bitmap
|
||||
|
||||
struct my_cursor
|
||||
{
|
||||
char* andmask;
|
||||
char *andmask;
|
||||
int andbpp;
|
||||
char* xormask;
|
||||
char *xormask;
|
||||
int xorbpp;
|
||||
int width;
|
||||
int height;
|
||||
@@ -49,13 +47,14 @@ struct my_cursor
|
||||
/*****************************************************************************/
|
||||
/* return error */
|
||||
static int DEFAULT_CC
|
||||
lib_mod_start(struct mod* mod, int w, int h, int bpp)
|
||||
lib_mod_start(struct mod *mod, int w, int h, int bpp)
|
||||
{
|
||||
LIB_DEBUG(mod, "in lib_mod_start");
|
||||
g_writeln("lib_mod_start: w %d h %d bpp %d", w, h, bpp);
|
||||
mod->width = w;
|
||||
mod->height = h;
|
||||
mod->bpp = bpp;
|
||||
|
||||
if (bpp == 24)
|
||||
{
|
||||
mod->settings->server_depth = 32;
|
||||
@@ -64,6 +63,7 @@ lib_mod_start(struct mod* mod, int w, int h, int bpp)
|
||||
{
|
||||
mod->settings->server_depth = mod->bpp;
|
||||
}
|
||||
|
||||
mod->settings->width = mod->width;
|
||||
mod->settings->height = mod->height;
|
||||
LIB_DEBUG(mod, "out lib_mod_start");
|
||||
@@ -73,7 +73,7 @@ lib_mod_start(struct mod* mod, int w, int h, int bpp)
|
||||
/******************************************************************************/
|
||||
/* return error */
|
||||
static int DEFAULT_CC
|
||||
lib_mod_connect(struct mod* mod)
|
||||
lib_mod_connect(struct mod *mod)
|
||||
{
|
||||
int code;
|
||||
|
||||
@@ -87,7 +87,7 @@ lib_mod_connect(struct mod* mod)
|
||||
/******************************************************************************/
|
||||
/* return error */
|
||||
static int DEFAULT_CC
|
||||
lib_mod_event(struct mod* mod, int msg, long param1, long param2,
|
||||
lib_mod_event(struct mod *mod, int msg, long param1, long param2,
|
||||
long param3, long param4)
|
||||
{
|
||||
LIB_DEBUG(mod, "in lib_mod_event");
|
||||
@@ -152,6 +152,7 @@ lib_mod_event(struct mod* mod, int msg, long param1, long param2,
|
||||
case 110:
|
||||
break;
|
||||
}
|
||||
|
||||
LIB_DEBUG(mod, "out lib_mod_event");
|
||||
return 0;
|
||||
}
|
||||
@@ -159,7 +160,7 @@ lib_mod_event(struct mod* mod, int msg, long param1, long param2,
|
||||
/******************************************************************************/
|
||||
/* return error */
|
||||
static int DEFAULT_CC
|
||||
lib_mod_signal(struct mod* mod)
|
||||
lib_mod_signal(struct mod *mod)
|
||||
{
|
||||
LIB_DEBUG(mod, "in lib_mod_signal");
|
||||
g_writeln("lib_mod_signal:");
|
||||
@@ -170,7 +171,7 @@ lib_mod_signal(struct mod* mod)
|
||||
/******************************************************************************/
|
||||
/* return error */
|
||||
static int DEFAULT_CC
|
||||
lib_mod_end(struct mod* mod)
|
||||
lib_mod_end(struct mod *mod)
|
||||
{
|
||||
g_writeln("lib_mod_end:");
|
||||
return 0;
|
||||
@@ -179,9 +180,10 @@ lib_mod_end(struct mod* mod)
|
||||
/******************************************************************************/
|
||||
/* return error */
|
||||
static int DEFAULT_CC
|
||||
lib_mod_set_param(struct mod* mod, char* name, char* value)
|
||||
lib_mod_set_param(struct mod *mod, char *name, char *value)
|
||||
{
|
||||
g_writeln("lib_mod_set_param: name [%s] value [%s]", name, value);
|
||||
|
||||
if (g_strcmp(name, "hostname") == 0)
|
||||
{
|
||||
g_strncpy(mod->settings->hostname, value, sizeof(mod->settings->hostname));
|
||||
@@ -208,12 +210,13 @@ lib_mod_set_param(struct mod* mod, char* name, char* value)
|
||||
{
|
||||
g_writeln("lib_mod_set_param: unknown name [%s] value [%s]", name, value);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
static int DEFAULT_CC
|
||||
mod_session_change(struct mod* v, int a, int b)
|
||||
mod_session_change(struct mod *v, int a, int b)
|
||||
{
|
||||
g_writeln("mod_session_change:");
|
||||
return 0;
|
||||
@@ -221,50 +224,50 @@ mod_session_change(struct mod* v, int a, int b)
|
||||
|
||||
/******************************************************************************/
|
||||
static int DEFAULT_CC
|
||||
mod_get_wait_objs(struct mod* v, tbus* read_objs, int* rcount,
|
||||
tbus* write_objs, int* wcount, int* timeout)
|
||||
mod_get_wait_objs(struct mod *v, tbus *read_objs, int *rcount,
|
||||
tbus *write_objs, int *wcount, int *timeout)
|
||||
{
|
||||
void** rfds;
|
||||
void** wfds;
|
||||
void **rfds;
|
||||
void **wfds;
|
||||
|
||||
rfds = (void**)read_objs;
|
||||
wfds = (void**)write_objs;
|
||||
rfds = (void **)read_objs;
|
||||
wfds = (void **)write_objs;
|
||||
return v->inst->rdp_get_fds(v->inst, rfds, rcount, wfds, wcount);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
static int DEFAULT_CC
|
||||
mod_check_wait_objs(struct mod* v)
|
||||
mod_check_wait_objs(struct mod *v)
|
||||
{
|
||||
return v->inst->rdp_check_fds(v->inst);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
static void DEFAULT_CC
|
||||
ui_error(rdpInst* inst, const char* text)
|
||||
ui_error(rdpInst *inst, const char *text)
|
||||
{
|
||||
g_writeln("ui_error: %s", text);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
static void DEFAULT_CC
|
||||
ui_warning(rdpInst* inst, const char* text)
|
||||
ui_warning(rdpInst *inst, const char *text)
|
||||
{
|
||||
g_writeln("ui_warning: %s", text);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
static void DEFAULT_CC
|
||||
ui_unimpl(rdpInst* inst, const char* text)
|
||||
ui_unimpl(rdpInst *inst, const char *text)
|
||||
{
|
||||
g_writeln("ui_unimpl: %s", text);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
static void DEFAULT_CC
|
||||
ui_begin_update(rdpInst* inst)
|
||||
ui_begin_update(rdpInst *inst)
|
||||
{
|
||||
struct mod* mod;
|
||||
struct mod *mod;
|
||||
|
||||
mod = GET_MOD(inst);
|
||||
mod->server_begin_update(mod);
|
||||
@@ -272,9 +275,9 @@ ui_begin_update(rdpInst* inst)
|
||||
|
||||
/******************************************************************************/
|
||||
static void DEFAULT_CC
|
||||
ui_end_update(rdpInst* inst)
|
||||
ui_end_update(rdpInst *inst)
|
||||
{
|
||||
struct mod* mod;
|
||||
struct mod *mod;
|
||||
|
||||
mod = GET_MOD(inst);
|
||||
mod->server_end_update(mod);
|
||||
@@ -282,7 +285,7 @@ ui_end_update(rdpInst* inst)
|
||||
|
||||
/******************************************************************************/
|
||||
static void DEFAULT_CC
|
||||
ui_desktop_save(rdpInst* inst, int offset, int x, int y,
|
||||
ui_desktop_save(rdpInst *inst, int offset, int x, int y,
|
||||
int cx, int cy)
|
||||
{
|
||||
g_writeln("ui_desktop_save:");
|
||||
@@ -290,7 +293,7 @@ ui_desktop_save(rdpInst* inst, int offset, int x, int y,
|
||||
|
||||
/******************************************************************************/
|
||||
static void DEFAULT_CC
|
||||
ui_desktop_restore(rdpInst* inst, int offset, int x, int y,
|
||||
ui_desktop_restore(rdpInst *inst, int offset, int x, int y,
|
||||
int cx, int cy)
|
||||
{
|
||||
g_writeln("ui_desktop_restore:");
|
||||
@@ -298,51 +301,55 @@ ui_desktop_restore(rdpInst* inst, int offset, int x, int y,
|
||||
|
||||
/******************************************************************************/
|
||||
static RD_HBITMAP DEFAULT_CC
|
||||
ui_create_bitmap(rdpInst* inst, int width, int height, uint8* data)
|
||||
ui_create_bitmap(rdpInst *inst, int width, int height, uint8 *data)
|
||||
{
|
||||
struct my_bitmap* bm;
|
||||
struct mod* mod;
|
||||
struct my_bitmap *bm;
|
||||
struct mod *mod;
|
||||
int size;
|
||||
int bpp;
|
||||
char* bmpdata;
|
||||
char *bmpdata;
|
||||
|
||||
mod = GET_MOD(inst);
|
||||
bpp = mod->bpp == 24 ? 32 : mod->bpp;
|
||||
bm = (struct my_bitmap*)g_malloc(sizeof(struct my_bitmap), 1);
|
||||
bm = (struct my_bitmap *)g_malloc(sizeof(struct my_bitmap), 1);
|
||||
bm->width = width;
|
||||
bm->height = height;
|
||||
bm->bpp = bpp;
|
||||
bmpdata = convert_bitmap(mod->settings->server_depth, bpp,
|
||||
data, width, height, mod->cmap);
|
||||
if (bmpdata == (char*)data)
|
||||
|
||||
if (bmpdata == (char *)data)
|
||||
{
|
||||
size = width * height * ((bpp + 7) / 8);
|
||||
bm->data = (char*)g_malloc(size, 0);
|
||||
bm->data = (char *)g_malloc(size, 0);
|
||||
g_memcpy(bm->data, bmpdata, size);
|
||||
}
|
||||
else
|
||||
{
|
||||
bm->data = bmpdata;
|
||||
}
|
||||
|
||||
return bm;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
static void DEFAULT_CC
|
||||
ui_paint_bitmap(rdpInst* inst, int x, int y, int cx, int cy, int width,
|
||||
int height, uint8* data)
|
||||
ui_paint_bitmap(rdpInst *inst, int x, int y, int cx, int cy, int width,
|
||||
int height, uint8 *data)
|
||||
{
|
||||
struct mod* mod;
|
||||
char* bmpdata;
|
||||
struct mod *mod;
|
||||
char *bmpdata;
|
||||
|
||||
mod = GET_MOD(inst);
|
||||
bmpdata = convert_bitmap(mod->settings->server_depth, mod->bpp,
|
||||
data, width, height, mod->cmap);
|
||||
|
||||
if (bmpdata != 0)
|
||||
{
|
||||
mod->server_paint_rect(mod, x, y, cx, cy, bmpdata, width, height, 0, 0);
|
||||
}
|
||||
if (bmpdata != (char*)data)
|
||||
|
||||
if (bmpdata != (char *)data)
|
||||
{
|
||||
g_free(bmpdata);
|
||||
}
|
||||
@@ -350,28 +357,28 @@ ui_paint_bitmap(rdpInst* inst, int x, int y, int cx, int cy, int width,
|
||||
|
||||
/******************************************************************************/
|
||||
static void DEFAULT_CC
|
||||
ui_destroy_bitmap(rdpInst* inst, RD_HBITMAP bmp)
|
||||
ui_destroy_bitmap(rdpInst *inst, RD_HBITMAP bmp)
|
||||
{
|
||||
struct my_bitmap* bm;
|
||||
struct my_bitmap *bm;
|
||||
|
||||
bm = (struct my_bitmap*)bmp;
|
||||
bm = (struct my_bitmap *)bmp;
|
||||
g_free(bm->data);
|
||||
g_free(bm);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
static void DEFAULT_CC
|
||||
ui_line(rdpInst* inst, uint8 opcode, int startx, int starty, int endx,
|
||||
int endy, RD_PEN* pen)
|
||||
ui_line(rdpInst *inst, uint8 opcode, int startx, int starty, int endx,
|
||||
int endy, RD_PEN *pen)
|
||||
{
|
||||
g_writeln("ui_line:");
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
static void DEFAULT_CC
|
||||
ui_rect(rdpInst* inst, int x, int y, int cx, int cy, uint32 color)
|
||||
ui_rect(rdpInst *inst, int x, int y, int cx, int cy, uint32 color)
|
||||
{
|
||||
struct mod* mod;
|
||||
struct mod *mod;
|
||||
|
||||
mod = GET_MOD(inst);
|
||||
color = convert_color(mod->settings->server_depth, mod->bpp,
|
||||
@@ -382,50 +389,50 @@ ui_rect(rdpInst* inst, int x, int y, int cx, int cy, uint32 color)
|
||||
|
||||
/******************************************************************************/
|
||||
static void DEFAULT_CC
|
||||
ui_polygon(rdpInst* inst, uint8 opcode, uint8 fillmode, RD_POINT* point,
|
||||
int npoints, RD_BRUSH* brush, uint32 bgcolor, uint32 fgcolor)
|
||||
ui_polygon(rdpInst *inst, uint8 opcode, uint8 fillmode, RD_POINT *point,
|
||||
int npoints, RD_BRUSH *brush, uint32 bgcolor, uint32 fgcolor)
|
||||
{
|
||||
g_writeln("ui_polygon:");
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
static void DEFAULT_CC
|
||||
ui_polyline(rdpInst* inst, uint8 opcode, RD_POINT* points, int npoints,
|
||||
RD_PEN* pen)
|
||||
ui_polyline(rdpInst *inst, uint8 opcode, RD_POINT *points, int npoints,
|
||||
RD_PEN *pen)
|
||||
{
|
||||
g_writeln("ui_polyline:");
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
static void DEFAULT_CC
|
||||
ui_ellipse(rdpInst* inst, uint8 opcode, uint8 fillmode, int x, int y,
|
||||
int cx, int cy, RD_BRUSH* brush, uint32 bgcolor, uint32 fgcolor)
|
||||
ui_ellipse(rdpInst *inst, uint8 opcode, uint8 fillmode, int x, int y,
|
||||
int cx, int cy, RD_BRUSH *brush, uint32 bgcolor, uint32 fgcolor)
|
||||
{
|
||||
g_writeln("ui_ellipse:");
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
static void DEFAULT_CC
|
||||
ui_add_char(rdpInst * inst, uint8 font, uint16 character, sint16 offset,
|
||||
sint16 baseline, uint16 width, uint16 height, uint8 * data)
|
||||
ui_add_char(rdpInst *inst, uint8 font, uint16 character, sint16 offset,
|
||||
sint16 baseline, uint16 width, uint16 height, uint8 *data)
|
||||
{
|
||||
struct mod* mod;
|
||||
struct mod *mod;
|
||||
|
||||
//g_writeln("ui_add_char:");
|
||||
mod = GET_MOD(inst);
|
||||
mod->server_add_char(mod, font, character, offset, baseline,
|
||||
width, height, (char*)data);
|
||||
width, height, (char *)data);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
static void DEFAULT_CC
|
||||
ui_draw_text(rdpInst* inst, uint8 font, uint8 flags,
|
||||
ui_draw_text(rdpInst *inst, uint8 font, uint8 flags,
|
||||
uint8 opcode, int mixmode,
|
||||
int x, int y, int clipx, int clipy, int clipcx, int clipcy,
|
||||
int boxx, int boxy, int boxcx, int boxcy, RD_BRUSH * brush,
|
||||
uint32 bgcolor, uint32 fgcolor, uint8 * text, uint8 length)
|
||||
int boxx, int boxy, int boxcx, int boxcy, RD_BRUSH *brush,
|
||||
uint32 bgcolor, uint32 fgcolor, uint8 *text, uint8 length)
|
||||
{
|
||||
struct mod* mod;
|
||||
struct mod *mod;
|
||||
|
||||
//g_writeln("ui_draw_text: flags %d mixmode %d x %d y %d", flags, mixmode, x, y);
|
||||
//g_writeln("%d %d %d %d %d %d %d %d", clipx, clipy, clipcx, clipcy, boxx, boxy, boxcx, boxcy);
|
||||
@@ -439,19 +446,19 @@ ui_draw_text(rdpInst* inst, uint8 font, uint8 flags,
|
||||
mod->server_draw_text(mod, font, flags, mixmode,
|
||||
clipx, clipy, clipx + clipcx, clipy + clipcy,
|
||||
boxx, boxy, boxx + boxcx, boxy + boxcy, x, y,
|
||||
(char*)text, length);
|
||||
(char *)text, length);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
static void DEFAULT_CC
|
||||
ui_start_draw_glyphs(rdpInst* inst, uint32 bgcolor, uint32 fgcolor)
|
||||
ui_start_draw_glyphs(rdpInst *inst, uint32 bgcolor, uint32 fgcolor)
|
||||
{
|
||||
g_writeln("ui_start_draw_glyphs:");
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
static void DEFAULT_CC
|
||||
ui_draw_glyph(rdpInst* inst, int x, int y, int cx, int cy,
|
||||
ui_draw_glyph(rdpInst *inst, int x, int y, int cx, int cy,
|
||||
RD_HGLYPH glyph)
|
||||
{
|
||||
g_writeln("ui_draw_glyph:");
|
||||
@@ -459,14 +466,14 @@ ui_draw_glyph(rdpInst* inst, int x, int y, int cx, int cy,
|
||||
|
||||
/******************************************************************************/
|
||||
static void DEFAULT_CC
|
||||
ui_end_draw_glyphs(rdpInst* inst, int x, int y, int cx, int cy)
|
||||
ui_end_draw_glyphs(rdpInst *inst, int x, int y, int cx, int cy)
|
||||
{
|
||||
g_writeln("ui_end_draw_glyphs:");
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
static uint32 DEFAULT_CC
|
||||
ui_get_toggle_keys_state(rdpInst* inst)
|
||||
ui_get_toggle_keys_state(rdpInst *inst)
|
||||
{
|
||||
g_writeln("ui_get_toggle_keys_state:");
|
||||
return 0;
|
||||
@@ -474,16 +481,16 @@ ui_get_toggle_keys_state(rdpInst* inst)
|
||||
|
||||
/******************************************************************************/
|
||||
static void DEFAULT_CC
|
||||
ui_bell(rdpInst* inst)
|
||||
ui_bell(rdpInst *inst)
|
||||
{
|
||||
g_writeln("ui_bell:");
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
static void DEFAULT_CC
|
||||
ui_destblt(rdpInst* inst, uint8 opcode, int x, int y, int cx, int cy)
|
||||
ui_destblt(rdpInst *inst, uint8 opcode, int x, int y, int cx, int cy)
|
||||
{
|
||||
struct mod* mod;
|
||||
struct mod *mod;
|
||||
|
||||
g_writeln("ui_destblt:");
|
||||
mod = GET_MOD(inst);
|
||||
@@ -494,10 +501,10 @@ ui_destblt(rdpInst* inst, uint8 opcode, int x, int y, int cx, int cy)
|
||||
|
||||
/******************************************************************************/
|
||||
static void DEFAULT_CC
|
||||
ui_patblt(rdpInst* inst, uint8 opcode, int x, int y, int cx, int cy,
|
||||
RD_BRUSH* brush, uint32 bgcolor, uint32 fgcolor)
|
||||
ui_patblt(rdpInst *inst, uint8 opcode, int x, int y, int cx, int cy,
|
||||
RD_BRUSH *brush, uint32 bgcolor, uint32 fgcolor)
|
||||
{
|
||||
struct mod* mod;
|
||||
struct mod *mod;
|
||||
uint8 idata[8];
|
||||
int index;
|
||||
|
||||
@@ -510,6 +517,7 @@ ui_patblt(rdpInst* inst, uint8 opcode, int x, int y, int cx, int cy,
|
||||
bgcolor, mod->cmap);
|
||||
mod->server_set_bgcolor(mod, bgcolor);
|
||||
mod->server_set_mixmode(mod, 1);
|
||||
|
||||
if (brush->bd != 0)
|
||||
{
|
||||
if (brush->bd->color_code == 1) /* 8x8 1 bpp */
|
||||
@@ -518,6 +526,7 @@ ui_patblt(rdpInst* inst, uint8 opcode, int x, int y, int cx, int cy,
|
||||
{
|
||||
idata[index] = ~(brush->bd->data[index]);
|
||||
}
|
||||
|
||||
mod->server_set_brush(mod, brush->xorigin, brush->yorigin,
|
||||
brush->style, idata);
|
||||
}
|
||||
@@ -532,9 +541,11 @@ ui_patblt(rdpInst* inst, uint8 opcode, int x, int y, int cx, int cy,
|
||||
{
|
||||
idata[index] = ~(brush->pattern[index]);
|
||||
}
|
||||
|
||||
mod->server_set_brush(mod, brush->xorigin, brush->yorigin,
|
||||
brush->style, idata);
|
||||
}
|
||||
|
||||
mod->server_fill_rect(mod, x, y, cx, cy);
|
||||
mod->server_set_opcode(mod, 0xcc);
|
||||
mod->server_set_mixmode(mod, 0);
|
||||
@@ -542,10 +553,10 @@ ui_patblt(rdpInst* inst, uint8 opcode, int x, int y, int cx, int cy,
|
||||
|
||||
/******************************************************************************/
|
||||
static void DEFAULT_CC
|
||||
ui_screenblt(rdpInst* inst, uint8 opcode, int x, int y, int cx, int cy,
|
||||
ui_screenblt(rdpInst *inst, uint8 opcode, int x, int y, int cx, int cy,
|
||||
int srcx, int srcy)
|
||||
{
|
||||
struct mod* mod;
|
||||
struct mod *mod;
|
||||
|
||||
mod = GET_MOD(inst);
|
||||
mod->server_set_opcode(mod, opcode);
|
||||
@@ -555,15 +566,15 @@ ui_screenblt(rdpInst* inst, uint8 opcode, int x, int y, int cx, int cy,
|
||||
|
||||
/******************************************************************************/
|
||||
static void DEFAULT_CC
|
||||
ui_memblt(rdpInst* inst, uint8 opcode, int x, int y, int cx, int cy,
|
||||
ui_memblt(rdpInst *inst, uint8 opcode, int x, int y, int cx, int cy,
|
||||
RD_HBITMAP src, int srcx, int srcy)
|
||||
{
|
||||
struct my_bitmap* bitmap;
|
||||
struct mod* mod;
|
||||
char* bmpdata;
|
||||
struct my_bitmap *bitmap;
|
||||
struct mod *mod;
|
||||
char *bmpdata;
|
||||
|
||||
mod = GET_MOD(inst);
|
||||
bitmap = (struct my_bitmap*)src;
|
||||
bitmap = (struct my_bitmap *)src;
|
||||
mod->server_set_opcode(mod, opcode);
|
||||
mod->server_paint_rect(mod, x, y, cx, cy, bitmap->data,
|
||||
bitmap->width, bitmap->height, srcx, srcy);
|
||||
@@ -572,8 +583,8 @@ ui_memblt(rdpInst* inst, uint8 opcode, int x, int y, int cx, int cy,
|
||||
|
||||
/******************************************************************************/
|
||||
static void DEFAULT_CC
|
||||
ui_triblt(rdpInst* inst, uint8 opcode, int x, int y, int cx, int cy,
|
||||
RD_HBITMAP src, int srcx, int srcy, RD_BRUSH* brush,
|
||||
ui_triblt(rdpInst *inst, uint8 opcode, int x, int y, int cx, int cy,
|
||||
RD_HBITMAP src, int srcx, int srcy, RD_BRUSH *brush,
|
||||
uint32 bgcolor, uint32 fgcolor)
|
||||
{
|
||||
g_writeln("ui_triblt:");
|
||||
@@ -581,7 +592,7 @@ ui_triblt(rdpInst* inst, uint8 opcode, int x, int y, int cx, int cy,
|
||||
|
||||
/******************************************************************************/
|
||||
static RD_HGLYPH DEFAULT_CC
|
||||
ui_create_glyph(rdpInst* inst, int width, int height, uint8* data)
|
||||
ui_create_glyph(rdpInst *inst, int width, int height, uint8 *data)
|
||||
{
|
||||
g_writeln("ui_create_glyph:");
|
||||
return 0;
|
||||
@@ -589,23 +600,23 @@ ui_create_glyph(rdpInst* inst, int width, int height, uint8* data)
|
||||
|
||||
/******************************************************************************/
|
||||
static void DEFAULT_CC
|
||||
ui_destroy_glyph(rdpInst* inst, RD_HGLYPH glyph)
|
||||
ui_destroy_glyph(rdpInst *inst, RD_HGLYPH glyph)
|
||||
{
|
||||
g_writeln("ui_destroy_glyph:");
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
static int DEFAULT_CC
|
||||
ui_select(rdpInst* inst, int rdp_socket)
|
||||
ui_select(rdpInst *inst, int rdp_socket)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
static void DEFAULT_CC
|
||||
ui_set_clip(rdpInst* inst, int x, int y, int cx, int cy)
|
||||
ui_set_clip(rdpInst *inst, int x, int y, int cx, int cy)
|
||||
{
|
||||
struct mod* mod;
|
||||
struct mod *mod;
|
||||
|
||||
mod = GET_MOD(inst);
|
||||
mod->server_set_clip(mod, x, y, cx, cy);
|
||||
@@ -613,9 +624,9 @@ ui_set_clip(rdpInst* inst, int x, int y, int cx, int cy)
|
||||
|
||||
/******************************************************************************/
|
||||
static void DEFAULT_CC
|
||||
ui_reset_clip(rdpInst* inst)
|
||||
ui_reset_clip(rdpInst *inst)
|
||||
{
|
||||
struct mod* mod;
|
||||
struct mod *mod;
|
||||
|
||||
mod = GET_MOD(inst);
|
||||
mod->server_reset_clip(mod);
|
||||
@@ -623,21 +634,22 @@ ui_reset_clip(rdpInst* inst)
|
||||
|
||||
/******************************************************************************/
|
||||
static void DEFAULT_CC
|
||||
ui_resize_window(rdpInst* inst)
|
||||
ui_resize_window(rdpInst *inst)
|
||||
{
|
||||
g_writeln("ui_resize_window:");
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
static void DEFAULT_CC
|
||||
ui_set_cursor(rdpInst* inst, RD_HCURSOR cursor)
|
||||
ui_set_cursor(rdpInst *inst, RD_HCURSOR cursor)
|
||||
{
|
||||
struct mod* mod;
|
||||
struct my_cursor* cur;
|
||||
struct mod *mod;
|
||||
struct my_cursor *cur;
|
||||
|
||||
//g_writeln("ui_set_cursor:");
|
||||
mod = GET_MOD(inst);
|
||||
cur = (struct my_cursor*)cursor;
|
||||
cur = (struct my_cursor *)cursor;
|
||||
|
||||
if (cur != 0)
|
||||
{
|
||||
mod->server_set_cursor(mod, cur->hotx, cur->hoty,
|
||||
@@ -651,17 +663,19 @@ ui_set_cursor(rdpInst* inst, RD_HCURSOR cursor)
|
||||
|
||||
/******************************************************************************/
|
||||
static void DEFAULT_CC
|
||||
ui_destroy_cursor(rdpInst* inst, RD_HCURSOR cursor)
|
||||
ui_destroy_cursor(rdpInst *inst, RD_HCURSOR cursor)
|
||||
{
|
||||
struct my_cursor* cur;
|
||||
struct my_cursor *cur;
|
||||
|
||||
//g_writeln("ui_destroy_cursor:");
|
||||
cur = (struct my_cursor*)cursor;
|
||||
cur = (struct my_cursor *)cursor;
|
||||
|
||||
if (cur != 0)
|
||||
{
|
||||
g_free(cur->andmask);
|
||||
g_free(cur->xormask);
|
||||
}
|
||||
|
||||
g_free(cur);
|
||||
}
|
||||
|
||||
@@ -670,12 +684,12 @@ ui_destroy_cursor(rdpInst* inst, RD_HCURSOR cursor)
|
||||
|
||||
/******************************************************************************/
|
||||
static int
|
||||
l_get_pixel(tui8* data, int x, int y, int width, int height, int bpp)
|
||||
l_get_pixel(tui8 *data, int x, int y, int width, int height, int bpp)
|
||||
{
|
||||
int start;
|
||||
int shift;
|
||||
tui16* src16;
|
||||
tui32* src32;
|
||||
tui16 *src16;
|
||||
tui32 *src32;
|
||||
int red, green, blue;
|
||||
|
||||
switch (bpp)
|
||||
@@ -689,7 +703,7 @@ l_get_pixel(tui8* data, int x, int y, int width, int height, int bpp)
|
||||
return data[y * width + x];
|
||||
case 15:
|
||||
case 16:
|
||||
src16 = (uint16*) data;
|
||||
src16 = (uint16 *) data;
|
||||
return src16[y * width + x];
|
||||
case 24:
|
||||
data += y * width * 3;
|
||||
@@ -699,7 +713,7 @@ l_get_pixel(tui8* data, int x, int y, int width, int height, int bpp)
|
||||
blue = data[2];
|
||||
return RGB24(red, green, blue);
|
||||
case 32:
|
||||
src32 = (uint32*) data;
|
||||
src32 = (uint32 *) data;
|
||||
return src32[y * width + x];
|
||||
default:
|
||||
g_writeln("l_get_pixel: unknown bpp %d", bpp);
|
||||
@@ -711,24 +725,29 @@ l_get_pixel(tui8* data, int x, int y, int width, int height, int bpp)
|
||||
|
||||
/******************************************************************************/
|
||||
static void
|
||||
l_set_pixel(tui8* data, int x, int y, int width, int height,
|
||||
l_set_pixel(tui8 *data, int x, int y, int width, int height,
|
||||
int bpp, int pixel)
|
||||
{
|
||||
int start;
|
||||
int shift;
|
||||
int* dst32;
|
||||
tui8* dst8;
|
||||
int *dst32;
|
||||
tui8 *dst8;
|
||||
|
||||
if (bpp == 1)
|
||||
{
|
||||
width = (width + 7) / 8;
|
||||
start = (y * width) + x / 8;
|
||||
shift = x % 8;
|
||||
|
||||
if (pixel)
|
||||
{
|
||||
data[start] = data[start] | (0x80 >> shift);
|
||||
}
|
||||
else
|
||||
{
|
||||
data[start] = data[start] & ~(0x80 >> shift);
|
||||
}
|
||||
}
|
||||
else if (bpp == 24)
|
||||
{
|
||||
dst8 = data + (y * width + x) * 3;
|
||||
@@ -738,7 +757,7 @@ l_set_pixel(tui8* data, int x, int y, int width, int height,
|
||||
}
|
||||
else if (bpp == 32)
|
||||
{
|
||||
dst32 = (int*) data;
|
||||
dst32 = (int *) data;
|
||||
dst32[y * width + x] = pixel;
|
||||
}
|
||||
else
|
||||
@@ -752,32 +771,34 @@ l_set_pixel(tui8* data, int x, int y, int width, int height,
|
||||
/* andmask = mask = 32 * 32 / 8
|
||||
xormask = data = 32 * 32 * 3 */
|
||||
static RD_HCURSOR DEFAULT_CC
|
||||
ui_create_cursor(rdpInst* inst, unsigned int x, unsigned int y,
|
||||
int width, int height, uint8* andmask,
|
||||
uint8* xormask, int bpp)
|
||||
ui_create_cursor(rdpInst *inst, unsigned int x, unsigned int y,
|
||||
int width, int height, uint8 *andmask,
|
||||
uint8 *xormask, int bpp)
|
||||
{
|
||||
struct mod* mod;
|
||||
struct my_cursor* cur;
|
||||
struct mod *mod;
|
||||
struct my_cursor *cur;
|
||||
int i;
|
||||
int j;
|
||||
int jj;
|
||||
int apixel;
|
||||
int xpixel;
|
||||
char* dst;
|
||||
char *dst;
|
||||
|
||||
mod = GET_MOD(inst);
|
||||
g_writeln("ui_create_cursor: x %d y %d width %d height %d bpp %d",
|
||||
x, y, width, height, bpp);
|
||||
cur = (struct my_cursor*)g_malloc(sizeof(struct my_cursor), 1);
|
||||
cur = (struct my_cursor *)g_malloc(sizeof(struct my_cursor), 1);
|
||||
cur->width = width;
|
||||
cur->height = height;
|
||||
cur->hotx = x;
|
||||
cur->hoty = y;
|
||||
cur->andmask = g_malloc(32 * 32 * 4, 1);
|
||||
cur->xormask = g_malloc(32 * 32 * 4, 1);
|
||||
|
||||
for (j = 0; j < height; j++)
|
||||
{
|
||||
jj = (bpp != 1) ? j : (height - 1) - j;
|
||||
|
||||
for (i = 0; i < width; i++)
|
||||
{
|
||||
apixel = l_get_pixel(andmask, i, jj, width, height, 1);
|
||||
@@ -787,44 +808,48 @@ ui_create_cursor(rdpInst* inst, unsigned int x, unsigned int y,
|
||||
l_set_pixel(cur->xormask, i, j, width, height, 24, xpixel);
|
||||
}
|
||||
}
|
||||
|
||||
return (RD_HCURSOR)cur;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
static void DEFAULT_CC
|
||||
ui_set_null_cursor(rdpInst* inst)
|
||||
ui_set_null_cursor(rdpInst *inst)
|
||||
{
|
||||
g_writeln("ui_set_null_cursor:");
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
static void DEFAULT_CC
|
||||
ui_set_default_cursor(rdpInst* inst)
|
||||
ui_set_default_cursor(rdpInst *inst)
|
||||
{
|
||||
g_writeln("ui_set_default_cursor:");
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
static RD_HPALETTE DEFAULT_CC
|
||||
ui_create_palette(rdpInst* inst, RD_PALETTE* colors)
|
||||
ui_create_palette(rdpInst *inst, RD_PALETTE *colors)
|
||||
{
|
||||
struct mod* mod;
|
||||
struct mod *mod;
|
||||
int index;
|
||||
int red;
|
||||
int green;
|
||||
int blue;
|
||||
int pixel;
|
||||
int count;
|
||||
int* cmap;
|
||||
int *cmap;
|
||||
|
||||
mod = GET_MOD(inst);
|
||||
g_writeln("ui_create_palette:");
|
||||
count = 256;
|
||||
|
||||
if (count > colors->count)
|
||||
{
|
||||
count = colors->count;
|
||||
}
|
||||
cmap = (int*)g_malloc(256 * 4, 1);
|
||||
|
||||
cmap = (int *)g_malloc(256 * 4, 1);
|
||||
|
||||
for (index = 0; index < count; index++)
|
||||
{
|
||||
red = colors->entries[index].red;
|
||||
@@ -833,21 +858,22 @@ ui_create_palette(rdpInst* inst, RD_PALETTE* colors)
|
||||
pixel = COLOR24RGB(red, green, blue);
|
||||
cmap[index] = pixel;
|
||||
}
|
||||
|
||||
return (RD_HPALETTE)cmap;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
static void DEFAULT_CC
|
||||
ui_move_pointer(rdpInst* inst, int x, int y)
|
||||
ui_move_pointer(rdpInst *inst, int x, int y)
|
||||
{
|
||||
g_writeln("ui_move_pointer:");
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
static void DEFAULT_CC
|
||||
ui_set_palette(rdpInst* inst, RD_HPALETTE map)
|
||||
ui_set_palette(rdpInst *inst, RD_HPALETTE map)
|
||||
{
|
||||
struct mod* mod;
|
||||
struct mod *mod;
|
||||
|
||||
mod = GET_MOD(inst);
|
||||
g_writeln("ui_set_palette:");
|
||||
@@ -857,7 +883,7 @@ ui_set_palette(rdpInst* inst, RD_HPALETTE map)
|
||||
|
||||
/******************************************************************************/
|
||||
static RD_HBITMAP DEFAULT_CC
|
||||
ui_create_surface(rdpInst* inst, int width, int height, RD_HBITMAP old)
|
||||
ui_create_surface(rdpInst *inst, int width, int height, RD_HBITMAP old)
|
||||
{
|
||||
g_writeln("ui_create_surface:");
|
||||
return 0;
|
||||
@@ -865,21 +891,21 @@ ui_create_surface(rdpInst* inst, int width, int height, RD_HBITMAP old)
|
||||
|
||||
/******************************************************************************/
|
||||
static void DEFAULT_CC
|
||||
ui_set_surface(rdpInst* inst, RD_HBITMAP surface)
|
||||
ui_set_surface(rdpInst *inst, RD_HBITMAP surface)
|
||||
{
|
||||
g_writeln("ui_set_surface:");
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
static void DEFAULT_CC
|
||||
ui_destroy_surface(rdpInst* inst, RD_HBITMAP surface)
|
||||
ui_destroy_surface(rdpInst *inst, RD_HBITMAP surface)
|
||||
{
|
||||
g_writeln("ui_destroy_surface:");
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
static void DEFAULT_CC
|
||||
ui_channel_data(rdpInst* inst, int chan_id, char* data, int data_size,
|
||||
ui_channel_data(rdpInst *inst, int chan_id, char *data, int data_size,
|
||||
int flags, int total_size)
|
||||
{
|
||||
g_writeln("ui_channel_data:");
|
||||
@@ -887,36 +913,36 @@ ui_channel_data(rdpInst* inst, int chan_id, char* data, int data_size,
|
||||
|
||||
/******************************************************************************/
|
||||
static RD_BOOL DEFAULT_CC
|
||||
ui_authenticate(rdpInst * inst)
|
||||
ui_authenticate(rdpInst *inst)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
static int DEFAULT_CC
|
||||
ui_decode(rdpInst * inst, uint8 * data, int data_size)
|
||||
ui_decode(rdpInst *inst, uint8 *data, int data_size)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
static RD_BOOL DEFAULT_CC
|
||||
ui_check_certificate(rdpInst * inst, const char * fingerprint,
|
||||
const char * subject, const char * issuer, RD_BOOL verified)
|
||||
ui_check_certificate(rdpInst *inst, const char *fingerprint,
|
||||
const char *subject, const char *issuer, RD_BOOL verified)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
struct mod* EXPORT_CC
|
||||
struct mod *EXPORT_CC
|
||||
mod_init(void)
|
||||
{
|
||||
struct mod* mod;
|
||||
struct mod *mod;
|
||||
|
||||
//g_writeln("1");
|
||||
//freerdp_global_init();
|
||||
//g_writeln("2");
|
||||
mod = (struct mod*)g_malloc(sizeof(struct mod), 1);
|
||||
mod = (struct mod *)g_malloc(sizeof(struct mod), 1);
|
||||
mod->size = sizeof(struct mod);
|
||||
mod->version = CURRENT_MOD_VER;
|
||||
mod->handle = (tbus)mod;
|
||||
@@ -929,7 +955,7 @@ mod_init(void)
|
||||
mod->mod_session_change = mod_session_change;
|
||||
mod->mod_get_wait_objs = mod_get_wait_objs;
|
||||
mod->mod_check_wait_objs = mod_check_wait_objs;
|
||||
mod->settings = (struct rdp_set*)g_malloc(sizeof(struct rdp_set), 1);
|
||||
mod->settings = (struct rdp_set *)g_malloc(sizeof(struct rdp_set), 1);
|
||||
|
||||
mod->settings->width = 1280;
|
||||
mod->settings->height = 1024;
|
||||
@@ -946,10 +972,12 @@ mod_init(void)
|
||||
mod->settings->text_flags = 1;
|
||||
|
||||
mod->inst = freerdp_new(mod->settings);
|
||||
|
||||
if (mod->inst == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
SET_MOD(mod->inst, mod);
|
||||
mod->inst->ui_error = ui_error;
|
||||
mod->inst->ui_warning = ui_warning;
|
||||
@@ -1006,12 +1034,13 @@ mod_init(void)
|
||||
|
||||
/******************************************************************************/
|
||||
int EXPORT_CC
|
||||
mod_exit(struct mod* mod)
|
||||
mod_exit(struct mod *mod)
|
||||
{
|
||||
if (mod == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
freerdp_free(mod->inst);
|
||||
g_free(mod->settings);
|
||||
g_free(mod);
|
||||
|
||||
+19
-21
@@ -1,24 +1,22 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2010
|
||||
|
||||
freerdp wrapper
|
||||
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* freerdp wrapper
|
||||
*/
|
||||
|
||||
/* include other h files */
|
||||
#include "arch.h"
|
||||
|
||||
+66
-29
@@ -19,13 +19,13 @@
|
||||
|
||||
#include "xrdp-freerdp.h"
|
||||
|
||||
char* APP_CC
|
||||
convert_bitmap(int in_bpp, int out_bpp, char* bmpdata,
|
||||
int width, int height, int* palette)
|
||||
char *APP_CC
|
||||
convert_bitmap(int in_bpp, int out_bpp, char *bmpdata,
|
||||
int width, int height, int *palette)
|
||||
{
|
||||
char* out;
|
||||
char* src;
|
||||
char* dst;
|
||||
char *out;
|
||||
char *src;
|
||||
char *dst;
|
||||
int i;
|
||||
int j;
|
||||
int red;
|
||||
@@ -35,14 +35,15 @@ convert_bitmap(int in_bpp, int out_bpp, char* bmpdata,
|
||||
|
||||
if ((in_bpp == 8) && (out_bpp == 8))
|
||||
{
|
||||
out = (char*)g_malloc(width * height, 0);
|
||||
out = (char *)g_malloc(width * height, 0);
|
||||
src = bmpdata;
|
||||
dst = out;
|
||||
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
for (j = 0; j < width; j++)
|
||||
{
|
||||
pixel = *((tui8*)src);
|
||||
pixel = *((tui8 *)src);
|
||||
pixel = palette[pixel];
|
||||
SPLITCOLOR32(red, green, blue, pixel);
|
||||
pixel = COLOR8(red, green, blue);
|
||||
@@ -51,143 +52,167 @@ convert_bitmap(int in_bpp, int out_bpp, char* bmpdata,
|
||||
dst++;
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
if ((in_bpp == 8) && (out_bpp == 16))
|
||||
{
|
||||
out = (char*)g_malloc(width * height * 2, 0);
|
||||
out = (char *)g_malloc(width * height * 2, 0);
|
||||
src = bmpdata;
|
||||
dst = out;
|
||||
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
for (j = 0; j < width; j++)
|
||||
{
|
||||
pixel = *((tui8*)src);
|
||||
pixel = *((tui8 *)src);
|
||||
pixel = palette[pixel];
|
||||
SPLITCOLOR32(red, green, blue, pixel);
|
||||
pixel = COLOR16(red, green, blue);
|
||||
*((tui16*)dst) = pixel;
|
||||
*((tui16 *)dst) = pixel;
|
||||
src++;
|
||||
dst += 2;
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
if ((in_bpp == 8) && (out_bpp == 24))
|
||||
{
|
||||
out = (char*)g_malloc(width * height * 4, 0);
|
||||
out = (char *)g_malloc(width * height * 4, 0);
|
||||
src = bmpdata;
|
||||
dst = out;
|
||||
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
for (j = 0; j < width; j++)
|
||||
{
|
||||
pixel = *((tui8*)src);
|
||||
pixel = *((tui8 *)src);
|
||||
pixel = palette[pixel];
|
||||
SPLITCOLOR32(red, green, blue, pixel);
|
||||
pixel = COLOR24RGB(red, green, blue);
|
||||
*((tui32*)dst) = pixel;
|
||||
*((tui32 *)dst) = pixel;
|
||||
src++;
|
||||
dst += 4;
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
if ((in_bpp == 15) && (out_bpp == 16))
|
||||
{
|
||||
out = (char*)g_malloc(width * height * 2, 0);
|
||||
out = (char *)g_malloc(width * height * 2, 0);
|
||||
src = bmpdata;
|
||||
dst = out;
|
||||
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
for (j = 0; j < width; j++)
|
||||
{
|
||||
pixel = *((tui16*)src);
|
||||
pixel = *((tui16 *)src);
|
||||
SPLITCOLOR15(red, green, blue, pixel);
|
||||
pixel = COLOR16(red, green, blue);
|
||||
*((tui16*)dst) = pixel;
|
||||
*((tui16 *)dst) = pixel;
|
||||
src += 2;
|
||||
dst += 2;
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
if ((in_bpp == 15) && (out_bpp == 24))
|
||||
{
|
||||
out = (char*)g_malloc(width * height * 4, 0);
|
||||
out = (char *)g_malloc(width * height * 4, 0);
|
||||
src = bmpdata;
|
||||
dst = out;
|
||||
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
for (j = 0; j < width; j++)
|
||||
{
|
||||
pixel = *((tui16*)src);
|
||||
pixel = *((tui16 *)src);
|
||||
SPLITCOLOR15(red, green, blue, pixel);
|
||||
pixel = COLOR24RGB(red, green, blue);
|
||||
*((tui32*)dst) = pixel;
|
||||
*((tui32 *)dst) = pixel;
|
||||
src += 2;
|
||||
dst += 4;
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
if ((in_bpp == 15) && (out_bpp == 15))
|
||||
{
|
||||
return bmpdata;
|
||||
}
|
||||
|
||||
if ((in_bpp == 16) && (out_bpp == 16))
|
||||
{
|
||||
return bmpdata;
|
||||
}
|
||||
|
||||
if ((in_bpp == 16) && (out_bpp == 24))
|
||||
{
|
||||
out = (char*)g_malloc(width * height * 4, 0);
|
||||
out = (char *)g_malloc(width * height * 4, 0);
|
||||
src = bmpdata;
|
||||
dst = out;
|
||||
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
for (j = 0; j < width; j++)
|
||||
{
|
||||
pixel = *((tui16*)src);
|
||||
pixel = *((tui16 *)src);
|
||||
SPLITCOLOR16(red, green, blue, pixel);
|
||||
pixel = COLOR24RGB(red, green, blue);
|
||||
*((tui32*)dst) = pixel;
|
||||
*((tui32 *)dst) = pixel;
|
||||
src += 2;
|
||||
dst += 4;
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
if ((in_bpp == 24) && (out_bpp == 24))
|
||||
{
|
||||
out = (char*)g_malloc(width * height * 4, 0);
|
||||
out = (char *)g_malloc(width * height * 4, 0);
|
||||
src = bmpdata;
|
||||
dst = out;
|
||||
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
for (j = 0; j < width; j++)
|
||||
{
|
||||
blue = *((tui8*)src);
|
||||
blue = *((tui8 *)src);
|
||||
src++;
|
||||
green = *((tui8*)src);
|
||||
green = *((tui8 *)src);
|
||||
src++;
|
||||
red = *((tui8*)src);
|
||||
red = *((tui8 *)src);
|
||||
src++;
|
||||
pixel = COLOR24RGB(red, green, blue);
|
||||
*((tui32*)dst) = pixel;
|
||||
*((tui32 *)dst) = pixel;
|
||||
dst += 4;
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
if ((in_bpp == 32) && (out_bpp == 24))
|
||||
{
|
||||
return bmpdata;
|
||||
}
|
||||
|
||||
if ((in_bpp == 32) && (out_bpp == 32))
|
||||
{
|
||||
return bmpdata;
|
||||
}
|
||||
|
||||
g_writeln("convert_bitmap: error unknown conversion from %d to %d",
|
||||
in_bpp, out_bpp);
|
||||
return 0;
|
||||
@@ -196,7 +221,7 @@ convert_bitmap(int in_bpp, int out_bpp, char* bmpdata,
|
||||
/*****************************************************************************/
|
||||
/* returns color or 0 */
|
||||
int APP_CC
|
||||
convert_color(int in_bpp, int out_bpp, int in_color, int* palette)
|
||||
convert_color(int in_bpp, int out_bpp, int in_color, int *palette)
|
||||
{
|
||||
int pixel;
|
||||
int red;
|
||||
@@ -208,6 +233,7 @@ convert_color(int in_bpp, int out_bpp, int in_color, int* palette)
|
||||
pixel = in_color == 0 ? 0 : 0xffffff;
|
||||
return pixel;
|
||||
}
|
||||
|
||||
if ((in_bpp == 8) && (out_bpp == 8))
|
||||
{
|
||||
pixel = palette[in_color];
|
||||
@@ -215,6 +241,7 @@ convert_color(int in_bpp, int out_bpp, int in_color, int* palette)
|
||||
pixel = COLOR8(red, green, blue);
|
||||
return pixel;
|
||||
}
|
||||
|
||||
if ((in_bpp == 8) && (out_bpp == 16))
|
||||
{
|
||||
pixel = palette[in_color];
|
||||
@@ -222,6 +249,7 @@ convert_color(int in_bpp, int out_bpp, int in_color, int* palette)
|
||||
pixel = COLOR16(red, green, blue);
|
||||
return pixel;
|
||||
}
|
||||
|
||||
if ((in_bpp == 8) && (out_bpp == 24))
|
||||
{
|
||||
pixel = palette[in_color];
|
||||
@@ -229,6 +257,7 @@ convert_color(int in_bpp, int out_bpp, int in_color, int* palette)
|
||||
pixel = COLOR24BGR(red, green, blue);
|
||||
return pixel;
|
||||
}
|
||||
|
||||
if ((in_bpp == 15) && (out_bpp == 16))
|
||||
{
|
||||
pixel = in_color;
|
||||
@@ -236,6 +265,7 @@ convert_color(int in_bpp, int out_bpp, int in_color, int* palette)
|
||||
pixel = COLOR16(red, green, blue);
|
||||
return pixel;
|
||||
}
|
||||
|
||||
if ((in_bpp == 15) && (out_bpp == 24))
|
||||
{
|
||||
pixel = in_color;
|
||||
@@ -243,14 +273,17 @@ convert_color(int in_bpp, int out_bpp, int in_color, int* palette)
|
||||
pixel = COLOR24BGR(red, green, blue);
|
||||
return pixel;
|
||||
}
|
||||
|
||||
if ((in_bpp == 15) && (out_bpp == 15))
|
||||
{
|
||||
return in_color;
|
||||
}
|
||||
|
||||
if ((in_bpp == 16) && (out_bpp == 16))
|
||||
{
|
||||
return in_color;
|
||||
}
|
||||
|
||||
if ((in_bpp == 16) && (out_bpp == 24))
|
||||
{
|
||||
pixel = in_color;
|
||||
@@ -258,18 +291,22 @@ convert_color(int in_bpp, int out_bpp, int in_color, int* palette)
|
||||
pixel = COLOR24BGR(red, green, blue);
|
||||
return pixel;
|
||||
}
|
||||
|
||||
if ((in_bpp == 24) && (out_bpp == 24))
|
||||
{
|
||||
return in_color;
|
||||
}
|
||||
|
||||
if ((in_bpp == 32) && (out_bpp == 24))
|
||||
{
|
||||
return in_color;
|
||||
}
|
||||
|
||||
if ((in_bpp == 32) && (out_bpp == 32))
|
||||
{
|
||||
return in_color;
|
||||
}
|
||||
|
||||
g_writeln("convert_color: error unknown conversion from %d to %d",
|
||||
in_bpp, out_bpp);
|
||||
return 0;
|
||||
|
||||
+260
-184
File diff suppressed because it is too large
Load Diff
+18
-6
@@ -41,56 +41,64 @@
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char* programname;
|
||||
const char *programname;
|
||||
char text[256];
|
||||
char* displayname = NULL;
|
||||
char* outfname;
|
||||
char* sections[5] = {"noshift", "shift", "altgr", "capslock", "shiftcapslock"};
|
||||
char *displayname = NULL;
|
||||
char *outfname;
|
||||
char *sections[5] = {"noshift", "shift", "altgr", "capslock", "shiftcapslock"};
|
||||
int states[5] = {0, 1, 0x80, 2, 3};
|
||||
int i;
|
||||
int idx;
|
||||
int char_count;
|
||||
int nbytes = 0;
|
||||
int unicode;
|
||||
Display* dpy;
|
||||
Display *dpy;
|
||||
KeySym ks;
|
||||
FILE* outf;
|
||||
FILE *outf;
|
||||
XKeyPressedEvent e;
|
||||
wchar_t wtext[256];
|
||||
|
||||
setlocale(LC_CTYPE, "");
|
||||
programname = argv[0];
|
||||
|
||||
if (argc != 2)
|
||||
{
|
||||
fprintf(stderr, "Usage: %s out_filename\n", programname);
|
||||
fprintf(stderr, "Example: %s /etc/xrdp/km-0409.ini\n", programname);
|
||||
return 1;
|
||||
}
|
||||
|
||||
outfname = argv[1];
|
||||
dpy = XOpenDisplay(displayname);
|
||||
|
||||
if (!dpy)
|
||||
{
|
||||
fprintf(stderr, "%s: unable to open display '%s'\n",
|
||||
programname, XDisplayName(displayname));
|
||||
return 1;
|
||||
}
|
||||
|
||||
outf = fopen(outfname, "w");
|
||||
|
||||
if (outf == NULL)
|
||||
{
|
||||
fprintf(stderr, "%s: unable to create file '%s'\n", programname, outfname);
|
||||
XCloseDisplay(dpy);
|
||||
return 1;
|
||||
}
|
||||
|
||||
memset(&e, 0, sizeof(e));
|
||||
e.type = KeyPress;
|
||||
e.serial = 16;
|
||||
e.send_event = True;
|
||||
e.display = dpy;
|
||||
e.same_screen = True;
|
||||
|
||||
for (idx = 0; idx < 5; idx++) /* Sections and states */
|
||||
{
|
||||
fprintf(outf, "[%s]\n", sections[idx]);
|
||||
e.state = states[idx];
|
||||
|
||||
for (i = 8; i <= 137; i++) /* Keycodes */
|
||||
{
|
||||
e.keycode = i;
|
||||
@@ -98,17 +106,21 @@ int main(int argc, char **argv)
|
||||
text[nbytes] = 0;
|
||||
char_count = mbstowcs(wtext, text, 255);
|
||||
unicode = 0;
|
||||
|
||||
if (char_count == 1)
|
||||
{
|
||||
unicode = wtext[0];
|
||||
}
|
||||
|
||||
fprintf(outf, "Key%d=%d:%d\n", i, (int) ks, unicode);
|
||||
}
|
||||
|
||||
if (idx != 4)
|
||||
{
|
||||
fprintf(outf, "\n");
|
||||
}
|
||||
}
|
||||
|
||||
XCloseDisplay(dpy);
|
||||
fclose(outf);
|
||||
return 0;
|
||||
|
||||
+94
-68
@@ -1,24 +1,22 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2007-2010
|
||||
|
||||
rsa key generator for xrdp
|
||||
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* rsa key generator for xrdp
|
||||
*/
|
||||
|
||||
/*
|
||||
references:
|
||||
@@ -104,7 +102,7 @@ static tui8 g_testkey[176] =
|
||||
};
|
||||
|
||||
/* this is the installed signature */
|
||||
char inst_pub_sig[]="0x6a,0x41,0xb1,0x43,0xcf,0x47,0x6f,0xf1,0xe6,0xcc,0xa1,\
|
||||
char inst_pub_sig[] = "0x6a,0x41,0xb1,0x43,0xcf,0x47,0x6f,0xf1,0xe6,0xcc,0xa1,\
|
||||
0x72,0x97,0xd9,0xe1,0x85,0x15,0xb3,0xc2,0x39,0xa0,0xa6,0x26,0x1a,0xb6,\
|
||||
0x49,0x01,0xfa,0xa6,0xda,0x60,0xd7,0x45,0xf7,0x2c,0xee,0xe4,0x8e,0x64,\
|
||||
0x2e,0x37,0x49,0xf0,0x4c,0x94,0x6f,0x08,0xf5,0x63,0x4c,0x56,0x29,0x55,\
|
||||
@@ -126,19 +124,20 @@ out_params(void)
|
||||
/*****************************************************************************/
|
||||
/* this is the special key signing algorithm */
|
||||
static int APP_CC
|
||||
sign_key(char* e_data, int e_len, char* n_data, int n_len,
|
||||
char* sign_data, int sign_len)
|
||||
sign_key(char *e_data, int e_len, char *n_data, int n_len,
|
||||
char *sign_data, int sign_len)
|
||||
{
|
||||
char* key;
|
||||
char* md5_final;
|
||||
void* md5;
|
||||
char *key;
|
||||
char *md5_final;
|
||||
void *md5;
|
||||
|
||||
if ((e_len != 4) || (n_len != 64) || (sign_len != 64))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
key = (char*)g_malloc(176, 0);
|
||||
md5_final = (char*)g_malloc(64, 0);
|
||||
|
||||
key = (char *)g_malloc(176, 0);
|
||||
md5_final = (char *)g_malloc(64, 0);
|
||||
md5 = ssl_md5_info_create();
|
||||
/* copy the test key */
|
||||
g_memcpy(key, g_testkey, 176);
|
||||
@@ -157,8 +156,8 @@ sign_key(char* e_data, int e_len, char* n_data, int n_len,
|
||||
md5_final[62] = 1;
|
||||
md5_final[63] = 0;
|
||||
/* encrypt */
|
||||
ssl_mod_exp(sign_data, 64, md5_final, 64, (char*)g_ppk_n, 64,
|
||||
(char*)g_ppk_d, 64);
|
||||
ssl_mod_exp(sign_data, 64, md5_final, 64, (char *)g_ppk_n, 64,
|
||||
(char *)g_ppk_d, 64);
|
||||
/* cleanup */
|
||||
ssl_md5_info_delete(md5);
|
||||
g_free(key);
|
||||
@@ -168,34 +167,37 @@ sign_key(char* e_data, int e_len, char* n_data, int n_len,
|
||||
|
||||
/*****************************************************************************/
|
||||
static int APP_CC
|
||||
write_out_line(int fd, char* name, char* data, int len)
|
||||
write_out_line(int fd, char *name, char *data, int len)
|
||||
{
|
||||
int max;
|
||||
int error;
|
||||
int index;
|
||||
int data_item;
|
||||
int buf_pos;
|
||||
char* buf;
|
||||
char* text;
|
||||
char *buf;
|
||||
char *text;
|
||||
|
||||
text = (char*)g_malloc(256, 0);
|
||||
text = (char *)g_malloc(256, 0);
|
||||
max = len;
|
||||
max = max * 10;
|
||||
buf_pos = g_strlen(name);
|
||||
max = max + buf_pos + 16;
|
||||
buf = (char*)g_malloc(max, 0);
|
||||
buf = (char *)g_malloc(max, 0);
|
||||
g_strncpy(buf, name, max - 1);
|
||||
buf[buf_pos] = '=';
|
||||
buf_pos++;
|
||||
|
||||
for (index = 0; index < len; index++)
|
||||
{
|
||||
data_item = (tui8)(data[index]);
|
||||
g_snprintf(text, 255, "0x%2.2x", data_item);
|
||||
|
||||
if (index != 0)
|
||||
{
|
||||
buf[buf_pos] = ',';
|
||||
buf_pos++;
|
||||
}
|
||||
|
||||
buf[buf_pos] = text[0];
|
||||
buf_pos++;
|
||||
buf[buf_pos] = text[1];
|
||||
@@ -205,6 +207,7 @@ write_out_line(int fd, char* name, char* data, int len)
|
||||
buf[buf_pos] = text[3];
|
||||
buf_pos++;
|
||||
}
|
||||
|
||||
buf[buf_pos] = '\n';
|
||||
buf_pos++;
|
||||
buf[buf_pos] = 0;
|
||||
@@ -216,9 +219,9 @@ write_out_line(int fd, char* name, char* data, int len)
|
||||
|
||||
/*****************************************************************************/
|
||||
static int APP_CC
|
||||
save_all(char* e_data, int e_len, char* n_data, int n_len,
|
||||
char* d_data, int d_len, char* sign_data, int sign_len,
|
||||
const char* path_and_file_name)
|
||||
save_all(char *e_data, int e_len, char *n_data, int n_len,
|
||||
char *d_data, int d_len, char *sign_data, int sign_len,
|
||||
const char *path_and_file_name)
|
||||
{
|
||||
int fd;
|
||||
char filename[256];
|
||||
@@ -231,8 +234,10 @@ save_all(char* e_data, int e_len, char* n_data, int n_len,
|
||||
{
|
||||
g_strncpy(filename, path_and_file_name, 255);
|
||||
}
|
||||
|
||||
g_writeln("saving to %s", filename);
|
||||
g_writeln("");
|
||||
|
||||
if (g_file_exist(filename))
|
||||
{
|
||||
if (g_file_delete(filename) == 0)
|
||||
@@ -241,7 +246,9 @@ save_all(char* e_data, int e_len, char* n_data, int n_len,
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
fd = g_file_open(filename);
|
||||
|
||||
if (fd > 0)
|
||||
{
|
||||
if (g_file_write(fd, "[keys]\n", 7) == -1)
|
||||
@@ -249,6 +256,7 @@ save_all(char* e_data, int e_len, char* n_data, int n_len,
|
||||
g_writeln("problem writing to %s, maybe no rights", filename);
|
||||
return 1;
|
||||
}
|
||||
|
||||
write_out_line(fd, "pub_exp", e_data, e_len);
|
||||
write_out_line(fd, "pub_mod", n_data, n_len);
|
||||
write_out_line(fd, "pub_sig", sign_data, sign_len);
|
||||
@@ -259,28 +267,29 @@ save_all(char* e_data, int e_len, char* n_data, int n_len,
|
||||
g_writeln("problem opening %s, maybe no rights", filename);
|
||||
return 1;
|
||||
}
|
||||
|
||||
g_file_close(fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
static int APP_CC
|
||||
key_gen(const char* path_and_file_name)
|
||||
key_gen(const char *path_and_file_name)
|
||||
{
|
||||
char* e_data;
|
||||
char* n_data;
|
||||
char* d_data;
|
||||
char* sign_data;
|
||||
char *e_data;
|
||||
char *n_data;
|
||||
char *d_data;
|
||||
char *sign_data;
|
||||
int e_len;
|
||||
int n_len;
|
||||
int d_len;
|
||||
int sign_len;
|
||||
int error;
|
||||
|
||||
e_data = (char*)g_exponent;
|
||||
n_data = (char*)g_malloc(64, 0);
|
||||
d_data = (char*)g_malloc(64, 0);
|
||||
sign_data = (char*)g_malloc(64, 0);
|
||||
e_data = (char *)g_exponent;
|
||||
n_data = (char *)g_malloc(64, 0);
|
||||
d_data = (char *)g_malloc(64, 0);
|
||||
sign_data = (char *)g_malloc(64, 0);
|
||||
e_len = 4;
|
||||
n_len = 64;
|
||||
d_len = 64;
|
||||
@@ -289,34 +298,41 @@ key_gen(const char* path_and_file_name)
|
||||
g_writeln("");
|
||||
g_writeln("Generating %d bit rsa key...", MY_KEY_SIZE);
|
||||
g_writeln("");
|
||||
|
||||
if (error == 0)
|
||||
{
|
||||
error = ssl_gen_key_xrdp1(MY_KEY_SIZE, e_data, e_len, n_data, n_len,
|
||||
d_data, d_len);
|
||||
|
||||
if (error != 0)
|
||||
{
|
||||
g_writeln("error %d in key_gen, ssl_gen_key_xrdp1", error);
|
||||
}
|
||||
}
|
||||
|
||||
if (error == 0)
|
||||
{
|
||||
g_writeln("ssl_gen_key_xrdp1 ok");
|
||||
g_writeln("");
|
||||
error = sign_key(e_data, e_len, n_data, n_len, sign_data, sign_len);
|
||||
|
||||
if (error != 0)
|
||||
{
|
||||
g_writeln("error %d in key_gen, sign_key", error);
|
||||
}
|
||||
}
|
||||
|
||||
if (error == 0)
|
||||
{
|
||||
error = save_all(e_data, e_len, n_data, n_len, d_data, d_len,
|
||||
sign_data, sign_len, path_and_file_name);
|
||||
|
||||
if (error != 0)
|
||||
{
|
||||
g_writeln("error %d in key_gen, save_all", error);
|
||||
}
|
||||
}
|
||||
|
||||
g_free(n_data);
|
||||
g_free(d_data);
|
||||
g_free(sign_data);
|
||||
@@ -331,35 +347,41 @@ key_gen_run_it(void)
|
||||
int fd;
|
||||
int index;
|
||||
int rv;
|
||||
struct list* names;
|
||||
struct list* values;
|
||||
char* name;
|
||||
char* value;
|
||||
struct list *names;
|
||||
struct list *values;
|
||||
char *name;
|
||||
char *value;
|
||||
|
||||
if (!g_file_exist("/etc/xrdp/rsakeys.ini"))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (g_file_get_size("/etc/xrdp/rsakeys.ini") < 10)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
fd = g_file_open("/etc/xrdp/rsakeys.ini");
|
||||
|
||||
if (fd < 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
rv = 0;
|
||||
names = list_create();
|
||||
names->auto_free = 1;
|
||||
values = list_create();
|
||||
values->auto_free = 1;
|
||||
|
||||
if (file_read_section(fd, "keys", names, values) == 0)
|
||||
{
|
||||
for (index = 0; index < names->count; index++)
|
||||
{
|
||||
name = (char*)list_get_item(names, index);
|
||||
value = (char*)list_get_item(values, index);
|
||||
name = (char *)list_get_item(names, index);
|
||||
value = (char *)list_get_item(values, index);
|
||||
|
||||
if (g_strcasecmp(name, "pub_sig") == 0)
|
||||
{
|
||||
if (g_strcasecmp(value, inst_pub_sig) == 0)
|
||||
@@ -373,6 +395,7 @@ key_gen_run_it(void)
|
||||
{
|
||||
g_writeln("error reading keys section of rsakeys.ini");
|
||||
}
|
||||
|
||||
list_delete(names);
|
||||
list_delete(values);
|
||||
g_file_close(fd);
|
||||
@@ -387,6 +410,7 @@ key_gen_auto(void)
|
||||
{
|
||||
return key_gen("/etc/xrdp/rsakeys.ini");
|
||||
}
|
||||
|
||||
g_writeln("xrdp-keygen does not need to run");
|
||||
return 0;
|
||||
}
|
||||
@@ -395,23 +419,23 @@ key_gen_auto(void)
|
||||
static int APP_CC
|
||||
key_test(void)
|
||||
{
|
||||
char* md5_final;
|
||||
char* sig;
|
||||
void* md5;
|
||||
char *md5_final;
|
||||
char *sig;
|
||||
void *md5;
|
||||
|
||||
md5_final = (char*)g_malloc(64, 0);
|
||||
sig = (char*)g_malloc(64, 0);
|
||||
md5_final = (char *)g_malloc(64, 0);
|
||||
sig = (char *)g_malloc(64, 0);
|
||||
md5 = ssl_md5_info_create();
|
||||
g_writeln("original key is:");
|
||||
g_hexdump((char*)g_testkey, 176);
|
||||
g_hexdump((char *)g_testkey, 176);
|
||||
g_writeln("original exponent is:");
|
||||
g_hexdump((char*)g_testkey + 32, 4);
|
||||
g_hexdump((char *)g_testkey + 32, 4);
|
||||
g_writeln("original modulus is:");
|
||||
g_hexdump((char*)g_testkey + 36, 64);
|
||||
g_hexdump((char *)g_testkey + 36, 64);
|
||||
g_writeln("original signature is:");
|
||||
g_hexdump((char*)g_testkey + 112, 64);
|
||||
g_hexdump((char *)g_testkey + 112, 64);
|
||||
ssl_md5_clear(md5);
|
||||
ssl_md5_transform(md5, (char*)g_testkey, 108);
|
||||
ssl_md5_transform(md5, (char *)g_testkey, 108);
|
||||
g_memset(md5_final, 0xff, 64);
|
||||
ssl_md5_complete(md5, md5_final);
|
||||
g_writeln("md5 hash of first 108 bytes of this key is:");
|
||||
@@ -419,13 +443,13 @@ key_test(void)
|
||||
md5_final[16] = 0;
|
||||
md5_final[62] = 1;
|
||||
md5_final[63] = 0;
|
||||
ssl_mod_exp(sig, 64, md5_final, 64, (char*)g_ppk_n, 64, (char*)g_ppk_d, 64);
|
||||
ssl_mod_exp(sig, 64, md5_final, 64, (char *)g_ppk_n, 64, (char *)g_ppk_d, 64);
|
||||
g_writeln("produced signature(this should match original \
|
||||
signature above) is:");
|
||||
g_hexdump(sig, 64);
|
||||
g_memset(md5_final, 0, 64);
|
||||
ssl_mod_exp(md5_final, 64, (char*)g_testkey + 112, 64, (char*)g_ppk_n, 64,
|
||||
(char*)g_ppk_e, 4);
|
||||
ssl_mod_exp(md5_final, 64, (char *)g_testkey + 112, 64, (char *)g_ppk_n, 64,
|
||||
(char *)g_ppk_e, 4);
|
||||
g_writeln("decrypted hash of first 108 bytes of this key is:");
|
||||
g_hexdump(md5_final, 64);
|
||||
ssl_md5_info_delete(md5);
|
||||
@@ -436,7 +460,7 @@ signature above) is:");
|
||||
|
||||
/*****************************************************************************/
|
||||
int DEFAULT_CC
|
||||
main(int argc, char** argv)
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
if (argc > 1)
|
||||
{
|
||||
@@ -451,6 +475,7 @@ main(int argc, char** argv)
|
||||
g_writeln("must run as root");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return key_gen_auto();
|
||||
}
|
||||
else
|
||||
@@ -468,6 +493,7 @@ main(int argc, char** argv)
|
||||
return key_test();
|
||||
}
|
||||
}
|
||||
|
||||
out_params();
|
||||
return 0;
|
||||
}
|
||||
|
||||
+242
-177
File diff suppressed because it is too large
Load Diff
+19
-21
@@ -1,24 +1,22 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2004-2010
|
||||
|
||||
libxrdp header
|
||||
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2010
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* libxrdp header
|
||||
*/
|
||||
|
||||
#if !defined(LIBXRDP_H)
|
||||
#define LIBXRDP_H
|
||||
|
||||
+19
-21
@@ -1,24 +1,22 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2004-2010
|
||||
|
||||
header file for use with libxrdp.so / xrdp.dll
|
||||
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2010
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* header file for use with libxrdp.so / xrdp.dll
|
||||
*/
|
||||
|
||||
#ifndef LIBXRDPINC_H
|
||||
#define LIBXRDPINC_H
|
||||
|
||||
+170
-74
@@ -1,30 +1,28 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2004-2010
|
||||
|
||||
bitmap compressor
|
||||
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* bitmap compressor
|
||||
*/
|
||||
|
||||
#include "libxrdp.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
#define IN_PIXEL8(in_ptr, in_x, in_y, in_w, in_last_pixel, in_pixel); \
|
||||
{ \
|
||||
{ \
|
||||
if (in_ptr == 0) \
|
||||
{ \
|
||||
in_pixel = 0; \
|
||||
@@ -37,11 +35,11 @@
|
||||
{ \
|
||||
in_pixel = in_last_pixel; \
|
||||
} \
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
#define IN_PIXEL16(in_ptr, in_x, in_y, in_w, in_last_pixel, in_pixel); \
|
||||
{ \
|
||||
{ \
|
||||
if (in_ptr == 0) \
|
||||
{ \
|
||||
in_pixel = 0; \
|
||||
@@ -54,11 +52,11 @@
|
||||
{ \
|
||||
in_pixel = in_last_pixel; \
|
||||
} \
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
#define IN_PIXEL32(in_ptr, in_x, in_y, in_w, in_last_pixel, in_pixel); \
|
||||
{ \
|
||||
{ \
|
||||
if (in_ptr == 0) \
|
||||
{ \
|
||||
in_pixel = 0; \
|
||||
@@ -71,12 +69,12 @@
|
||||
{ \
|
||||
in_pixel = in_last_pixel; \
|
||||
} \
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* color */
|
||||
#define OUT_COLOR_COUNT1(in_count, in_s, in_data) \
|
||||
{ \
|
||||
{ \
|
||||
if (in_count > 0) \
|
||||
{ \
|
||||
if (in_count < 32) \
|
||||
@@ -100,12 +98,12 @@
|
||||
} \
|
||||
} \
|
||||
in_count = 0; \
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* color */
|
||||
#define OUT_COLOR_COUNT2(in_count, in_s, in_data) \
|
||||
{ \
|
||||
{ \
|
||||
if (in_count > 0) \
|
||||
{ \
|
||||
if (in_count < 32) \
|
||||
@@ -129,12 +127,12 @@
|
||||
} \
|
||||
} \
|
||||
in_count = 0; \
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* color */
|
||||
#define OUT_COLOR_COUNT3(in_count, in_s, in_data) \
|
||||
{ \
|
||||
{ \
|
||||
if (in_count > 0) \
|
||||
{ \
|
||||
if (in_count < 32) \
|
||||
@@ -164,12 +162,12 @@
|
||||
} \
|
||||
} \
|
||||
in_count = 0; \
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* copy */
|
||||
#define OUT_COPY_COUNT1(in_count, in_s, in_data) \
|
||||
{ \
|
||||
{ \
|
||||
if (in_count > 0) \
|
||||
{ \
|
||||
if (in_count < 32) \
|
||||
@@ -194,12 +192,12 @@
|
||||
} \
|
||||
in_count = 0; \
|
||||
init_stream(in_data, 0); \
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* copy */
|
||||
#define OUT_COPY_COUNT2(in_count, in_s, in_data) \
|
||||
{ \
|
||||
{ \
|
||||
if (in_count > 0) \
|
||||
{ \
|
||||
if (in_count < 32) \
|
||||
@@ -227,12 +225,12 @@
|
||||
} \
|
||||
in_count = 0; \
|
||||
init_stream(in_data, 0); \
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* copy */
|
||||
#define OUT_COPY_COUNT3(in_count, in_s, in_data) \
|
||||
{ \
|
||||
{ \
|
||||
if (in_count > 0) \
|
||||
{ \
|
||||
if (in_count < 32) \
|
||||
@@ -260,12 +258,12 @@
|
||||
} \
|
||||
in_count = 0; \
|
||||
init_stream(in_data, 0); \
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* bicolor */
|
||||
#define OUT_BICOLOR_COUNT1(in_count, in_s, in_color1, in_color2) \
|
||||
{ \
|
||||
{ \
|
||||
if (in_count > 0) \
|
||||
{ \
|
||||
if (in_count / 2 < 16) \
|
||||
@@ -293,12 +291,12 @@
|
||||
} \
|
||||
} \
|
||||
in_count = 0; \
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* bicolor */
|
||||
#define OUT_BICOLOR_COUNT2(in_count, in_s, in_color1, in_color2) \
|
||||
{ \
|
||||
{ \
|
||||
if (in_count > 0) \
|
||||
{ \
|
||||
if (in_count / 2 < 16) \
|
||||
@@ -326,12 +324,12 @@
|
||||
} \
|
||||
} \
|
||||
in_count = 0; \
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* bicolor */
|
||||
#define OUT_BICOLOR_COUNT3(in_count, in_s, in_color1, in_color2) \
|
||||
{ \
|
||||
{ \
|
||||
if (in_count > 0) \
|
||||
{ \
|
||||
if (in_count / 2 < 16) \
|
||||
@@ -371,12 +369,12 @@
|
||||
} \
|
||||
} \
|
||||
in_count = 0; \
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* fill */
|
||||
#define OUT_FILL_COUNT1(in_count, in_s) \
|
||||
{ \
|
||||
{ \
|
||||
if (in_count > 0) \
|
||||
{ \
|
||||
if (in_count < 32) \
|
||||
@@ -396,12 +394,12 @@
|
||||
} \
|
||||
} \
|
||||
in_count = 0; \
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* fill */
|
||||
#define OUT_FILL_COUNT2(in_count, in_s) \
|
||||
{ \
|
||||
{ \
|
||||
if (in_count > 0) \
|
||||
{ \
|
||||
if (in_count < 32) \
|
||||
@@ -421,12 +419,12 @@
|
||||
} \
|
||||
} \
|
||||
in_count = 0; \
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* fill */
|
||||
#define OUT_FILL_COUNT3(in_count, in_s) \
|
||||
{ \
|
||||
{ \
|
||||
if (in_count > 0) \
|
||||
{ \
|
||||
if (in_count < 32) \
|
||||
@@ -446,12 +444,12 @@
|
||||
} \
|
||||
} \
|
||||
in_count = 0; \
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* mix */
|
||||
#define OUT_MIX_COUNT1(in_count, in_s) \
|
||||
{ \
|
||||
{ \
|
||||
if (in_count > 0) \
|
||||
{ \
|
||||
if (in_count < 32) \
|
||||
@@ -472,12 +470,12 @@
|
||||
} \
|
||||
} \
|
||||
in_count = 0; \
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* mix */
|
||||
#define OUT_MIX_COUNT2(in_count, in_s) \
|
||||
{ \
|
||||
{ \
|
||||
if (in_count > 0) \
|
||||
{ \
|
||||
if (in_count < 32) \
|
||||
@@ -498,12 +496,12 @@
|
||||
} \
|
||||
} \
|
||||
in_count = 0; \
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* mix */
|
||||
#define OUT_MIX_COUNT3(in_count, in_s) \
|
||||
{ \
|
||||
{ \
|
||||
if (in_count > 0) \
|
||||
{ \
|
||||
if (in_count < 32) \
|
||||
@@ -524,12 +522,12 @@
|
||||
} \
|
||||
} \
|
||||
in_count = 0; \
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* fom */
|
||||
#define OUT_FOM_COUNT1(in_count, in_s, in_mask, in_mask_len) \
|
||||
{ \
|
||||
{ \
|
||||
if (in_count > 0) \
|
||||
{ \
|
||||
if ((in_count % 8) == 0 && in_count < 249) \
|
||||
@@ -553,12 +551,12 @@
|
||||
} \
|
||||
} \
|
||||
in_count = 0; \
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* fom */
|
||||
#define OUT_FOM_COUNT2(in_count, in_s, in_mask, in_mask_len) \
|
||||
{ \
|
||||
{ \
|
||||
if (in_count > 0) \
|
||||
{ \
|
||||
if ((in_count % 8) == 0 && in_count < 249) \
|
||||
@@ -582,12 +580,12 @@
|
||||
} \
|
||||
} \
|
||||
in_count = 0; \
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* fill or mix (fom) */
|
||||
#define OUT_FOM_COUNT3(in_count, in_s, in_mask, in_mask_len) \
|
||||
{ \
|
||||
{ \
|
||||
if (in_count > 0) \
|
||||
{ \
|
||||
if ((in_count % 8) == 0 && in_count < 249) \
|
||||
@@ -611,27 +609,27 @@
|
||||
} \
|
||||
} \
|
||||
in_count = 0; \
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
#define TEST_FILL \
|
||||
((last_line == 0 && pixel == 0) || \
|
||||
((last_line == 0 && pixel == 0) || \
|
||||
(last_line != 0 && pixel == ypixel))
|
||||
#define TEST_MIX \
|
||||
((last_line == 0 && pixel == mix) || \
|
||||
((last_line == 0 && pixel == mix) || \
|
||||
(last_line != 0 && pixel == (ypixel ^ mix)))
|
||||
#define TEST_FOM (TEST_FILL || TEST_MIX)
|
||||
#define TEST_COLOR (pixel == last_pixel)
|
||||
#define TEST_BICOLOR \
|
||||
( \
|
||||
( \
|
||||
(pixel != last_pixel) && \
|
||||
( \
|
||||
(!bicolor_spin && pixel == bicolor1 && last_pixel == bicolor2) || \
|
||||
(bicolor_spin && pixel == bicolor2 && last_pixel == bicolor1) \
|
||||
) \
|
||||
)
|
||||
)
|
||||
#define RESET_COUNTS \
|
||||
{ \
|
||||
{ \
|
||||
bicolor_count = 0; \
|
||||
fill_count = 0; \
|
||||
color_count = 0; \
|
||||
@@ -639,17 +637,17 @@
|
||||
fom_count = 0; \
|
||||
fom_mask_len = 0; \
|
||||
bicolor_spin = 0; \
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
int APP_CC
|
||||
xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
struct stream* s, int bpp, int byte_limit,
|
||||
int start_line, struct stream* temp_s,
|
||||
xrdp_bitmap_compress(char *in_data, int width, int height,
|
||||
struct stream *s, int bpp, int byte_limit,
|
||||
int start_line, struct stream *temp_s,
|
||||
int e)
|
||||
{
|
||||
char* line;
|
||||
char* last_line;
|
||||
char *line;
|
||||
char *last_line;
|
||||
char fom_mask[8192]; /* good for up to 64K bitmap */
|
||||
int lines_sent;
|
||||
int pixel;
|
||||
@@ -688,14 +686,17 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
fill_count = 0;
|
||||
mix_count = 0;
|
||||
fom_count = 0;
|
||||
|
||||
if (bpp == 8)
|
||||
{
|
||||
mix = 0xff;
|
||||
out_count = end;
|
||||
line = in_data + width * start_line;
|
||||
|
||||
while (start_line >= 0 && out_count < 32768)
|
||||
{
|
||||
i = (s->p - s->data) + count;
|
||||
|
||||
if (i - color_count >= byte_limit &&
|
||||
i - bicolor_count >= byte_limit &&
|
||||
i - fill_count >= byte_limit &&
|
||||
@@ -704,12 +705,15 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
out_count += end;
|
||||
|
||||
for (i = 0; i < end; i++)
|
||||
{
|
||||
/* read next pixel */
|
||||
IN_PIXEL8(line, i, 0, width, last_pixel, pixel);
|
||||
IN_PIXEL8(last_line, i, 0, width, last_ypixel, ypixel);
|
||||
|
||||
if (!TEST_FILL)
|
||||
{
|
||||
if (fill_count > 3 &&
|
||||
@@ -723,8 +727,10 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
OUT_FILL_COUNT1(fill_count, s);
|
||||
RESET_COUNTS;
|
||||
}
|
||||
|
||||
fill_count = 0;
|
||||
}
|
||||
|
||||
if (!TEST_MIX)
|
||||
{
|
||||
if (mix_count > 3 &&
|
||||
@@ -738,8 +744,10 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
OUT_MIX_COUNT1(mix_count, s);
|
||||
RESET_COUNTS;
|
||||
}
|
||||
|
||||
mix_count = 0;
|
||||
}
|
||||
|
||||
if (!TEST_COLOR)
|
||||
{
|
||||
if (color_count > 3 &&
|
||||
@@ -753,8 +761,10 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
OUT_COLOR_COUNT1(color_count, s, last_pixel);
|
||||
RESET_COUNTS;
|
||||
}
|
||||
|
||||
color_count = 0;
|
||||
}
|
||||
|
||||
if (!TEST_BICOLOR)
|
||||
{
|
||||
if (bicolor_count > 3 &&
|
||||
@@ -776,13 +786,16 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
OUT_COPY_COUNT1(count, s, temp_s);
|
||||
OUT_BICOLOR_COUNT1(bicolor_count, s, bicolor2, bicolor1);
|
||||
}
|
||||
|
||||
RESET_COUNTS;
|
||||
}
|
||||
|
||||
bicolor_count = 0;
|
||||
bicolor1 = last_pixel;
|
||||
bicolor2 = pixel;
|
||||
bicolor_spin = 0;
|
||||
}
|
||||
|
||||
if (!TEST_FOM)
|
||||
{
|
||||
if (fom_count > 3 &&
|
||||
@@ -796,26 +809,32 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
OUT_FOM_COUNT1(fom_count, s, fom_mask, fom_mask_len);
|
||||
RESET_COUNTS;
|
||||
}
|
||||
|
||||
fom_count = 0;
|
||||
fom_mask_len = 0;
|
||||
}
|
||||
|
||||
if (TEST_FILL)
|
||||
{
|
||||
fill_count++;
|
||||
}
|
||||
|
||||
if (TEST_MIX)
|
||||
{
|
||||
mix_count++;
|
||||
}
|
||||
|
||||
if (TEST_COLOR)
|
||||
{
|
||||
color_count++;
|
||||
}
|
||||
|
||||
if (TEST_BICOLOR)
|
||||
{
|
||||
bicolor_spin = !bicolor_spin;
|
||||
bicolor_count++;
|
||||
}
|
||||
|
||||
if (TEST_FOM)
|
||||
{
|
||||
if ((fom_count % 8) == 0)
|
||||
@@ -823,17 +842,21 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
fom_mask[fom_mask_len] = 0;
|
||||
fom_mask_len++;
|
||||
}
|
||||
|
||||
if (pixel == (ypixel ^ mix))
|
||||
{
|
||||
fom_mask[fom_mask_len - 1] |= (1 << (fom_count % 8));
|
||||
}
|
||||
|
||||
fom_count++;
|
||||
}
|
||||
|
||||
out_uint8(temp_s, pixel);
|
||||
count++;
|
||||
last_pixel = pixel;
|
||||
last_ypixel = ypixel;
|
||||
}
|
||||
|
||||
/* can't take fix, mix, or fom past first line */
|
||||
if (last_line == 0)
|
||||
{
|
||||
@@ -848,7 +871,9 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
OUT_FILL_COUNT1(fill_count, s);
|
||||
RESET_COUNTS;
|
||||
}
|
||||
|
||||
fill_count = 0;
|
||||
|
||||
if (mix_count > 3 &&
|
||||
mix_count >= fill_count &&
|
||||
mix_count >= bicolor_count &&
|
||||
@@ -860,7 +885,9 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
OUT_MIX_COUNT1(mix_count, s);
|
||||
RESET_COUNTS;
|
||||
}
|
||||
|
||||
mix_count = 0;
|
||||
|
||||
if (fom_count > 3 &&
|
||||
fom_count >= fill_count &&
|
||||
fom_count >= color_count &&
|
||||
@@ -872,14 +899,17 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
OUT_FOM_COUNT1(fom_count, s, fom_mask, fom_mask_len);
|
||||
RESET_COUNTS;
|
||||
}
|
||||
|
||||
fom_count = 0;
|
||||
fom_mask_len = 0;
|
||||
}
|
||||
|
||||
last_line = line;
|
||||
line = line - width;
|
||||
start_line--;
|
||||
lines_sent++;
|
||||
}
|
||||
|
||||
if (fill_count > 3 &&
|
||||
fill_count >= color_count &&
|
||||
fill_count >= bicolor_count &&
|
||||
@@ -929,6 +959,7 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
OUT_COPY_COUNT1(count, s, temp_s);
|
||||
OUT_BICOLOR_COUNT1(bicolor_count, s, bicolor2, bicolor1);
|
||||
}
|
||||
|
||||
count -= bicolor_count;
|
||||
OUT_COPY_COUNT1(count, s, temp_s);
|
||||
OUT_BICOLOR_COUNT1(bicolor_count, s, bicolor1, bicolor2);
|
||||
@@ -953,9 +984,11 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
mix = (bpp == 15) ? 0xba1f : 0xffff;
|
||||
out_count = end * 2;
|
||||
line = in_data + width * start_line * 2;
|
||||
|
||||
while (start_line >= 0 && out_count < 32768)
|
||||
{
|
||||
i = (s->p - s->data) + count * 2;
|
||||
|
||||
if (i - (color_count * 2) >= byte_limit &&
|
||||
i - (bicolor_count * 2) >= byte_limit &&
|
||||
i - (fill_count * 2) >= byte_limit &&
|
||||
@@ -964,12 +997,15 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
out_count += end * 2;
|
||||
|
||||
for (i = 0; i < end; i++)
|
||||
{
|
||||
/* read next pixel */
|
||||
IN_PIXEL16(line, i, 0, width, last_pixel, pixel);
|
||||
IN_PIXEL16(last_line, i, 0, width, last_ypixel, ypixel);
|
||||
|
||||
if (!TEST_FILL)
|
||||
{
|
||||
if (fill_count > 3 &&
|
||||
@@ -983,8 +1019,10 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
OUT_FILL_COUNT2(fill_count, s);
|
||||
RESET_COUNTS;
|
||||
}
|
||||
|
||||
fill_count = 0;
|
||||
}
|
||||
|
||||
if (!TEST_MIX)
|
||||
{
|
||||
if (mix_count > 3 &&
|
||||
@@ -998,8 +1036,10 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
OUT_MIX_COUNT2(mix_count, s);
|
||||
RESET_COUNTS;
|
||||
}
|
||||
|
||||
mix_count = 0;
|
||||
}
|
||||
|
||||
if (!TEST_COLOR)
|
||||
{
|
||||
if (color_count > 3 &&
|
||||
@@ -1013,8 +1053,10 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
OUT_COLOR_COUNT2(color_count, s, last_pixel);
|
||||
RESET_COUNTS;
|
||||
}
|
||||
|
||||
color_count = 0;
|
||||
}
|
||||
|
||||
if (!TEST_BICOLOR)
|
||||
{
|
||||
if (bicolor_count > 3 &&
|
||||
@@ -1036,13 +1078,16 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
OUT_COPY_COUNT2(count, s, temp_s);
|
||||
OUT_BICOLOR_COUNT2(bicolor_count, s, bicolor2, bicolor1);
|
||||
}
|
||||
|
||||
RESET_COUNTS;
|
||||
}
|
||||
|
||||
bicolor_count = 0;
|
||||
bicolor1 = last_pixel;
|
||||
bicolor2 = pixel;
|
||||
bicolor_spin = 0;
|
||||
}
|
||||
|
||||
if (!TEST_FOM)
|
||||
{
|
||||
if (fom_count > 3 &&
|
||||
@@ -1056,26 +1101,32 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
OUT_FOM_COUNT2(fom_count, s, fom_mask, fom_mask_len);
|
||||
RESET_COUNTS;
|
||||
}
|
||||
|
||||
fom_count = 0;
|
||||
fom_mask_len = 0;
|
||||
}
|
||||
|
||||
if (TEST_FILL)
|
||||
{
|
||||
fill_count++;
|
||||
}
|
||||
|
||||
if (TEST_MIX)
|
||||
{
|
||||
mix_count++;
|
||||
}
|
||||
|
||||
if (TEST_COLOR)
|
||||
{
|
||||
color_count++;
|
||||
}
|
||||
|
||||
if (TEST_BICOLOR)
|
||||
{
|
||||
bicolor_spin = !bicolor_spin;
|
||||
bicolor_count++;
|
||||
}
|
||||
|
||||
if (TEST_FOM)
|
||||
{
|
||||
if ((fom_count % 8) == 0)
|
||||
@@ -1083,17 +1134,21 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
fom_mask[fom_mask_len] = 0;
|
||||
fom_mask_len++;
|
||||
}
|
||||
|
||||
if (pixel == (ypixel ^ mix))
|
||||
{
|
||||
fom_mask[fom_mask_len - 1] |= (1 << (fom_count % 8));
|
||||
}
|
||||
|
||||
fom_count++;
|
||||
}
|
||||
|
||||
out_uint16_le(temp_s, pixel);
|
||||
count++;
|
||||
last_pixel = pixel;
|
||||
last_ypixel = ypixel;
|
||||
}
|
||||
|
||||
/* can't take fix, mix, or fom past first line */
|
||||
if (last_line == 0)
|
||||
{
|
||||
@@ -1108,7 +1163,9 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
OUT_FILL_COUNT2(fill_count, s);
|
||||
RESET_COUNTS;
|
||||
}
|
||||
|
||||
fill_count = 0;
|
||||
|
||||
if (mix_count > 3 &&
|
||||
mix_count >= fill_count &&
|
||||
mix_count >= bicolor_count &&
|
||||
@@ -1120,7 +1177,9 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
OUT_MIX_COUNT2(mix_count, s);
|
||||
RESET_COUNTS;
|
||||
}
|
||||
|
||||
mix_count = 0;
|
||||
|
||||
if (fom_count > 3 &&
|
||||
fom_count >= fill_count &&
|
||||
fom_count >= color_count &&
|
||||
@@ -1132,14 +1191,17 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
OUT_FOM_COUNT2(fom_count, s, fom_mask, fom_mask_len);
|
||||
RESET_COUNTS;
|
||||
}
|
||||
|
||||
fom_count = 0;
|
||||
fom_mask_len = 0;
|
||||
}
|
||||
|
||||
last_line = line;
|
||||
line = line - width * 2;
|
||||
start_line--;
|
||||
lines_sent++;
|
||||
}
|
||||
|
||||
if (fill_count > 3 &&
|
||||
fill_count >= color_count &&
|
||||
fill_count >= bicolor_count &&
|
||||
@@ -1189,6 +1251,7 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
OUT_COPY_COUNT2(count, s, temp_s);
|
||||
OUT_BICOLOR_COUNT2(bicolor_count, s, bicolor2, bicolor1);
|
||||
}
|
||||
|
||||
count -= bicolor_count;
|
||||
OUT_COPY_COUNT2(count, s, temp_s);
|
||||
OUT_BICOLOR_COUNT2(bicolor_count, s, bicolor1, bicolor2);
|
||||
@@ -1213,9 +1276,11 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
mix = 0xffffff;
|
||||
out_count = end * 3;
|
||||
line = in_data + width * start_line * 4;
|
||||
|
||||
while (start_line >= 0 && out_count < 32768)
|
||||
{
|
||||
i = (s->p - s->data) + count * 3;
|
||||
|
||||
if (i - (color_count * 3) >= byte_limit &&
|
||||
i - (bicolor_count * 3) >= byte_limit &&
|
||||
i - (fill_count * 3) >= byte_limit &&
|
||||
@@ -1224,12 +1289,15 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
out_count += end * 3;
|
||||
|
||||
for (i = 0; i < end; i++)
|
||||
{
|
||||
/* read next pixel */
|
||||
IN_PIXEL32(line, i, 0, width, last_pixel, pixel);
|
||||
IN_PIXEL32(last_line, i, 0, width, last_ypixel, ypixel);
|
||||
|
||||
if (!TEST_FILL)
|
||||
{
|
||||
if (fill_count > 3 &&
|
||||
@@ -1243,8 +1311,10 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
OUT_FILL_COUNT3(fill_count, s);
|
||||
RESET_COUNTS;
|
||||
}
|
||||
|
||||
fill_count = 0;
|
||||
}
|
||||
|
||||
if (!TEST_MIX)
|
||||
{
|
||||
if (mix_count > 3 &&
|
||||
@@ -1258,8 +1328,10 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
OUT_MIX_COUNT3(mix_count, s);
|
||||
RESET_COUNTS;
|
||||
}
|
||||
|
||||
mix_count = 0;
|
||||
}
|
||||
|
||||
if (!TEST_COLOR)
|
||||
{
|
||||
if (color_count > 3 &&
|
||||
@@ -1273,8 +1345,10 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
OUT_COLOR_COUNT3(color_count, s, last_pixel);
|
||||
RESET_COUNTS;
|
||||
}
|
||||
|
||||
color_count = 0;
|
||||
}
|
||||
|
||||
if (!TEST_BICOLOR)
|
||||
{
|
||||
if (bicolor_count > 3 &&
|
||||
@@ -1296,13 +1370,16 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
OUT_COPY_COUNT3(count, s, temp_s);
|
||||
OUT_BICOLOR_COUNT3(bicolor_count, s, bicolor2, bicolor1);
|
||||
}
|
||||
|
||||
RESET_COUNTS;
|
||||
}
|
||||
|
||||
bicolor_count = 0;
|
||||
bicolor1 = last_pixel;
|
||||
bicolor2 = pixel;
|
||||
bicolor_spin = 0;
|
||||
}
|
||||
|
||||
if (!TEST_FOM)
|
||||
{
|
||||
if (fom_count > 3 &&
|
||||
@@ -1316,26 +1393,32 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
OUT_FOM_COUNT3(fom_count, s, fom_mask, fom_mask_len);
|
||||
RESET_COUNTS;
|
||||
}
|
||||
|
||||
fom_count = 0;
|
||||
fom_mask_len = 0;
|
||||
}
|
||||
|
||||
if (TEST_FILL)
|
||||
{
|
||||
fill_count++;
|
||||
}
|
||||
|
||||
if (TEST_MIX)
|
||||
{
|
||||
mix_count++;
|
||||
}
|
||||
|
||||
if (TEST_COLOR)
|
||||
{
|
||||
color_count++;
|
||||
}
|
||||
|
||||
if (TEST_BICOLOR)
|
||||
{
|
||||
bicolor_spin = !bicolor_spin;
|
||||
bicolor_count++;
|
||||
}
|
||||
|
||||
if (TEST_FOM)
|
||||
{
|
||||
if ((fom_count % 8) == 0)
|
||||
@@ -1343,12 +1426,15 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
fom_mask[fom_mask_len] = 0;
|
||||
fom_mask_len++;
|
||||
}
|
||||
|
||||
if (pixel == (ypixel ^ mix))
|
||||
{
|
||||
fom_mask[fom_mask_len - 1] |= (1 << (fom_count % 8));
|
||||
}
|
||||
|
||||
fom_count++;
|
||||
}
|
||||
|
||||
out_uint8(temp_s, pixel & 0xff);
|
||||
out_uint8(temp_s, (pixel >> 8) & 0xff);
|
||||
out_uint8(temp_s, (pixel >> 16) & 0xff);
|
||||
@@ -1356,6 +1442,7 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
last_pixel = pixel;
|
||||
last_ypixel = ypixel;
|
||||
}
|
||||
|
||||
/* can't take fix, mix, or fom past first line */
|
||||
if (last_line == 0)
|
||||
{
|
||||
@@ -1370,7 +1457,9 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
OUT_FILL_COUNT3(fill_count, s);
|
||||
RESET_COUNTS;
|
||||
}
|
||||
|
||||
fill_count = 0;
|
||||
|
||||
if (mix_count > 3 &&
|
||||
mix_count >= fill_count &&
|
||||
mix_count >= bicolor_count &&
|
||||
@@ -1382,7 +1471,9 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
OUT_MIX_COUNT3(mix_count, s);
|
||||
RESET_COUNTS;
|
||||
}
|
||||
|
||||
mix_count = 0;
|
||||
|
||||
if (fom_count > 3 &&
|
||||
fom_count >= fill_count &&
|
||||
fom_count >= color_count &&
|
||||
@@ -1394,14 +1485,17 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
OUT_FOM_COUNT3(fom_count, s, fom_mask, fom_mask_len);
|
||||
RESET_COUNTS;
|
||||
}
|
||||
|
||||
fom_count = 0;
|
||||
fom_mask_len = 0;
|
||||
}
|
||||
|
||||
last_line = line;
|
||||
line = line - width * 4;
|
||||
start_line--;
|
||||
lines_sent++;
|
||||
}
|
||||
|
||||
if (fill_count > 3 &&
|
||||
fill_count >= color_count &&
|
||||
fill_count >= bicolor_count &&
|
||||
@@ -1451,6 +1545,7 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
OUT_COPY_COUNT3(count, s, temp_s);
|
||||
OUT_BICOLOR_COUNT3(bicolor_count, s, bicolor2, bicolor1);
|
||||
}
|
||||
|
||||
count -= bicolor_count;
|
||||
OUT_COPY_COUNT3(count, s, temp_s);
|
||||
OUT_BICOLOR_COUNT3(bicolor_count, s, bicolor1, bicolor2);
|
||||
@@ -1470,5 +1565,6 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
OUT_COPY_COUNT3(count, s, temp_s);
|
||||
}
|
||||
}
|
||||
|
||||
return lines_sent;
|
||||
}
|
||||
|
||||
+51
-39
@@ -1,24 +1,22 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2006-2010
|
||||
|
||||
channel layer
|
||||
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2006-2012
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* channel layer
|
||||
*/
|
||||
|
||||
#include "libxrdp.h"
|
||||
|
||||
@@ -31,27 +29,29 @@
|
||||
|
||||
/*****************************************************************************/
|
||||
/* returns pointer or nil on error */
|
||||
static struct mcs_channel_item* APP_CC
|
||||
xrdp_channel_get_item(struct xrdp_channel* self, int channel_id)
|
||||
static struct mcs_channel_item *APP_CC
|
||||
xrdp_channel_get_item(struct xrdp_channel *self, int channel_id)
|
||||
{
|
||||
struct mcs_channel_item* channel;
|
||||
if(self->mcs_layer->channel_list==NULL)
|
||||
struct mcs_channel_item *channel;
|
||||
|
||||
if (self->mcs_layer->channel_list == NULL)
|
||||
{
|
||||
g_writeln("xrdp_channel_get_item - No channel initialized");
|
||||
return NULL ;
|
||||
}
|
||||
channel = (struct mcs_channel_item*)
|
||||
|
||||
channel = (struct mcs_channel_item *)
|
||||
list_get_item(self->mcs_layer->channel_list, channel_id);
|
||||
return channel;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
struct xrdp_channel* APP_CC
|
||||
xrdp_channel_create(struct xrdp_sec* owner, struct xrdp_mcs* mcs_layer)
|
||||
struct xrdp_channel *APP_CC
|
||||
xrdp_channel_create(struct xrdp_sec *owner, struct xrdp_mcs *mcs_layer)
|
||||
{
|
||||
struct xrdp_channel* self;
|
||||
struct xrdp_channel *self;
|
||||
|
||||
self = (struct xrdp_channel*)g_malloc(sizeof(struct xrdp_channel), 1);
|
||||
self = (struct xrdp_channel *)g_malloc(sizeof(struct xrdp_channel), 1);
|
||||
self->sec_layer = owner;
|
||||
self->mcs_layer = mcs_layer;
|
||||
return self;
|
||||
@@ -60,25 +60,27 @@ xrdp_channel_create(struct xrdp_sec* owner, struct xrdp_mcs* mcs_layer)
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
void APP_CC
|
||||
xrdp_channel_delete(struct xrdp_channel* self)
|
||||
xrdp_channel_delete(struct xrdp_channel *self)
|
||||
{
|
||||
if (self == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
g_memset(self,0,sizeof(struct xrdp_channel));
|
||||
|
||||
g_memset(self, 0, sizeof(struct xrdp_channel));
|
||||
g_free(self);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
int APP_CC
|
||||
xrdp_channel_init(struct xrdp_channel* self, struct stream* s)
|
||||
xrdp_channel_init(struct xrdp_channel *self, struct stream *s)
|
||||
{
|
||||
if (xrdp_sec_init(self->sec_layer, s) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
s_push_layer(s, channel_hdr, 8);
|
||||
return 0;
|
||||
}
|
||||
@@ -87,29 +89,35 @@ xrdp_channel_init(struct xrdp_channel* self, struct stream* s)
|
||||
/* returns error */
|
||||
/* This sends data out to the secure layer. */
|
||||
int APP_CC
|
||||
xrdp_channel_send(struct xrdp_channel* self, struct stream* s, int channel_id,
|
||||
xrdp_channel_send(struct xrdp_channel *self, struct stream *s, int channel_id,
|
||||
int total_data_len, int flags)
|
||||
{
|
||||
struct mcs_channel_item* channel;
|
||||
struct mcs_channel_item *channel;
|
||||
|
||||
channel = xrdp_channel_get_item(self, channel_id);
|
||||
|
||||
if (channel == NULL)
|
||||
{
|
||||
g_writeln("xrdp_channel_send - no such channel");
|
||||
return 1;
|
||||
}
|
||||
|
||||
s_pop_layer(s, channel_hdr);
|
||||
out_uint32_le(s, total_data_len);
|
||||
|
||||
if (channel->flags & XR_CHANNEL_OPTION_SHOW_PROTOCOL)
|
||||
{
|
||||
flags |= CHANNEL_FLAG_SHOW_PROTOCOL;
|
||||
}
|
||||
|
||||
out_uint32_le(s, flags);
|
||||
|
||||
if (xrdp_sec_send(self->sec_layer, s, channel->chanid) != 0)
|
||||
{
|
||||
g_writeln("xrdp_channel_send - failure sending data");
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -118,16 +126,17 @@ xrdp_channel_send(struct xrdp_channel* self, struct stream* s, int channel_id,
|
||||
/* this will inform the callback, whatever it is that some channel data is
|
||||
ready. the default for this is a call to xrdp_wm.c. */
|
||||
static int APP_CC
|
||||
xrdp_channel_call_callback(struct xrdp_channel* self, struct stream* s,
|
||||
xrdp_channel_call_callback(struct xrdp_channel *self, struct stream *s,
|
||||
int channel_id,
|
||||
int total_data_len, int flags)
|
||||
{
|
||||
struct xrdp_session* session;
|
||||
struct xrdp_session *session;
|
||||
int rv;
|
||||
int size;
|
||||
|
||||
rv = 0;
|
||||
session = self->sec_layer->rdp_layer->session;
|
||||
|
||||
if (session != 0)
|
||||
{
|
||||
if (session->callback != 0)
|
||||
@@ -147,6 +156,7 @@ xrdp_channel_call_callback(struct xrdp_channel* self, struct stream* s,
|
||||
{
|
||||
g_writeln("in xrdp_channel_call_callback, session is nil");
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
@@ -157,14 +167,14 @@ xrdp_channel_call_callback(struct xrdp_channel* self, struct stream* s,
|
||||
'chanid' passed in here is the mcs channel id so it MCS_GLOBAL_CHANNEL
|
||||
plus something. */
|
||||
int APP_CC
|
||||
xrdp_channel_process(struct xrdp_channel* self, struct stream* s,
|
||||
xrdp_channel_process(struct xrdp_channel *self, struct stream *s,
|
||||
int chanid)
|
||||
{
|
||||
int length;
|
||||
int flags;
|
||||
int rv;
|
||||
int channel_id;
|
||||
struct mcs_channel_item* channel;
|
||||
struct mcs_channel_item *channel;
|
||||
|
||||
|
||||
/* this assumes that the channels are in order of chanid(mcs channel id)
|
||||
@@ -173,11 +183,13 @@ xrdp_channel_process(struct xrdp_channel* self, struct stream* s,
|
||||
one should be MCS_GLOBAL_CHANNEL + 2, and so on */
|
||||
channel_id = (chanid - MCS_GLOBAL_CHANNEL) - 1;
|
||||
channel = xrdp_channel_get_item(self, channel_id);
|
||||
|
||||
if (channel == NULL)
|
||||
{
|
||||
g_writeln("xrdp_channel_process, channel not found");
|
||||
return 1;
|
||||
}
|
||||
|
||||
rv = 0;
|
||||
in_uint32_le(s, length);
|
||||
in_uint32_le(s, flags);
|
||||
|
||||
+28
-15
@@ -20,14 +20,14 @@
|
||||
#include "libxrdp.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
struct xrdp_fastpath* APP_CC
|
||||
xrdp_fastpath_create(struct xrdp_session* session)
|
||||
struct xrdp_fastpath *APP_CC
|
||||
xrdp_fastpath_create(struct xrdp_session *session)
|
||||
{
|
||||
struct xrdp_fastpath* self;
|
||||
struct xrdp_fastpath *self;
|
||||
|
||||
self = (struct xrdp_fastpath*)g_malloc(sizeof(struct xrdp_fastpath), 1);
|
||||
self = (struct xrdp_fastpath *)g_malloc(sizeof(struct xrdp_fastpath), 1);
|
||||
self->tcp_layer =
|
||||
((struct xrdp_rdp*)session->rdp)->sec_layer->
|
||||
((struct xrdp_rdp *)session->rdp)->sec_layer->
|
||||
mcs_layer->iso_layer->tcp_layer;
|
||||
make_stream(self->out_s);
|
||||
init_stream(self->out_s, FASTPATH_MAX_PACKET_SIZE);
|
||||
@@ -36,12 +36,13 @@ xrdp_fastpath_create(struct xrdp_session* session)
|
||||
|
||||
/*****************************************************************************/
|
||||
void APP_CC
|
||||
xrdp_fastpath_delete(struct xrdp_fastpath* self)
|
||||
xrdp_fastpath_delete(struct xrdp_fastpath *self)
|
||||
{
|
||||
if (self == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
free_stream(self->out_s);
|
||||
g_free(self);
|
||||
}
|
||||
@@ -49,27 +50,27 @@ xrdp_fastpath_delete(struct xrdp_fastpath* self)
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
int APP_CC
|
||||
xrdp_fastpath_reset(struct xrdp_fastpath* self)
|
||||
xrdp_fastpath_reset(struct xrdp_fastpath *self)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int APP_CC
|
||||
xrdp_fastpath_init(struct xrdp_fastpath* self)
|
||||
xrdp_fastpath_init(struct xrdp_fastpath *self)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
int APP_CC
|
||||
xrdp_fastpath_send_update_pdu(struct xrdp_fastpath* self, tui8 updateCode,
|
||||
struct stream* s)
|
||||
xrdp_fastpath_send_update_pdu(struct xrdp_fastpath *self, tui8 updateCode,
|
||||
struct stream *s)
|
||||
{
|
||||
tui16 len;
|
||||
tui16 maxLen;
|
||||
tui32 payloadLeft;
|
||||
tui8 fragment;
|
||||
struct stream* s_send;
|
||||
struct stream *s_send;
|
||||
int compression;
|
||||
int i;
|
||||
int i32;
|
||||
@@ -78,6 +79,7 @@ xrdp_fastpath_send_update_pdu(struct xrdp_fastpath* self, tui8 updateCode,
|
||||
s_send = self->out_s;
|
||||
maxLen = FASTPATH_MAX_PACKET_SIZE - 6; /* 6 bytes for header */
|
||||
payloadLeft = (s->end - s->data);
|
||||
|
||||
for (i = 0; payloadLeft > 0; i++)
|
||||
{
|
||||
if (payloadLeft > maxLen)
|
||||
@@ -88,7 +90,9 @@ xrdp_fastpath_send_update_pdu(struct xrdp_fastpath* self, tui8 updateCode,
|
||||
{
|
||||
len = payloadLeft;
|
||||
}
|
||||
|
||||
payloadLeft -= len;
|
||||
|
||||
if (payloadLeft == 0)
|
||||
{
|
||||
fragment = i ? FASTPATH_FRAGMENT_LAST : FASTPATH_FRAGMENT_SINGLE;
|
||||
@@ -97,6 +101,7 @@ xrdp_fastpath_send_update_pdu(struct xrdp_fastpath* self, tui8 updateCode,
|
||||
{
|
||||
fragment = i ? FASTPATH_FRAGMENT_NEXT : FASTPATH_FRAGMENT_FIRST;
|
||||
}
|
||||
|
||||
init_stream(s_send, 0);
|
||||
out_uint8(s_send, 0); /* fOutputHeader */
|
||||
i32 = ((len + 6) >> 8) | 0x80;
|
||||
@@ -109,18 +114,20 @@ xrdp_fastpath_send_update_pdu(struct xrdp_fastpath* self, tui8 updateCode,
|
||||
out_uint16_le(s_send, len);
|
||||
s_copy(s_send, s, len);
|
||||
s_mark_end(s_send);
|
||||
|
||||
if (xrdp_tcp_send(self->tcp_layer, s_send) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
int
|
||||
xrdp_fastpath_process_update(struct xrdp_fastpath* self, tui8 updateCode,
|
||||
tui32 size, struct stream* s)
|
||||
xrdp_fastpath_process_update(struct xrdp_fastpath *self, tui8 updateCode,
|
||||
tui32 size, struct stream *s)
|
||||
{
|
||||
switch (updateCode)
|
||||
{
|
||||
@@ -147,7 +154,7 @@ xrdp_fastpath_process_update(struct xrdp_fastpath* self, tui8 updateCode,
|
||||
|
||||
/*****************************************************************************/
|
||||
int APP_CC
|
||||
xrdp_fastpath_process_data(struct xrdp_fastpath* self, struct stream* s,
|
||||
xrdp_fastpath_process_data(struct xrdp_fastpath *self, struct stream *s,
|
||||
tui8 header)
|
||||
{
|
||||
tui8 encryptionFlags;
|
||||
@@ -164,6 +171,7 @@ xrdp_fastpath_process_data(struct xrdp_fastpath* self, struct stream* s,
|
||||
numberEvents = (header & 0x3c) >> 2;
|
||||
xrdp_tcp_recv(self->tcp_layer, s, 1);
|
||||
in_uint8(s, length);
|
||||
|
||||
if (length & 0x80)
|
||||
{
|
||||
xrdp_tcp_recv(self->tcp_layer, s, 1);
|
||||
@@ -174,23 +182,28 @@ xrdp_fastpath_process_data(struct xrdp_fastpath* self, struct stream* s,
|
||||
{
|
||||
length -= 2;
|
||||
}
|
||||
|
||||
xrdp_tcp_recv(self->tcp_layer, s, length);
|
||||
|
||||
if (encryptionFlags != 0)
|
||||
{
|
||||
/* TODO decryption ...*/
|
||||
}
|
||||
|
||||
/* parse updateHeader */
|
||||
in_uint8(s, updateHeader);
|
||||
updateCode = (updateHeader & 0x0f);
|
||||
updateFrag = (updateHeader & 0x30) >> 4;
|
||||
updateComp = (updateHeader & 0xc0) >> 6;
|
||||
|
||||
if (updateFrag && updateComp)
|
||||
{
|
||||
/* TODO */
|
||||
g_writeln("xrdp_fastpath_process_data: updateFrag=%d, updateComp=%d",
|
||||
updateFrag,updateComp);
|
||||
updateFrag, updateComp);
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint16_le(s, size);
|
||||
return xrdp_fastpath_process_update(self, updateCode, size, s);
|
||||
}
|
||||
|
||||
+52
-33
@@ -1,35 +1,33 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2004-2010
|
||||
|
||||
iso layer
|
||||
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* iso layer
|
||||
*/
|
||||
|
||||
#include "libxrdp.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
struct xrdp_iso* APP_CC
|
||||
xrdp_iso_create(struct xrdp_mcs* owner, struct trans* trans)
|
||||
struct xrdp_iso *APP_CC
|
||||
xrdp_iso_create(struct xrdp_mcs *owner, struct trans *trans)
|
||||
{
|
||||
struct xrdp_iso* self;
|
||||
struct xrdp_iso *self;
|
||||
|
||||
DEBUG((" in xrdp_iso_create"));
|
||||
self = (struct xrdp_iso*)g_malloc(sizeof(struct xrdp_iso), 1);
|
||||
self = (struct xrdp_iso *)g_malloc(sizeof(struct xrdp_iso), 1);
|
||||
self->mcs_layer = owner;
|
||||
self->tcp_layer = xrdp_tcp_create(self, trans);
|
||||
DEBUG((" out xrdp_iso_create"));
|
||||
@@ -38,12 +36,13 @@ xrdp_iso_create(struct xrdp_mcs* owner, struct trans* trans)
|
||||
|
||||
/*****************************************************************************/
|
||||
void APP_CC
|
||||
xrdp_iso_delete(struct xrdp_iso* self)
|
||||
xrdp_iso_delete(struct xrdp_iso *self)
|
||||
{
|
||||
if (self == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
xrdp_tcp_delete(self->tcp_layer);
|
||||
g_free(self);
|
||||
}
|
||||
@@ -51,29 +50,36 @@ xrdp_iso_delete(struct xrdp_iso* self)
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
static int APP_CC
|
||||
xrdp_iso_recv_msg(struct xrdp_iso* self, struct stream* s, int* code)
|
||||
xrdp_iso_recv_msg(struct xrdp_iso *self, struct stream *s, int *code)
|
||||
{
|
||||
int ver;
|
||||
int len;
|
||||
|
||||
*code = 0;
|
||||
|
||||
if (xrdp_tcp_recv(self->tcp_layer, s, 4) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint8(s, ver);
|
||||
|
||||
if (ver != 3)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint8s(s, 1);
|
||||
in_uint16_be(s, len);
|
||||
|
||||
if (xrdp_tcp_recv(self->tcp_layer, s, len - 4) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint8s(s, 1);
|
||||
in_uint8(s, *code);
|
||||
|
||||
if (*code == ISO_PDU_DT)
|
||||
{
|
||||
in_uint8s(s, 1);
|
||||
@@ -82,39 +88,44 @@ xrdp_iso_recv_msg(struct xrdp_iso* self, struct stream* s, int* code)
|
||||
{
|
||||
in_uint8s(s, 5);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
int APP_CC
|
||||
xrdp_iso_recv(struct xrdp_iso* self, struct stream* s)
|
||||
xrdp_iso_recv(struct xrdp_iso *self, struct stream *s)
|
||||
{
|
||||
int code;
|
||||
|
||||
DEBUG((" in xrdp_iso_recv"));
|
||||
|
||||
if (xrdp_iso_recv_msg(self, s, &code) != 0)
|
||||
{
|
||||
DEBUG((" out xrdp_iso_recv xrdp_iso_recv_msg return non zero"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (code != ISO_PDU_DT)
|
||||
{
|
||||
DEBUG((" out xrdp_iso_recv code != ISO_PDU_DT"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
DEBUG((" out xrdp_iso_recv"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
static int APP_CC
|
||||
xrdp_iso_send_msg(struct xrdp_iso* self, struct stream* s, int code)
|
||||
xrdp_iso_send_msg(struct xrdp_iso *self, struct stream *s, int code)
|
||||
{
|
||||
if (xrdp_tcp_init(self->tcp_layer, s) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
out_uint8(s, 3);
|
||||
out_uint8(s, 0);
|
||||
out_uint16_be(s, 11); /* length */
|
||||
@@ -124,39 +135,45 @@ xrdp_iso_send_msg(struct xrdp_iso* self, struct stream* s, int code)
|
||||
out_uint16_le(s, 0);
|
||||
out_uint8(s, 0);
|
||||
s_mark_end(s);
|
||||
|
||||
if (xrdp_tcp_send(self->tcp_layer, s) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
int APP_CC
|
||||
xrdp_iso_incoming(struct xrdp_iso* self)
|
||||
xrdp_iso_incoming(struct xrdp_iso *self)
|
||||
{
|
||||
int code;
|
||||
struct stream* s;
|
||||
struct stream *s;
|
||||
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
DEBUG((" in xrdp_iso_incoming"));
|
||||
|
||||
if (xrdp_iso_recv_msg(self, s, &code) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (code != ISO_PDU_CR)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (xrdp_iso_send_msg(self, s, ISO_PDU_CC) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
DEBUG((" out xrdp_iso_incoming"));
|
||||
free_stream(s);
|
||||
return 0;
|
||||
@@ -165,7 +182,7 @@ xrdp_iso_incoming(struct xrdp_iso* self)
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
int APP_CC
|
||||
xrdp_iso_init(struct xrdp_iso* self, struct stream* s)
|
||||
xrdp_iso_init(struct xrdp_iso *self, struct stream *s)
|
||||
{
|
||||
xrdp_tcp_init(self->tcp_layer, s);
|
||||
s_push_layer(s, iso_hdr, 7);
|
||||
@@ -175,7 +192,7 @@ xrdp_iso_init(struct xrdp_iso* self, struct stream* s)
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
int APP_CC
|
||||
xrdp_iso_send(struct xrdp_iso* self, struct stream* s)
|
||||
xrdp_iso_send(struct xrdp_iso *self, struct stream *s)
|
||||
{
|
||||
int len;
|
||||
|
||||
@@ -188,10 +205,12 @@ xrdp_iso_send(struct xrdp_iso* self, struct stream* s)
|
||||
out_uint8(s, 2);
|
||||
out_uint8(s, ISO_PDU_DT);
|
||||
out_uint8(s, 0x80);
|
||||
|
||||
if (xrdp_tcp_send(self->tcp_layer, s) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
DEBUG((" out xrdp_iso_send"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,24 +1,22 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2012
|
||||
|
||||
jpeg compressor
|
||||
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* jpeg compressor
|
||||
*/
|
||||
|
||||
#include "libxrdp.h"
|
||||
|
||||
@@ -33,7 +31,7 @@
|
||||
|
||||
struct mydata_comp
|
||||
{
|
||||
char* cb;
|
||||
char *cb;
|
||||
int cb_bytes;
|
||||
int total_done;
|
||||
int overwrite;
|
||||
@@ -44,9 +42,9 @@ struct mydata_comp
|
||||
static void DEFAULT_CC
|
||||
my_init_destination(j_compress_ptr cinfo)
|
||||
{
|
||||
struct mydata_comp* md;
|
||||
struct mydata_comp *md;
|
||||
|
||||
md = (struct mydata_comp*)(cinfo->client_data);
|
||||
md = (struct mydata_comp *)(cinfo->client_data);
|
||||
md->total_done = 0;
|
||||
md->overwrite = 0;
|
||||
cinfo->dest->next_output_byte = md->cb;
|
||||
@@ -58,10 +56,10 @@ my_init_destination(j_compress_ptr cinfo)
|
||||
static int DEFAULT_CC
|
||||
my_empty_output_buffer(j_compress_ptr cinfo)
|
||||
{
|
||||
struct mydata_comp* md;
|
||||
struct mydata_comp *md;
|
||||
int chunk_bytes;
|
||||
|
||||
md = (struct mydata_comp*)(cinfo->client_data);
|
||||
md = (struct mydata_comp *)(cinfo->client_data);
|
||||
chunk_bytes = md->cb_bytes;
|
||||
md->total_done += chunk_bytes;
|
||||
cinfo->dest->next_output_byte = md->cb;
|
||||
@@ -75,18 +73,18 @@ my_empty_output_buffer(j_compress_ptr cinfo)
|
||||
static void DEFAULT_CC
|
||||
my_term_destination(j_compress_ptr cinfo)
|
||||
{
|
||||
struct mydata_comp* md;
|
||||
struct mydata_comp *md;
|
||||
int chunk_bytes;
|
||||
|
||||
md = (struct mydata_comp*)(cinfo->client_data);
|
||||
md = (struct mydata_comp *)(cinfo->client_data);
|
||||
chunk_bytes = md->cb_bytes - cinfo->dest->free_in_buffer;
|
||||
md->total_done += chunk_bytes;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
static int APP_CC
|
||||
jp_do_compress(char* data, int width, int height, int bpp, int quality,
|
||||
char* comp_data, int* comp_data_bytes)
|
||||
jp_do_compress(char *data, int width, int height, int bpp, int quality,
|
||||
char *comp_data, int *comp_data_bytes)
|
||||
{
|
||||
struct jpeg_compress_struct cinfo;
|
||||
struct jpeg_error_mgr jerr;
|
||||
@@ -117,6 +115,7 @@ jp_do_compress(char* data, int width, int height, int bpp, int quality,
|
||||
cinfo.dct_method = JDCT_FLOAT;
|
||||
jpeg_set_quality(&cinfo, quality, 1);
|
||||
jpeg_start_compress(&cinfo, 1);
|
||||
|
||||
while (cinfo.next_scanline + 3 < cinfo.image_height)
|
||||
{
|
||||
row_pointer[0] = data;
|
||||
@@ -129,32 +128,36 @@ jp_do_compress(char* data, int width, int height, int bpp, int quality,
|
||||
data += width * Bpp;
|
||||
jpeg_write_scanlines(&cinfo, row_pointer, 4);
|
||||
}
|
||||
|
||||
while (cinfo.next_scanline < cinfo.image_height)
|
||||
{
|
||||
row_pointer[0] = data;
|
||||
data += width * Bpp;
|
||||
jpeg_write_scanlines(&cinfo, row_pointer, 1);
|
||||
}
|
||||
|
||||
jpeg_finish_compress(&cinfo);
|
||||
*comp_data_bytes = md.total_done;
|
||||
jpeg_destroy_compress(&cinfo);
|
||||
|
||||
if (md.overwrite)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
static int APP_CC
|
||||
jpeg_compress(char* in_data, int width, int height,
|
||||
struct stream* s, struct stream* temp_s, int bpp,
|
||||
jpeg_compress(char *in_data, int width, int height,
|
||||
struct stream *s, struct stream *temp_s, int bpp,
|
||||
int byte_limit, int e, int quality)
|
||||
{
|
||||
char* data;
|
||||
tui32* src32;
|
||||
tui16* src16;
|
||||
tui8* dst8;
|
||||
char *data;
|
||||
tui32 *src32;
|
||||
tui16 *src16;
|
||||
tui8 *dst8;
|
||||
tui32 pixel;
|
||||
int red;
|
||||
int blue;
|
||||
@@ -165,19 +168,22 @@ jpeg_compress(char* in_data, int width, int height,
|
||||
|
||||
data = temp_s->data;
|
||||
dst8 = data;
|
||||
|
||||
if (bpp == 24)
|
||||
{
|
||||
src32 = (tui32*)in_data;
|
||||
src32 = (tui32 *)in_data;
|
||||
|
||||
for (j = 0; j < height; j++)
|
||||
{
|
||||
for (i = 0; i < width; i++)
|
||||
{
|
||||
pixel = src32[i + j * width];
|
||||
SPLITCOLOR32(red, green, blue, pixel);
|
||||
*(dst8++)= blue;
|
||||
*(dst8++)= green;
|
||||
*(dst8++)= red;
|
||||
*(dst8++) = blue;
|
||||
*(dst8++) = green;
|
||||
*(dst8++) = red;
|
||||
}
|
||||
|
||||
for (i = 0; i < e; i++)
|
||||
{
|
||||
*(dst8++) = blue;
|
||||
@@ -190,6 +196,7 @@ jpeg_compress(char* in_data, int width, int height,
|
||||
{
|
||||
g_writeln("bpp wrong %d", bpp);
|
||||
}
|
||||
|
||||
cdata_bytes = byte_limit;
|
||||
jp_do_compress(data, width + e, height, 24, quality, s->p, &cdata_bytes);
|
||||
s->p += cdata_bytes;
|
||||
@@ -198,9 +205,9 @@ jpeg_compress(char* in_data, int width, int height,
|
||||
|
||||
/*****************************************************************************/
|
||||
int APP_CC
|
||||
xrdp_jpeg_compress(char* in_data, int width, int height,
|
||||
struct stream* s, int bpp, int byte_limit,
|
||||
int start_line, struct stream* temp_s,
|
||||
xrdp_jpeg_compress(char *in_data, int width, int height,
|
||||
struct stream *s, int bpp, int byte_limit,
|
||||
int start_line, struct stream *temp_s,
|
||||
int e, int quality)
|
||||
{
|
||||
jpeg_compress(in_data, width, height, s, temp_s, bpp, byte_limit,
|
||||
@@ -212,9 +219,9 @@ xrdp_jpeg_compress(char* in_data, int width, int height,
|
||||
|
||||
/*****************************************************************************/
|
||||
int APP_CC
|
||||
xrdp_jpeg_compress(char* in_data, int width, int height,
|
||||
struct stream* s, int bpp, int byte_limit,
|
||||
int start_line, struct stream* temp_s,
|
||||
xrdp_jpeg_compress(char *in_data, int width, int height,
|
||||
struct stream *s, int bpp, int byte_limit,
|
||||
int start_line, struct stream *temp_s,
|
||||
int e, int quality)
|
||||
{
|
||||
return height;
|
||||
|
||||
+158
-65
@@ -1,37 +1,35 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2004-2010
|
||||
|
||||
mcs layer
|
||||
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* mcs layer
|
||||
*/
|
||||
|
||||
#include "libxrdp.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
struct xrdp_mcs* APP_CC
|
||||
xrdp_mcs_create(struct xrdp_sec* owner, struct trans* trans,
|
||||
struct stream* client_mcs_data,
|
||||
struct stream* server_mcs_data)
|
||||
struct xrdp_mcs *APP_CC
|
||||
xrdp_mcs_create(struct xrdp_sec *owner, struct trans *trans,
|
||||
struct stream *client_mcs_data,
|
||||
struct stream *server_mcs_data)
|
||||
{
|
||||
struct xrdp_mcs* self;
|
||||
struct xrdp_mcs *self;
|
||||
|
||||
DEBUG((" in xrdp_mcs_create"));
|
||||
self = (struct xrdp_mcs*)g_malloc(sizeof(struct xrdp_mcs), 1);
|
||||
self = (struct xrdp_mcs *)g_malloc(sizeof(struct xrdp_mcs), 1);
|
||||
self->sec_layer = owner;
|
||||
self->userid = 1;
|
||||
self->chanid = 1001;
|
||||
@@ -45,9 +43,9 @@ xrdp_mcs_create(struct xrdp_sec* owner, struct trans* trans,
|
||||
|
||||
/*****************************************************************************/
|
||||
void APP_CC
|
||||
xrdp_mcs_delete(struct xrdp_mcs* self)
|
||||
xrdp_mcs_delete(struct xrdp_mcs *self)
|
||||
{
|
||||
struct mcs_channel_item* channel_item;
|
||||
struct mcs_channel_item *channel_item;
|
||||
int index;
|
||||
int count;
|
||||
|
||||
@@ -55,19 +53,22 @@ xrdp_mcs_delete(struct xrdp_mcs* self)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* here we have to free the channel items and anything in them */
|
||||
count = self->channel_list->count;
|
||||
|
||||
for (index = count - 1; index >= 0; index--)
|
||||
{
|
||||
channel_item = (struct mcs_channel_item*)
|
||||
channel_item = (struct mcs_channel_item *)
|
||||
list_get_item(self->channel_list, index);
|
||||
g_free(channel_item);
|
||||
}
|
||||
|
||||
list_delete(self->channel_list);
|
||||
xrdp_iso_delete(self->iso_layer);
|
||||
/* make sure we get null pointer exception if struct is used again. */
|
||||
DEBUG(("xrdp_mcs_delete processed"))
|
||||
g_memset(self,0,sizeof(struct xrdp_mcs)) ;
|
||||
g_memset(self, 0, sizeof(struct xrdp_mcs)) ;
|
||||
g_free(self);
|
||||
}
|
||||
|
||||
@@ -75,31 +76,35 @@ xrdp_mcs_delete(struct xrdp_mcs* self)
|
||||
/* This function sends channel join confirm*/
|
||||
/* returns error = 1 ok = 0*/
|
||||
static int APP_CC
|
||||
xrdp_mcs_send_cjcf(struct xrdp_mcs* self, int userid, int chanid)
|
||||
xrdp_mcs_send_cjcf(struct xrdp_mcs *self, int userid, int chanid)
|
||||
{
|
||||
struct stream* s;
|
||||
struct stream *s;
|
||||
|
||||
DEBUG((" in xrdp_mcs_send_cjcf"));
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
|
||||
if (xrdp_iso_init(self->iso_layer, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
DEBUG((" out xrdp_mcs_send_cjcf error"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
out_uint8(s, (MCS_CJCF << 2) | 2);
|
||||
out_uint8(s, 0);
|
||||
out_uint16_be(s, userid);
|
||||
out_uint16_be(s, chanid); /* TODO Explain why we send this two times */
|
||||
out_uint16_be(s, chanid);
|
||||
s_mark_end(s);
|
||||
|
||||
if (xrdp_iso_send(self->iso_layer, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
DEBUG((" out xrdp_mcs_send_cjcf error"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
DEBUG((" out xrdp_mcs_send_cjcf"));
|
||||
return 0;
|
||||
@@ -108,7 +113,7 @@ xrdp_mcs_send_cjcf(struct xrdp_mcs* self, int userid, int chanid)
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
int APP_CC
|
||||
xrdp_mcs_recv(struct xrdp_mcs* self, struct stream* s, int* chan)
|
||||
xrdp_mcs_recv(struct xrdp_mcs *self, struct stream *s, int *chan)
|
||||
{
|
||||
int appid;
|
||||
int opcode;
|
||||
@@ -117,6 +122,7 @@ xrdp_mcs_recv(struct xrdp_mcs* self, struct stream* s, int* chan)
|
||||
int chanid;
|
||||
|
||||
DEBUG((" in xrdp_mcs_recv"));
|
||||
|
||||
while (1)
|
||||
{
|
||||
if (xrdp_iso_recv(self->iso_layer, s) != 0)
|
||||
@@ -124,14 +130,17 @@ xrdp_mcs_recv(struct xrdp_mcs* self, struct stream* s, int* chan)
|
||||
DEBUG((" out xrdp_mcs_recv xrdp_iso_recv returned non zero"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint8(s, opcode);
|
||||
appid = opcode >> 2;
|
||||
|
||||
if (appid == MCS_DPUM) /* Disconnect Provider Ultimatum */
|
||||
{
|
||||
g_writeln("received Disconnect Provider Ultimatum");
|
||||
DEBUG((" out xrdp_mcs_recv appid != MCS_DPUM"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* this is channels getting added from the client */
|
||||
if (appid == MCS_CJRQ)
|
||||
{
|
||||
@@ -139,35 +148,43 @@ xrdp_mcs_recv(struct xrdp_mcs* self, struct stream* s, int* chan)
|
||||
in_uint16_be(s, userid);
|
||||
in_uint16_be(s, chanid);
|
||||
DEBUG(("xrdp_mcs_recv adding channel %4.4x", chanid));
|
||||
if(xrdp_mcs_send_cjcf(self, userid, chanid)!=0)
|
||||
|
||||
if (xrdp_mcs_send_cjcf(self, userid, chanid) != 0)
|
||||
{
|
||||
g_writeln("Non handled error from xrdp_mcs_send_cjcf") ;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
if(appid==MCS_SDRQ || appid==MCS_SDIN)
|
||||
|
||||
if (appid == MCS_SDRQ || appid == MCS_SDIN)
|
||||
{
|
||||
break ;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_writeln("Recieved an unhandled appid:%d",appid);
|
||||
g_writeln("Recieved an unhandled appid:%d", appid);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (appid != MCS_SDRQ)
|
||||
{
|
||||
DEBUG((" out xrdp_mcs_recv err got 0x%x need MCS_SDRQ", appid));
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint8s(s, 2);
|
||||
in_uint16_be(s, *chan);
|
||||
in_uint8s(s, 1);
|
||||
in_uint8(s, len);
|
||||
|
||||
if (len & 0x80)
|
||||
{
|
||||
in_uint8s(s, 1);
|
||||
}
|
||||
|
||||
DEBUG((" out xrdp_mcs_recv"));
|
||||
return 0;
|
||||
}
|
||||
@@ -175,8 +192,8 @@ xrdp_mcs_recv(struct xrdp_mcs* self, struct stream* s, int* chan)
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
static int APP_CC
|
||||
xrdp_mcs_ber_parse_header(struct xrdp_mcs* self, struct stream* s,
|
||||
int tag_val, int* len)
|
||||
xrdp_mcs_ber_parse_header(struct xrdp_mcs *self, struct stream *s,
|
||||
int tag_val, int *len)
|
||||
{
|
||||
int tag;
|
||||
int l;
|
||||
@@ -190,15 +207,19 @@ xrdp_mcs_ber_parse_header(struct xrdp_mcs* self, struct stream* s,
|
||||
{
|
||||
in_uint8(s, tag);
|
||||
}
|
||||
|
||||
if (tag != tag_val)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint8(s, l);
|
||||
|
||||
if (l & 0x80)
|
||||
{
|
||||
l = l & ~0x80;
|
||||
*len = 0;
|
||||
|
||||
while (l > 0)
|
||||
{
|
||||
in_uint8(s, i);
|
||||
@@ -210,6 +231,7 @@ xrdp_mcs_ber_parse_header(struct xrdp_mcs* self, struct stream* s,
|
||||
{
|
||||
*len = l;
|
||||
}
|
||||
|
||||
if (s_check(s))
|
||||
{
|
||||
return 0;
|
||||
@@ -223,7 +245,7 @@ xrdp_mcs_ber_parse_header(struct xrdp_mcs* self, struct stream* s,
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
static int APP_CC
|
||||
xrdp_mcs_parse_domain_params(struct xrdp_mcs* self, struct stream* s)
|
||||
xrdp_mcs_parse_domain_params(struct xrdp_mcs *self, struct stream *s)
|
||||
{
|
||||
int len;
|
||||
|
||||
@@ -231,7 +253,9 @@ xrdp_mcs_parse_domain_params(struct xrdp_mcs* self, struct stream* s)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint8s(s, len);
|
||||
|
||||
if (s_check(s))
|
||||
{
|
||||
return 0;
|
||||
@@ -245,66 +269,80 @@ xrdp_mcs_parse_domain_params(struct xrdp_mcs* self, struct stream* s)
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
static int APP_CC
|
||||
xrdp_mcs_recv_connect_initial(struct xrdp_mcs* self)
|
||||
xrdp_mcs_recv_connect_initial(struct xrdp_mcs *self)
|
||||
{
|
||||
int len;
|
||||
struct stream* s;
|
||||
struct stream *s;
|
||||
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
|
||||
if (xrdp_iso_recv(self->iso_layer, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (xrdp_mcs_ber_parse_header(self, s, MCS_CONNECT_INITIAL, &len) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (xrdp_mcs_ber_parse_header(self, s, BER_TAG_OCTET_STRING, &len) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint8s(s, len);
|
||||
|
||||
if (xrdp_mcs_ber_parse_header(self, s, BER_TAG_OCTET_STRING, &len) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint8s(s, len);
|
||||
|
||||
if (xrdp_mcs_ber_parse_header(self, s, BER_TAG_BOOLEAN, &len) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint8s(s, len);
|
||||
|
||||
if (xrdp_mcs_parse_domain_params(self, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (xrdp_mcs_parse_domain_params(self, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (xrdp_mcs_parse_domain_params(self, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (xrdp_mcs_ber_parse_header(self, s, BER_TAG_OCTET_STRING, &len) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* make a copy of client mcs data */
|
||||
init_stream(self->client_mcs_data, len);
|
||||
out_uint8a(self->client_mcs_data, s->p, len);
|
||||
in_uint8s(s, len);
|
||||
s_mark_end(self->client_mcs_data);
|
||||
|
||||
if (s_check_end(s))
|
||||
{
|
||||
free_stream(s);
|
||||
@@ -320,35 +358,42 @@ xrdp_mcs_recv_connect_initial(struct xrdp_mcs* self)
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
static int APP_CC
|
||||
xrdp_mcs_recv_edrq(struct xrdp_mcs* self)
|
||||
xrdp_mcs_recv_edrq(struct xrdp_mcs *self)
|
||||
{
|
||||
int opcode;
|
||||
struct stream* s;
|
||||
struct stream *s;
|
||||
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
|
||||
if (xrdp_iso_recv(self->iso_layer, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint8(s, opcode);
|
||||
|
||||
if ((opcode >> 2) != MCS_EDRQ)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint8s(s, 2);
|
||||
in_uint8s(s, 2);
|
||||
|
||||
if (opcode & 2)
|
||||
{
|
||||
in_uint16_be(s, self->userid);
|
||||
}
|
||||
|
||||
if (!(s_check_end(s)))
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
return 0;
|
||||
}
|
||||
@@ -356,33 +401,39 @@ xrdp_mcs_recv_edrq(struct xrdp_mcs* self)
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
static int APP_CC
|
||||
xrdp_mcs_recv_aurq(struct xrdp_mcs* self)
|
||||
xrdp_mcs_recv_aurq(struct xrdp_mcs *self)
|
||||
{
|
||||
int opcode;
|
||||
struct stream* s;
|
||||
struct stream *s;
|
||||
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
|
||||
if (xrdp_iso_recv(self->iso_layer, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint8(s, opcode);
|
||||
|
||||
if ((opcode >> 2) != MCS_AURQ)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (opcode & 2)
|
||||
{
|
||||
in_uint16_be(s, self->userid);
|
||||
}
|
||||
|
||||
if (!(s_check_end(s)))
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
return 0;
|
||||
}
|
||||
@@ -390,29 +441,33 @@ xrdp_mcs_recv_aurq(struct xrdp_mcs* self)
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
static int APP_CC
|
||||
xrdp_mcs_send_aucf(struct xrdp_mcs* self)
|
||||
xrdp_mcs_send_aucf(struct xrdp_mcs *self)
|
||||
{
|
||||
struct stream* s;
|
||||
struct stream *s;
|
||||
|
||||
DEBUG((" in xrdp_mcs_send_aucf"));
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
|
||||
if (xrdp_iso_init(self->iso_layer, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
DEBUG((" out xrdp_mcs_send_aucf error"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
out_uint8(s, ((MCS_AUCF << 2) | 2));
|
||||
out_uint8s(s, 1);
|
||||
out_uint16_be(s, self->userid);
|
||||
s_mark_end(s);
|
||||
|
||||
if (xrdp_iso_send(self->iso_layer, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
DEBUG((" out xrdp_mcs_send_aucf error"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
DEBUG((" out xrdp_mcs_send_aucf"));
|
||||
return 0;
|
||||
@@ -421,34 +476,41 @@ xrdp_mcs_send_aucf(struct xrdp_mcs* self)
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
static int APP_CC
|
||||
xrdp_mcs_recv_cjrq(struct xrdp_mcs* self)
|
||||
xrdp_mcs_recv_cjrq(struct xrdp_mcs *self)
|
||||
{
|
||||
int opcode;
|
||||
struct stream* s;
|
||||
struct stream *s;
|
||||
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
|
||||
if (xrdp_iso_recv(self->iso_layer, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint8(s, opcode);
|
||||
|
||||
if ((opcode >> 2) != MCS_CJRQ)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint8s(s, 4);
|
||||
|
||||
if (opcode & 2)
|
||||
{
|
||||
in_uint8s(s, 2);
|
||||
}
|
||||
|
||||
if (!(s_check_end(s)))
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
return 0;
|
||||
}
|
||||
@@ -456,7 +518,7 @@ xrdp_mcs_recv_cjrq(struct xrdp_mcs* self)
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
static int APP_CC
|
||||
xrdp_mcs_ber_out_header(struct xrdp_mcs* self, struct stream* s,
|
||||
xrdp_mcs_ber_out_header(struct xrdp_mcs *self, struct stream *s,
|
||||
int tag_val, int len)
|
||||
{
|
||||
if (tag_val > 0xff)
|
||||
@@ -467,6 +529,7 @@ xrdp_mcs_ber_out_header(struct xrdp_mcs* self, struct stream* s,
|
||||
{
|
||||
out_uint8(s, tag_val);
|
||||
}
|
||||
|
||||
if (len >= 0x80)
|
||||
{
|
||||
out_uint8(s, 0x82);
|
||||
@@ -476,13 +539,14 @@ xrdp_mcs_ber_out_header(struct xrdp_mcs* self, struct stream* s,
|
||||
{
|
||||
out_uint8(s, len);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
static int APP_CC
|
||||
xrdp_mcs_ber_out_int8(struct xrdp_mcs* self, struct stream* s, int value)
|
||||
xrdp_mcs_ber_out_int8(struct xrdp_mcs *self, struct stream *s, int value)
|
||||
{
|
||||
xrdp_mcs_ber_out_header(self, s, BER_TAG_INTEGER, 1);
|
||||
out_uint8(s, value);
|
||||
@@ -493,7 +557,7 @@ xrdp_mcs_ber_out_int8(struct xrdp_mcs* self, struct stream* s, int value)
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
static int APP_CC
|
||||
xrdp_mcs_ber_out_int16(struct xrdp_mcs* self, struct stream* s, int value)
|
||||
xrdp_mcs_ber_out_int16(struct xrdp_mcs *self, struct stream *s, int value)
|
||||
{
|
||||
xrdp_mcs_ber_out_header(self, s, BER_TAG_INTEGER, 2);
|
||||
out_uint8(s, (value >> 8));
|
||||
@@ -505,7 +569,7 @@ xrdp_mcs_ber_out_int16(struct xrdp_mcs* self, struct stream* s, int value)
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
static int APP_CC
|
||||
xrdp_mcs_ber_out_int24(struct xrdp_mcs* self, struct stream* s, int value)
|
||||
xrdp_mcs_ber_out_int24(struct xrdp_mcs *self, struct stream *s, int value)
|
||||
{
|
||||
xrdp_mcs_ber_out_header(self, s, BER_TAG_INTEGER, 3);
|
||||
out_uint8(s, (value >> 16));
|
||||
@@ -517,7 +581,7 @@ xrdp_mcs_ber_out_int24(struct xrdp_mcs* self, struct stream* s, int value)
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
static int APP_CC
|
||||
xrdp_mcs_out_domain_params(struct xrdp_mcs* self, struct stream* s,
|
||||
xrdp_mcs_out_domain_params(struct xrdp_mcs *self, struct stream *s,
|
||||
int max_channels,
|
||||
int max_users, int max_tokens,
|
||||
int max_pdu_size)
|
||||
@@ -537,10 +601,10 @@ xrdp_mcs_out_domain_params(struct xrdp_mcs* self, struct stream* s,
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
static int APP_CC
|
||||
xrdp_mcs_send_connect_response(struct xrdp_mcs* self)
|
||||
xrdp_mcs_send_connect_response(struct xrdp_mcs *self)
|
||||
{
|
||||
int data_len;
|
||||
struct stream* s;
|
||||
struct stream *s;
|
||||
|
||||
DEBUG((" in xrdp_mcs_send_connect_response"));
|
||||
make_stream(s);
|
||||
@@ -557,12 +621,14 @@ xrdp_mcs_send_connect_response(struct xrdp_mcs* self)
|
||||
/* mcs data */
|
||||
out_uint8a(s, self->server_mcs_data->data, data_len);
|
||||
s_mark_end(s);
|
||||
|
||||
if (xrdp_iso_send(self->iso_layer, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
DEBUG((" out xrdp_mcs_send_connect_response error"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
DEBUG((" out xrdp_mcs_send_connect_response"));
|
||||
return 0;
|
||||
@@ -571,60 +637,73 @@ xrdp_mcs_send_connect_response(struct xrdp_mcs* self)
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
int APP_CC
|
||||
xrdp_mcs_incoming(struct xrdp_mcs* self)
|
||||
xrdp_mcs_incoming(struct xrdp_mcs *self)
|
||||
{
|
||||
DEBUG((" in xrdp_mcs_incoming"));
|
||||
|
||||
if (xrdp_iso_incoming(self->iso_layer) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (xrdp_mcs_recv_connect_initial(self) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* in xrdp_sec.c */
|
||||
if (xrdp_sec_process_mcs_data(self->sec_layer) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* in xrdp_sec.c */
|
||||
if (xrdp_sec_out_mcs_data(self->sec_layer) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (xrdp_mcs_send_connect_response(self) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (xrdp_mcs_recv_edrq(self) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (xrdp_mcs_recv_aurq(self) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (xrdp_mcs_send_aucf(self) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (xrdp_mcs_recv_cjrq(self) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (xrdp_mcs_send_cjcf(self, self->userid,
|
||||
self->userid + MCS_USERCHANNEL_BASE) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (xrdp_mcs_recv_cjrq(self) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (xrdp_mcs_send_cjcf(self, self->userid, MCS_GLOBAL_CHANNEL) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
DEBUG((" out xrdp_mcs_incoming"));
|
||||
return 0;
|
||||
}
|
||||
@@ -632,7 +711,7 @@ xrdp_mcs_incoming(struct xrdp_mcs* self)
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
int APP_CC
|
||||
xrdp_mcs_init(struct xrdp_mcs* self, struct stream* s)
|
||||
xrdp_mcs_init(struct xrdp_mcs *self, struct stream *s)
|
||||
{
|
||||
xrdp_iso_init(self->iso_layer, s);
|
||||
s_push_layer(s, mcs_hdr, 8);
|
||||
@@ -644,14 +723,15 @@ xrdp_mcs_init(struct xrdp_mcs* self, struct stream* s)
|
||||
/* Inform the callback that an mcs packet has been sent. This is needed so
|
||||
the module can send any high priority mcs packets like audio. */
|
||||
static int APP_CC
|
||||
xrdp_mcs_call_callback(struct xrdp_mcs* self)
|
||||
xrdp_mcs_call_callback(struct xrdp_mcs *self)
|
||||
{
|
||||
int rv;
|
||||
struct xrdp_session* session;
|
||||
struct xrdp_session *session;
|
||||
|
||||
rv = 0;
|
||||
/* if there is a callback, call it here */
|
||||
session = self->sec_layer->rdp_layer->session;
|
||||
|
||||
if (session != 0)
|
||||
{
|
||||
if (session->callback != 0)
|
||||
@@ -668,25 +748,28 @@ xrdp_mcs_call_callback(struct xrdp_mcs* self)
|
||||
{
|
||||
g_writeln("in xrdp_mcs_send, session is nil");
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
int APP_CC
|
||||
xrdp_mcs_send(struct xrdp_mcs* self, struct stream* s, int chan)
|
||||
xrdp_mcs_send(struct xrdp_mcs *self, struct stream *s, int chan)
|
||||
{
|
||||
int len;
|
||||
char* lp;
|
||||
char *lp;
|
||||
//static int max_len = 0;
|
||||
|
||||
DEBUG((" in xrdp_mcs_send"));
|
||||
s_pop_layer(s, mcs_hdr);
|
||||
len = (s->end - s->p) - 8;
|
||||
|
||||
if (len > 8192 * 2)
|
||||
{
|
||||
g_writeln("error in xrdp_mcs_send, size too bog, its %d", len);
|
||||
}
|
||||
|
||||
//if (len > max_len)
|
||||
//{
|
||||
// max_len = len;
|
||||
@@ -698,6 +781,7 @@ xrdp_mcs_send(struct xrdp_mcs* self, struct stream* s, int chan)
|
||||
out_uint16_be(s, self->userid);
|
||||
out_uint16_be(s, chan);
|
||||
out_uint8(s, 0x70);
|
||||
|
||||
if (len >= 128)
|
||||
{
|
||||
len = len | 0x8000;
|
||||
@@ -708,24 +792,29 @@ xrdp_mcs_send(struct xrdp_mcs* self, struct stream* s, int chan)
|
||||
out_uint8(s, len);
|
||||
/* move everything up one byte */
|
||||
lp = s->p;
|
||||
|
||||
while (lp < s->end)
|
||||
{
|
||||
lp[0] = lp[1];
|
||||
lp++;
|
||||
}
|
||||
|
||||
s->end--;
|
||||
}
|
||||
|
||||
if (xrdp_iso_send(self->iso_layer, s) != 0)
|
||||
{
|
||||
DEBUG((" out xrdp_mcs_send error"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* todo, do we need to call this for every mcs packet,
|
||||
maybe every 5 or so */
|
||||
if (chan == MCS_GLOBAL_CHANNEL)
|
||||
{
|
||||
xrdp_mcs_call_callback(self);
|
||||
}
|
||||
|
||||
DEBUG((" out xrdp_mcs_send"));
|
||||
return 0;
|
||||
}
|
||||
@@ -733,28 +822,32 @@ xrdp_mcs_send(struct xrdp_mcs* self, struct stream* s, int chan)
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
int APP_CC
|
||||
xrdp_mcs_disconnect(struct xrdp_mcs* self)
|
||||
xrdp_mcs_disconnect(struct xrdp_mcs *self)
|
||||
{
|
||||
struct stream* s;
|
||||
struct stream *s;
|
||||
|
||||
DEBUG((" in xrdp_mcs_disconnect"));
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
|
||||
if (xrdp_iso_init(self->iso_layer, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
DEBUG((" out xrdp_mcs_disconnect error"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
out_uint8(s, (MCS_DPUM << 2) | 1);
|
||||
out_uint8(s, 0x80);
|
||||
s_mark_end(s);
|
||||
|
||||
if (xrdp_iso_send(self->iso_layer, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
DEBUG((" out xrdp_mcs_disconnect error"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
DEBUG((" out xrdp_mcs_disconnect"));
|
||||
return 0;
|
||||
|
||||
+406
-113
File diff suppressed because it is too large
Load Diff
+72
-14
@@ -27,7 +27,7 @@
|
||||
/* RAIL */
|
||||
/* returns error */
|
||||
int APP_CC
|
||||
xrdp_orders_send_window_delete(struct xrdp_orders* self, int window_id)
|
||||
xrdp_orders_send_window_delete(struct xrdp_orders *self, int window_id)
|
||||
{
|
||||
int order_size;
|
||||
int order_flags;
|
||||
@@ -55,7 +55,7 @@ xrdp_orders_send_window_delete(struct xrdp_orders* self, int window_id)
|
||||
/* flags can contain WINDOW_ORDER_STATE_NEW and/or
|
||||
WINDOW_ORDER_FIELD_ICON_BIG */
|
||||
int APP_CC
|
||||
xrdp_orders_send_window_cached_icon(struct xrdp_orders* self,
|
||||
xrdp_orders_send_window_cached_icon(struct xrdp_orders *self,
|
||||
int window_id, int cache_entry,
|
||||
int cache_id, int flags)
|
||||
{
|
||||
@@ -88,12 +88,13 @@ xrdp_orders_send_window_cached_icon(struct xrdp_orders* self,
|
||||
/* RAIL */
|
||||
/* returns error */
|
||||
static int APP_CC
|
||||
xrdp_orders_send_ts_icon(struct stream* s, int cache_entry, int cache_id,
|
||||
struct rail_icon_info* icon_info)
|
||||
xrdp_orders_send_ts_icon(struct stream *s, int cache_entry, int cache_id,
|
||||
struct rail_icon_info *icon_info)
|
||||
{
|
||||
int use_cmap;
|
||||
|
||||
use_cmap = 0;
|
||||
|
||||
if ((icon_info->bpp == 1) || (icon_info->bpp == 2) || (icon_info->bpp == 4))
|
||||
{
|
||||
use_cmap = 1;
|
||||
@@ -105,17 +106,21 @@ xrdp_orders_send_ts_icon(struct stream* s, int cache_entry, int cache_id,
|
||||
out_uint8(s, icon_info->bpp);
|
||||
out_uint16_le(s, icon_info->width);
|
||||
out_uint16_le(s, icon_info->height);
|
||||
|
||||
if (use_cmap)
|
||||
{
|
||||
out_uint16_le(s, icon_info->cmap_bytes);
|
||||
}
|
||||
|
||||
out_uint16_le(s, icon_info->mask_bytes);
|
||||
out_uint16_le(s, icon_info->data_bytes);
|
||||
out_uint8p(s, icon_info->mask, icon_info->mask_bytes);
|
||||
|
||||
if (use_cmap)
|
||||
{
|
||||
out_uint8p(s, icon_info->cmap, icon_info->cmap_bytes);
|
||||
}
|
||||
|
||||
out_uint8p(s, icon_info->data, icon_info->data_bytes);
|
||||
return 0;
|
||||
}
|
||||
@@ -126,9 +131,9 @@ xrdp_orders_send_ts_icon(struct stream* s, int cache_entry, int cache_id,
|
||||
/* flags can contain WINDOW_ORDER_STATE_NEW and/or
|
||||
WINDOW_ORDER_FIELD_ICON_BIG */
|
||||
int APP_CC
|
||||
xrdp_orders_send_window_icon(struct xrdp_orders* self,
|
||||
xrdp_orders_send_window_icon(struct xrdp_orders *self,
|
||||
int window_id, int cache_entry, int cache_id,
|
||||
struct rail_icon_info* icon_info,
|
||||
struct rail_icon_info *icon_info,
|
||||
int flags)
|
||||
{
|
||||
int order_size;
|
||||
@@ -137,15 +142,19 @@ xrdp_orders_send_window_icon(struct xrdp_orders* self,
|
||||
int use_cmap;
|
||||
|
||||
use_cmap = 0;
|
||||
|
||||
if ((icon_info->bpp == 1) || (icon_info->bpp == 2) || (icon_info->bpp == 4))
|
||||
{
|
||||
use_cmap = 1;
|
||||
}
|
||||
|
||||
order_size = 23 + icon_info->mask_bytes + icon_info->data_bytes;
|
||||
|
||||
if (use_cmap)
|
||||
{
|
||||
order_size += icon_info->cmap_bytes + 2;
|
||||
}
|
||||
|
||||
xrdp_orders_check(self, order_size);
|
||||
self->order_count++;
|
||||
order_flags = RDP_ORDER_SECONDARY;
|
||||
@@ -168,7 +177,7 @@ xrdp_orders_send_window_icon(struct xrdp_orders* self,
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
static int APP_CC
|
||||
xrdp_orders_send_as_unicode(struct stream* s, const char* text)
|
||||
xrdp_orders_send_as_unicode(struct stream *s, const char *text)
|
||||
{
|
||||
int str_chars;
|
||||
int index;
|
||||
@@ -176,10 +185,12 @@ xrdp_orders_send_as_unicode(struct stream* s, const char* text)
|
||||
twchar wdst[256];
|
||||
|
||||
str_chars = g_mbstowcs(wdst, text, 255);
|
||||
|
||||
if (str_chars > 0)
|
||||
{
|
||||
i32 = str_chars * 2;
|
||||
out_uint16_le(s, i32);
|
||||
|
||||
for (index = 0; index < str_chars; index++)
|
||||
{
|
||||
i32 = wdst[index];
|
||||
@@ -190,6 +201,7 @@ xrdp_orders_send_as_unicode(struct stream* s, const char* text)
|
||||
{
|
||||
out_uint16_le(s, 0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -198,8 +210,8 @@ xrdp_orders_send_as_unicode(struct stream* s, const char* text)
|
||||
/* returns error */
|
||||
/* flags can contain WINDOW_ORDER_STATE_NEW */
|
||||
int APP_CC
|
||||
xrdp_orders_send_window_new_update(struct xrdp_orders* self, int window_id,
|
||||
struct rail_window_state_order* window_state,
|
||||
xrdp_orders_send_window_new_update(struct xrdp_orders *self, int window_id,
|
||||
struct rail_window_state_order *window_state,
|
||||
int flags)
|
||||
{
|
||||
int order_size;
|
||||
@@ -210,11 +222,13 @@ xrdp_orders_send_window_new_update(struct xrdp_orders* self, int window_id,
|
||||
|
||||
order_size = 11;
|
||||
field_present_flags = flags | WINDOW_ORDER_TYPE_WINDOW;
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_OWNER)
|
||||
{
|
||||
/* ownerWindowId (4 bytes) */
|
||||
order_size += 4;
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_STYLE)
|
||||
{
|
||||
/* style (4 bytes) */
|
||||
@@ -222,17 +236,20 @@ xrdp_orders_send_window_new_update(struct xrdp_orders* self, int window_id,
|
||||
/* extendedStyle (4 bytes) */
|
||||
order_size += 4;
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_SHOW)
|
||||
{
|
||||
/* showState (1 byte) */
|
||||
order_size += 1;
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_TITLE)
|
||||
{
|
||||
/* titleInfo */
|
||||
num_chars = g_mbstowcs(0, window_state->title_info, 0);
|
||||
order_size += 2 * num_chars + 2;
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_CLIENT_AREA_OFFSET)
|
||||
{
|
||||
/* clientOffsetX (4 bytes) */
|
||||
@@ -240,6 +257,7 @@ xrdp_orders_send_window_new_update(struct xrdp_orders* self, int window_id,
|
||||
/* clientOffsetY (4 bytes) */
|
||||
order_size += 4;
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_CLIENT_AREA_SIZE)
|
||||
{
|
||||
/* clientAreaWidth (4 bytes) */
|
||||
@@ -247,16 +265,19 @@ xrdp_orders_send_window_new_update(struct xrdp_orders* self, int window_id,
|
||||
/* clientAreaHeight (4 bytes) */
|
||||
order_size += 4;
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_RP_CONTENT)
|
||||
{
|
||||
/* RPContent (1 byte) */
|
||||
order_size += 1;
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_ROOT_PARENT)
|
||||
{
|
||||
/* rootParentHandle (4 bytes) */
|
||||
order_size += 4;
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_WND_OFFSET)
|
||||
{
|
||||
/* windowOffsetX (4 bytes) */
|
||||
@@ -264,6 +285,7 @@ xrdp_orders_send_window_new_update(struct xrdp_orders* self, int window_id,
|
||||
/* windowOffsetY (4 bytes) */
|
||||
order_size += 4;
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_WND_CLIENT_DELTA)
|
||||
{
|
||||
/* windowClientDeltaX (4 bytes) */
|
||||
@@ -271,6 +293,7 @@ xrdp_orders_send_window_new_update(struct xrdp_orders* self, int window_id,
|
||||
/* windowClientDeltaY (4 bytes) */
|
||||
order_size += 4;
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_WND_SIZE)
|
||||
{
|
||||
/* windowWidth (4 bytes) */
|
||||
@@ -278,12 +301,14 @@ xrdp_orders_send_window_new_update(struct xrdp_orders* self, int window_id,
|
||||
/* windowHeight (4 bytes) */
|
||||
order_size += 4;
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_WND_RECTS)
|
||||
{
|
||||
/* numWindowRects (2 bytes) */
|
||||
order_size += 2;
|
||||
order_size += 8 * window_state->num_window_rects;
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_VIS_OFFSET)
|
||||
{
|
||||
/* visibleOffsetX (4 bytes) */
|
||||
@@ -291,6 +316,7 @@ xrdp_orders_send_window_new_update(struct xrdp_orders* self, int window_id,
|
||||
/* visibleOffsetY (4 bytes) */
|
||||
order_size += 4;
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_VISIBILITY)
|
||||
{
|
||||
/* numVisibilityRects (2 bytes) */
|
||||
@@ -315,6 +341,7 @@ xrdp_orders_send_window_new_update(struct xrdp_orders* self, int window_id,
|
||||
/* ownerWindowId (4 bytes) */
|
||||
out_uint32_le(self->out_s, window_state->owner_window_id);
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_STYLE)
|
||||
{
|
||||
/* style (4 bytes) */
|
||||
@@ -322,16 +349,19 @@ xrdp_orders_send_window_new_update(struct xrdp_orders* self, int window_id,
|
||||
/* extendedStyle (4 bytes) */
|
||||
out_uint32_le(self->out_s, window_state->extended_style);
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_SHOW)
|
||||
{
|
||||
/* showState (1 byte) */
|
||||
out_uint8(self->out_s, window_state->show_state);
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_TITLE)
|
||||
{
|
||||
/* titleInfo */
|
||||
xrdp_orders_send_as_unicode(self->out_s, window_state->title_info);
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_CLIENT_AREA_OFFSET)
|
||||
{
|
||||
/* clientOffsetX (4 bytes) */
|
||||
@@ -339,6 +369,7 @@ xrdp_orders_send_window_new_update(struct xrdp_orders* self, int window_id,
|
||||
/* clientOffsetY (4 bytes) */
|
||||
out_uint32_le(self->out_s, window_state->client_offset_y);
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_CLIENT_AREA_SIZE)
|
||||
{
|
||||
/* clientAreaWidth (4 bytes) */
|
||||
@@ -346,16 +377,19 @@ xrdp_orders_send_window_new_update(struct xrdp_orders* self, int window_id,
|
||||
/* clientAreaHeight (4 bytes) */
|
||||
out_uint32_le(self->out_s, window_state->client_area_height);
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_RP_CONTENT)
|
||||
{
|
||||
/* RPContent (1 byte) */
|
||||
out_uint8(self->out_s, window_state->rp_content);
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_ROOT_PARENT)
|
||||
{
|
||||
/* rootParentHandle (4 bytes) */
|
||||
out_uint32_le(self->out_s, window_state->root_parent_handle);
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_WND_OFFSET)
|
||||
{
|
||||
/* windowOffsetX (4 bytes) */
|
||||
@@ -363,6 +397,7 @@ xrdp_orders_send_window_new_update(struct xrdp_orders* self, int window_id,
|
||||
/* windowOffsetY (4 bytes) */
|
||||
out_uint32_le(self->out_s, window_state->window_offset_y);
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_WND_CLIENT_DELTA)
|
||||
{
|
||||
/* windowClientDeltaX (4 bytes) */
|
||||
@@ -370,6 +405,7 @@ xrdp_orders_send_window_new_update(struct xrdp_orders* self, int window_id,
|
||||
/* windowClientDeltaY (4 bytes) */
|
||||
out_uint32_le(self->out_s, window_state->window_client_delta_y);
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_WND_SIZE)
|
||||
{
|
||||
/* windowWidth (4 bytes) */
|
||||
@@ -377,10 +413,12 @@ xrdp_orders_send_window_new_update(struct xrdp_orders* self, int window_id,
|
||||
/* windowHeight (4 bytes) */
|
||||
out_uint32_le(self->out_s, window_state->window_height);
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_WND_RECTS)
|
||||
{
|
||||
/* numWindowRects (2 bytes) */
|
||||
out_uint16_le(self->out_s, window_state->num_window_rects);
|
||||
|
||||
for (index = 0; index < window_state->num_window_rects; index++)
|
||||
{
|
||||
out_uint16_le(self->out_s, window_state->window_rects[index].left);
|
||||
@@ -389,6 +427,7 @@ xrdp_orders_send_window_new_update(struct xrdp_orders* self, int window_id,
|
||||
out_uint16_le(self->out_s, window_state->window_rects[index].bottom);
|
||||
}
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_VIS_OFFSET)
|
||||
{
|
||||
/* visibleOffsetX (4 bytes) */
|
||||
@@ -396,10 +435,12 @@ xrdp_orders_send_window_new_update(struct xrdp_orders* self, int window_id,
|
||||
/* visibleOffsetY (4 bytes) */
|
||||
out_uint32_le(self->out_s, window_state->visible_offset_y);
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_VISIBILITY)
|
||||
{
|
||||
/* numVisibilityRects (2 bytes) */
|
||||
out_uint16_le(self->out_s, window_state->num_visibility_rects);
|
||||
|
||||
for (index = 0; index < window_state->num_visibility_rects; index++)
|
||||
{
|
||||
out_uint16_le(self->out_s, window_state->visibility_rects[index].left);
|
||||
@@ -416,7 +457,7 @@ xrdp_orders_send_window_new_update(struct xrdp_orders* self, int window_id,
|
||||
/* RAIL */
|
||||
/* returns error */
|
||||
int APP_CC
|
||||
xrdp_orders_send_notify_delete(struct xrdp_orders* self, int window_id,
|
||||
xrdp_orders_send_notify_delete(struct xrdp_orders *self, int window_id,
|
||||
int notify_id)
|
||||
{
|
||||
int order_size;
|
||||
@@ -446,9 +487,9 @@ xrdp_orders_send_notify_delete(struct xrdp_orders* self, int window_id,
|
||||
/* returns error */
|
||||
/* flags can contain WINDOW_ORDER_STATE_NEW */
|
||||
int APP_CC
|
||||
xrdp_orders_send_notify_new_update(struct xrdp_orders* self,
|
||||
xrdp_orders_send_notify_new_update(struct xrdp_orders *self,
|
||||
int window_id, int notify_id,
|
||||
struct rail_notify_state_order* notify_state,
|
||||
struct rail_notify_state_order *notify_state,
|
||||
int flags)
|
||||
{
|
||||
int order_size;
|
||||
@@ -459,17 +500,20 @@ xrdp_orders_send_notify_new_update(struct xrdp_orders* self,
|
||||
|
||||
order_size = 15;
|
||||
field_present_flags = flags | WINDOW_ORDER_TYPE_NOTIFY;
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_NOTIFY_VERSION)
|
||||
{
|
||||
/* Version (4 bytes) */
|
||||
order_size += 4;
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_NOTIFY_TIP)
|
||||
{
|
||||
/* ToolTip (variable) UNICODE_STRING */
|
||||
num_chars = g_mbstowcs(0, notify_state->tool_tip, 0);
|
||||
order_size += 2 * num_chars + 2;
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_NOTIFY_INFO_TIP)
|
||||
{
|
||||
/* InfoTip (variable) TS_NOTIFY_ICON_INFOTIP */
|
||||
@@ -483,27 +527,33 @@ xrdp_orders_send_notify_new_update(struct xrdp_orders* self,
|
||||
/* InfoFlags (4 bytes) */
|
||||
order_size += 8;
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_NOTIFY_STATE)
|
||||
{
|
||||
/* State (4 bytes) */
|
||||
order_size += 4;
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_ICON)
|
||||
{
|
||||
/* Icon (variable) */
|
||||
use_cmap = 0;
|
||||
|
||||
if ((notify_state->icon_info.bpp == 1) || (notify_state->icon_info.bpp == 2) ||
|
||||
(notify_state->icon_info.bpp == 4))
|
||||
{
|
||||
use_cmap = 1;
|
||||
}
|
||||
|
||||
order_size += 12 + notify_state->icon_info.mask_bytes +
|
||||
notify_state->icon_info.data_bytes;
|
||||
|
||||
if (use_cmap)
|
||||
{
|
||||
order_size += notify_state->icon_info.cmap_bytes + 2;
|
||||
}
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_CACHED_ICON)
|
||||
{
|
||||
/* CachedIcon (3 bytes) */
|
||||
@@ -529,11 +579,13 @@ xrdp_orders_send_notify_new_update(struct xrdp_orders* self,
|
||||
/* Version (4 bytes) */
|
||||
out_uint32_le(self->out_s, notify_state->version);
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_NOTIFY_TIP)
|
||||
{
|
||||
/* ToolTip (variable) UNICODE_STRING */
|
||||
xrdp_orders_send_as_unicode(self->out_s, notify_state->tool_tip);
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_NOTIFY_INFO_TIP)
|
||||
{
|
||||
/* InfoTip (variable) TS_NOTIFY_ICON_INFOTIP */
|
||||
@@ -542,11 +594,13 @@ xrdp_orders_send_notify_new_update(struct xrdp_orders* self,
|
||||
xrdp_orders_send_as_unicode(self->out_s, notify_state->infotip.text);
|
||||
xrdp_orders_send_as_unicode(self->out_s, notify_state->infotip.title);
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_NOTIFY_STATE)
|
||||
{
|
||||
/* State (4 bytes) */
|
||||
out_uint32_le(self->out_s, notify_state->state);
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_ICON)
|
||||
{
|
||||
/* Icon (variable) */
|
||||
@@ -554,6 +608,7 @@ xrdp_orders_send_notify_new_update(struct xrdp_orders* self,
|
||||
notify_state->icon_cache_id,
|
||||
¬ify_state->icon_info);
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_CACHED_ICON)
|
||||
{
|
||||
/* CacheEntry (2 bytes) */
|
||||
@@ -570,8 +625,8 @@ xrdp_orders_send_notify_new_update(struct xrdp_orders* self,
|
||||
/* returns error */
|
||||
/* used for both Non-Monitored Desktop and Actively Monitored Desktop */
|
||||
int APP_CC
|
||||
xrdp_orders_send_monitored_desktop(struct xrdp_orders* self,
|
||||
struct rail_monitored_desktop_order* mdo,
|
||||
xrdp_orders_send_monitored_desktop(struct xrdp_orders *self,
|
||||
struct rail_monitored_desktop_order *mdo,
|
||||
int flags)
|
||||
{
|
||||
int order_size;
|
||||
@@ -587,6 +642,7 @@ xrdp_orders_send_monitored_desktop(struct xrdp_orders* self,
|
||||
/* ActiveWindowId (4 bytes) */
|
||||
order_size += 4;
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_DESKTOP_ZORDER)
|
||||
{
|
||||
/* NumWindowIds (1 byte) */
|
||||
@@ -610,10 +666,12 @@ xrdp_orders_send_monitored_desktop(struct xrdp_orders* self,
|
||||
/* ActiveWindowId (4 bytes) */
|
||||
out_uint32_le(self->out_s, mdo->active_window_id);
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_DESKTOP_ZORDER)
|
||||
{
|
||||
/* NumWindowIds (1 byte) */
|
||||
out_uint8(self->out_s, mdo->num_window_ids);
|
||||
|
||||
/* WindowIds (variable) */
|
||||
for (index = 0; index < mdo->num_window_ids; index++)
|
||||
{
|
||||
|
||||
+178
-97
@@ -1,24 +1,22 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2004-2010
|
||||
|
||||
rdp layer
|
||||
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* rdp layer
|
||||
*/
|
||||
|
||||
#include "libxrdp.h"
|
||||
|
||||
@@ -29,7 +27,8 @@
|
||||
|
||||
/* some compilers need unsigned char to avoid warnings */
|
||||
static tui8 g_unknown1[172] =
|
||||
{ 0xff, 0x02, 0xb6, 0x00, 0x28, 0x00, 0x00, 0x00,
|
||||
{
|
||||
0xff, 0x02, 0xb6, 0x00, 0x28, 0x00, 0x00, 0x00,
|
||||
0x27, 0x00, 0x27, 0x00, 0x03, 0x00, 0x04, 0x00,
|
||||
0x00, 0x00, 0x26, 0x00, 0x01, 0x00, 0x1e, 0x00,
|
||||
0x02, 0x00, 0x1f, 0x00, 0x03, 0x00, 0x1d, 0x00,
|
||||
@@ -50,7 +49,8 @@ static tui8 g_unknown1[172] =
|
||||
0x25, 0x00, 0x09, 0x00, 0x26, 0x00, 0x04, 0x00,
|
||||
0x27, 0x00, 0x03, 0x00, 0x28, 0x00, 0x02, 0x00,
|
||||
0x29, 0x00, 0x01, 0x00, 0x2a, 0x00, 0x05, 0x00,
|
||||
0x2b, 0x00, 0x2a, 0x00 };
|
||||
0x2b, 0x00, 0x2a, 0x00
|
||||
};
|
||||
|
||||
/* some compilers need unsigned char to avoid warnings */
|
||||
/*
|
||||
@@ -60,17 +60,17 @@ static tui8 g_unknown2[8] =
|
||||
|
||||
/*****************************************************************************/
|
||||
static int APP_CC
|
||||
xrdp_rdp_read_config(struct xrdp_client_info* client_info)
|
||||
xrdp_rdp_read_config(struct xrdp_client_info *client_info)
|
||||
{
|
||||
int index = 0;
|
||||
struct list* items = (struct list *)NULL;
|
||||
struct list* values = (struct list *)NULL;
|
||||
char* item = (char *)NULL;
|
||||
char* value = (char *)NULL;
|
||||
struct list *items = (struct list *)NULL;
|
||||
struct list *values = (struct list *)NULL;
|
||||
char *item = (char *)NULL;
|
||||
char *value = (char *)NULL;
|
||||
char cfg_file[256];
|
||||
|
||||
/* initialize (zero out) local variables: */
|
||||
g_memset(cfg_file,0,sizeof(char) * 256);
|
||||
g_memset(cfg_file, 0, sizeof(char) * 256);
|
||||
|
||||
items = list_create();
|
||||
items->auto_free = 1;
|
||||
@@ -78,10 +78,12 @@ xrdp_rdp_read_config(struct xrdp_client_info* client_info)
|
||||
values->auto_free = 1;
|
||||
g_snprintf(cfg_file, 255, "%s/xrdp.ini", XRDP_CFG_PATH);
|
||||
file_by_name_read_section(cfg_file, "globals", items, values);
|
||||
|
||||
for (index = 0; index < items->count; index++)
|
||||
{
|
||||
item = (char*)list_get_item(items, index);
|
||||
value = (char*)list_get_item(values, index);
|
||||
item = (char *)list_get_item(items, index);
|
||||
value = (char *)list_get_item(values, index);
|
||||
|
||||
if (g_strcasecmp(item, "bitmap_cache") == 0)
|
||||
{
|
||||
if ((g_strcasecmp(value, "yes") == 0) ||
|
||||
@@ -139,6 +141,7 @@ xrdp_rdp_read_config(struct xrdp_client_info* client_info)
|
||||
client_info->max_bpp = g_atoi(value);
|
||||
}
|
||||
}
|
||||
|
||||
list_delete(items);
|
||||
list_delete(values);
|
||||
return 0;
|
||||
@@ -147,7 +150,7 @@ xrdp_rdp_read_config(struct xrdp_client_info* client_info)
|
||||
#if defined(XRDP_FREERDP1)
|
||||
/*****************************************************************************/
|
||||
static void
|
||||
cpuid(tui32 info, tui32* eax, tui32* ebx, tui32* ecx, tui32* edx)
|
||||
cpuid(tui32 info, tui32 *eax, tui32 *ebx, tui32 *ecx, tui32 *edx)
|
||||
{
|
||||
#ifdef __GNUC__
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
@@ -199,14 +202,14 @@ xrdp_rdp_detect_cpu(void)
|
||||
#endif
|
||||
|
||||
/*****************************************************************************/
|
||||
struct xrdp_rdp* APP_CC
|
||||
xrdp_rdp_create(struct xrdp_session* session, struct trans* trans)
|
||||
struct xrdp_rdp *APP_CC
|
||||
xrdp_rdp_create(struct xrdp_session *session, struct trans *trans)
|
||||
{
|
||||
struct xrdp_rdp* self = (struct xrdp_rdp *)NULL;
|
||||
struct xrdp_rdp *self = (struct xrdp_rdp *)NULL;
|
||||
int bytes;
|
||||
|
||||
DEBUG(("in xrdp_rdp_create"));
|
||||
self = (struct xrdp_rdp*)g_malloc(sizeof(struct xrdp_rdp), 1);
|
||||
self = (struct xrdp_rdp *)g_malloc(sizeof(struct xrdp_rdp), 1);
|
||||
self->session = session;
|
||||
self->share_id = 66538;
|
||||
/* read ini settings */
|
||||
@@ -236,40 +239,43 @@ xrdp_rdp_create(struct xrdp_session* session, struct trans* trans)
|
||||
|
||||
/*****************************************************************************/
|
||||
void APP_CC
|
||||
xrdp_rdp_delete(struct xrdp_rdp* self)
|
||||
xrdp_rdp_delete(struct xrdp_rdp *self)
|
||||
{
|
||||
if (self == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
xrdp_sec_delete(self->sec_layer);
|
||||
#if defined(XRDP_FREERDP1)
|
||||
mppc_enc_free((struct rdp_mppc_enc*)(self->mppc_enc));
|
||||
rfx_context_free((RFX_CONTEXT*)(self->rfx_enc));
|
||||
mppc_enc_free((struct rdp_mppc_enc *)(self->mppc_enc));
|
||||
rfx_context_free((RFX_CONTEXT *)(self->rfx_enc));
|
||||
#endif
|
||||
g_free(self);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
int APP_CC
|
||||
xrdp_rdp_init(struct xrdp_rdp* self, struct stream* s)
|
||||
xrdp_rdp_init(struct xrdp_rdp *self, struct stream *s)
|
||||
{
|
||||
if (xrdp_sec_init(self->sec_layer, s) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
s_push_layer(s, rdp_hdr, 6);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
int APP_CC
|
||||
xrdp_rdp_init_data(struct xrdp_rdp* self, struct stream* s)
|
||||
xrdp_rdp_init_data(struct xrdp_rdp *self, struct stream *s)
|
||||
{
|
||||
if (xrdp_sec_init(self->sec_layer, s) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
s_push_layer(s, rdp_hdr, 18);
|
||||
return 0;
|
||||
}
|
||||
@@ -277,7 +283,7 @@ xrdp_rdp_init_data(struct xrdp_rdp* self, struct stream* s)
|
||||
/*****************************************************************************/
|
||||
/* returns erros */
|
||||
int APP_CC
|
||||
xrdp_rdp_recv(struct xrdp_rdp* self, struct stream* s, int* code)
|
||||
xrdp_rdp_recv(struct xrdp_rdp *self, struct stream *s, int *code)
|
||||
{
|
||||
int error = 0;
|
||||
int len = 0;
|
||||
@@ -285,10 +291,12 @@ xrdp_rdp_recv(struct xrdp_rdp* self, struct stream* s, int* code)
|
||||
int chan = 0;
|
||||
|
||||
DEBUG(("in xrdp_rdp_recv"));
|
||||
|
||||
if (s->next_packet == 0 || s->next_packet >= s->end)
|
||||
{
|
||||
chan = 0;
|
||||
error = xrdp_sec_recv(self->sec_layer, s, &chan);
|
||||
|
||||
if (error == -1) /* special code for send demand active */
|
||||
{
|
||||
s->next_packet = 0;
|
||||
@@ -296,29 +304,33 @@ xrdp_rdp_recv(struct xrdp_rdp* self, struct stream* s, int* code)
|
||||
DEBUG(("out (1) xrdp_rdp_recv"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (error != 0)
|
||||
{
|
||||
DEBUG(("out xrdp_rdp_recv error"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ((chan != MCS_GLOBAL_CHANNEL) && (chan > 0))
|
||||
{
|
||||
if (chan > MCS_GLOBAL_CHANNEL)
|
||||
{
|
||||
if(xrdp_channel_process(self->sec_layer->chan_layer, s, chan)!=0)
|
||||
if (xrdp_channel_process(self->sec_layer->chan_layer, s, chan) != 0)
|
||||
{
|
||||
g_writeln("xrdp_channel_process returned unhandled error") ;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
g_writeln("Wrong channel Id to be handled by xrdp_channel_process %d",chan);
|
||||
g_writeln("Wrong channel Id to be handled by xrdp_channel_process %d", chan);
|
||||
}
|
||||
|
||||
s->next_packet = 0;
|
||||
*code = 0;
|
||||
DEBUG(("out (2) xrdp_rdp_recv"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
s->next_packet = s->p;
|
||||
}
|
||||
else
|
||||
@@ -326,6 +338,7 @@ xrdp_rdp_recv(struct xrdp_rdp* self, struct stream* s, int* code)
|
||||
DEBUG(("xrdp_rdp_recv stream not touched"))
|
||||
s->p = s->next_packet;
|
||||
}
|
||||
|
||||
if (!s_check_rem(s, 6))
|
||||
{
|
||||
s->next_packet = 0;
|
||||
@@ -350,7 +363,7 @@ xrdp_rdp_recv(struct xrdp_rdp* self, struct stream* s, int* code)
|
||||
|
||||
/*****************************************************************************/
|
||||
int APP_CC
|
||||
xrdp_rdp_send(struct xrdp_rdp* self, struct stream* s, int pdu_type)
|
||||
xrdp_rdp_send(struct xrdp_rdp *self, struct stream *s, int pdu_type)
|
||||
{
|
||||
int len = 0;
|
||||
|
||||
@@ -360,18 +373,20 @@ xrdp_rdp_send(struct xrdp_rdp* self, struct stream* s, int pdu_type)
|
||||
out_uint16_le(s, len);
|
||||
out_uint16_le(s, 0x10 | pdu_type);
|
||||
out_uint16_le(s, self->mcs_channel);
|
||||
|
||||
if (xrdp_sec_send(self->sec_layer, s, MCS_GLOBAL_CHANNEL) != 0)
|
||||
{
|
||||
DEBUG(("out xrdp_rdp_send error"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
DEBUG(("out xrdp_rdp_send"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
int APP_CC
|
||||
xrdp_rdp_send_data(struct xrdp_rdp* self, struct stream* s,
|
||||
xrdp_rdp_send_data(struct xrdp_rdp *self, struct stream *s,
|
||||
int data_pdu_type)
|
||||
{
|
||||
int len;
|
||||
@@ -387,7 +402,7 @@ xrdp_rdp_send_data(struct xrdp_rdp* self, struct stream* s,
|
||||
int rdp_offset;
|
||||
struct stream ls;
|
||||
#if defined(XRDP_FREERDP1)
|
||||
struct rdp_mppc_enc* mppc_enc;
|
||||
struct rdp_mppc_enc *mppc_enc;
|
||||
#endif
|
||||
|
||||
DEBUG(("in xrdp_rdp_send_data"));
|
||||
@@ -400,14 +415,17 @@ xrdp_rdp_send_data(struct xrdp_rdp* self, struct stream* s,
|
||||
clen = len;
|
||||
tocomplen = pdulen - 18;
|
||||
#if defined(XRDP_FREERDP1)
|
||||
|
||||
if (self->client_info.rdp_compression && self->session->up_and_running)
|
||||
{
|
||||
mppc_enc = (struct rdp_mppc_enc*)(self->mppc_enc);
|
||||
if (compress_rdp(mppc_enc, (tui8*)(s->p + 18), tocomplen))
|
||||
mppc_enc = (struct rdp_mppc_enc *)(self->mppc_enc);
|
||||
|
||||
if (compress_rdp(mppc_enc, (tui8 *)(s->p + 18), tocomplen))
|
||||
{
|
||||
DEBUG(("mppc_encode ok flags 0x%x bytes_in_opb %d historyOffset %d "
|
||||
"tocomplen %d", mppc_enc->flags, mppc_enc->bytes_in_opb,
|
||||
mppc_enc->historyOffset, tocomplen));
|
||||
|
||||
if (mppc_enc->flags & RDP_MPPC_COMPRESSED)
|
||||
{
|
||||
clen = mppc_enc->bytes_in_opb + 18;
|
||||
@@ -437,6 +455,7 @@ xrdp_rdp_send_data(struct xrdp_rdp* self, struct stream* s,
|
||||
g_writeln("mppc_encode not ok");
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
out_uint16_le(s, pdulen);
|
||||
out_uint16_le(s, pdutype);
|
||||
@@ -454,34 +473,39 @@ xrdp_rdp_send_data(struct xrdp_rdp* self, struct stream* s,
|
||||
DEBUG(("out xrdp_rdp_send_data error"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
DEBUG(("out xrdp_rdp_send_data"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
int APP_CC
|
||||
xrdp_rdp_send_data_update_sync(struct xrdp_rdp* self)
|
||||
xrdp_rdp_send_data_update_sync(struct xrdp_rdp *self)
|
||||
{
|
||||
struct stream * s = (struct stream *)NULL;
|
||||
struct stream *s = (struct stream *)NULL;
|
||||
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
DEBUG(("in xrdp_rdp_send_data_update_sync"));
|
||||
|
||||
if (xrdp_rdp_init_data(self, s) != 0)
|
||||
{
|
||||
DEBUG(("out xrdp_rdp_send_data_update_sync error"));
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
out_uint16_le(s, RDP_UPDATE_SYNCHRONIZE);
|
||||
out_uint8s(s, 2);
|
||||
s_mark_end(s);
|
||||
|
||||
if (xrdp_rdp_send_data(self, s, RDP_DATA_PDU_UPDATE) != 0)
|
||||
{
|
||||
DEBUG(("out xrdp_rdp_send_data_update_sync error"));
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
DEBUG(("out xrdp_rdp_send_data_update_sync"));
|
||||
free_stream(s);
|
||||
return 0;
|
||||
@@ -489,9 +513,9 @@ xrdp_rdp_send_data_update_sync(struct xrdp_rdp* self)
|
||||
|
||||
/*****************************************************************************/
|
||||
static int APP_CC
|
||||
xrdp_rdp_parse_client_mcs_data(struct xrdp_rdp* self)
|
||||
xrdp_rdp_parse_client_mcs_data(struct xrdp_rdp *self)
|
||||
{
|
||||
struct stream* p = (struct stream *)NULL;
|
||||
struct stream *p = (struct stream *)NULL;
|
||||
int i = 0;
|
||||
|
||||
p = &(self->sec_layer->client_mcs_data);
|
||||
@@ -502,15 +526,18 @@ xrdp_rdp_parse_client_mcs_data(struct xrdp_rdp* self)
|
||||
in_uint8s(p, 120);
|
||||
self->client_info.bpp = 8;
|
||||
in_uint16_le(p, i);
|
||||
|
||||
switch (i)
|
||||
{
|
||||
case 0xca01:
|
||||
in_uint8s(p, 6);
|
||||
in_uint8(p, i);
|
||||
|
||||
if (i > 8)
|
||||
{
|
||||
self->client_info.bpp = i;
|
||||
}
|
||||
|
||||
break;
|
||||
case 0xca02:
|
||||
self->client_info.bpp = 15;
|
||||
@@ -522,6 +549,7 @@ xrdp_rdp_parse_client_mcs_data(struct xrdp_rdp* self)
|
||||
self->client_info.bpp = 24;
|
||||
break;
|
||||
}
|
||||
|
||||
if (self->client_info.max_bpp > 0)
|
||||
{
|
||||
if (self->client_info.bpp > self->client_info.max_bpp)
|
||||
@@ -529,6 +557,7 @@ xrdp_rdp_parse_client_mcs_data(struct xrdp_rdp* self)
|
||||
self->client_info.bpp = self->client_info.max_bpp;
|
||||
}
|
||||
}
|
||||
|
||||
p->p = p->data;
|
||||
DEBUG(("client width %d, client height %d bpp %d",
|
||||
self->client_info.width, self->client_info.height,
|
||||
@@ -538,13 +567,15 @@ xrdp_rdp_parse_client_mcs_data(struct xrdp_rdp* self)
|
||||
|
||||
/*****************************************************************************/
|
||||
int APP_CC
|
||||
xrdp_rdp_incoming(struct xrdp_rdp* self)
|
||||
xrdp_rdp_incoming(struct xrdp_rdp *self)
|
||||
{
|
||||
DEBUG(("in xrdp_rdp_incoming"));
|
||||
|
||||
if (xrdp_sec_incoming(self->sec_layer) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
self->mcs_channel = self->sec_layer->mcs_layer->userid +
|
||||
MCS_USERCHANNEL_BASE;
|
||||
xrdp_rdp_parse_client_mcs_data(self);
|
||||
@@ -554,21 +585,22 @@ xrdp_rdp_incoming(struct xrdp_rdp* self)
|
||||
|
||||
/*****************************************************************************/
|
||||
int APP_CC
|
||||
xrdp_rdp_send_demand_active(struct xrdp_rdp* self)
|
||||
xrdp_rdp_send_demand_active(struct xrdp_rdp *self)
|
||||
{
|
||||
struct stream* s;
|
||||
struct stream *s;
|
||||
int caps_count;
|
||||
int caps_size;
|
||||
int codec_caps_count;
|
||||
int codec_caps_size;
|
||||
char* caps_count_ptr;
|
||||
char* caps_size_ptr;
|
||||
char* caps_ptr;
|
||||
char* codec_caps_count_ptr;
|
||||
char* codec_caps_size_ptr;
|
||||
char *caps_count_ptr;
|
||||
char *caps_size_ptr;
|
||||
char *caps_ptr;
|
||||
char *codec_caps_count_ptr;
|
||||
char *codec_caps_size_ptr;
|
||||
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
|
||||
if (xrdp_rdp_init(self, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
@@ -788,7 +820,7 @@ xrdp_rdp_send_demand_active(struct xrdp_rdp* self)
|
||||
|
||||
/*****************************************************************************/
|
||||
static int APP_CC
|
||||
xrdp_process_capset_general(struct xrdp_rdp* self, struct stream* s,
|
||||
xrdp_process_capset_general(struct xrdp_rdp *self, struct stream *s,
|
||||
int len)
|
||||
{
|
||||
int i;
|
||||
@@ -805,7 +837,7 @@ xrdp_process_capset_general(struct xrdp_rdp* self, struct stream* s,
|
||||
|
||||
/*****************************************************************************/
|
||||
static int APP_CC
|
||||
xrdp_process_capset_order(struct xrdp_rdp* self, struct stream* s,
|
||||
xrdp_process_capset_order(struct xrdp_rdp *self, struct stream *s,
|
||||
int len)
|
||||
{
|
||||
int i;
|
||||
@@ -843,11 +875,13 @@ xrdp_process_capset_order(struct xrdp_rdp* self, struct stream* s,
|
||||
in_uint8s(s, 2); /* Text capability flags */
|
||||
/* read extended order support flags */
|
||||
in_uint16_le(s, ex_flags); /* Ex flags */
|
||||
|
||||
if (ex_flags & XR_ORDERFLAGS_EX_CACHE_BITMAP_REV3_SUPPORT)
|
||||
{
|
||||
g_writeln("xrdp_process_capset_order: bitmap cache v3 supported");
|
||||
self->client_info.bitmap_cache_version |= 4;
|
||||
}
|
||||
|
||||
in_uint8s(s, 4); /* Pad */
|
||||
|
||||
in_uint32_le(s, i); /* desktop cache size, usually 0x38400 */
|
||||
@@ -861,7 +895,7 @@ xrdp_process_capset_order(struct xrdp_rdp* self, struct stream* s,
|
||||
/*****************************************************************************/
|
||||
/* get the bitmap cache size */
|
||||
static int APP_CC
|
||||
xrdp_process_capset_bmpcache(struct xrdp_rdp* self, struct stream* s,
|
||||
xrdp_process_capset_bmpcache(struct xrdp_rdp *self, struct stream *s,
|
||||
int len)
|
||||
{
|
||||
self->client_info.bitmap_cache_version |= 1;
|
||||
@@ -884,7 +918,7 @@ xrdp_process_capset_bmpcache(struct xrdp_rdp* self, struct stream* s,
|
||||
/*****************************************************************************/
|
||||
/* get the bitmap cache size */
|
||||
static int APP_CC
|
||||
xrdp_process_capset_bmpcache2(struct xrdp_rdp* self, struct stream* s,
|
||||
xrdp_process_capset_bmpcache2(struct xrdp_rdp *self, struct stream *s,
|
||||
int len)
|
||||
{
|
||||
int Bpp = 0;
|
||||
@@ -919,7 +953,7 @@ xrdp_process_capset_bmpcache2(struct xrdp_rdp* self, struct stream* s,
|
||||
|
||||
/*****************************************************************************/
|
||||
static int
|
||||
xrdp_process_capset_cache_v3_codec_id(struct xrdp_rdp* self, struct stream* s,
|
||||
xrdp_process_capset_cache_v3_codec_id(struct xrdp_rdp *self, struct stream *s,
|
||||
int len)
|
||||
{
|
||||
int codec_id;
|
||||
@@ -934,7 +968,7 @@ xrdp_process_capset_cache_v3_codec_id(struct xrdp_rdp* self, struct stream* s,
|
||||
/*****************************************************************************/
|
||||
/* get the number of client cursor cache */
|
||||
static int APP_CC
|
||||
xrdp_process_capset_pointercache(struct xrdp_rdp* self, struct stream* s,
|
||||
xrdp_process_capset_pointercache(struct xrdp_rdp *self, struct stream *s,
|
||||
int len)
|
||||
{
|
||||
int i;
|
||||
@@ -949,7 +983,7 @@ xrdp_process_capset_pointercache(struct xrdp_rdp* self, struct stream* s,
|
||||
/*****************************************************************************/
|
||||
/* get the type of client brush cache */
|
||||
static int APP_CC
|
||||
xrdp_process_capset_brushcache(struct xrdp_rdp* self, struct stream* s,
|
||||
xrdp_process_capset_brushcache(struct xrdp_rdp *self, struct stream *s,
|
||||
int len)
|
||||
{
|
||||
int code;
|
||||
@@ -961,7 +995,7 @@ xrdp_process_capset_brushcache(struct xrdp_rdp* self, struct stream* s,
|
||||
|
||||
/*****************************************************************************/
|
||||
static int APP_CC
|
||||
xrdp_process_offscreen_bmpcache(struct xrdp_rdp* self, struct stream* s,
|
||||
xrdp_process_offscreen_bmpcache(struct xrdp_rdp *self, struct stream *s,
|
||||
int len)
|
||||
{
|
||||
int i32;
|
||||
@@ -971,6 +1005,7 @@ xrdp_process_offscreen_bmpcache(struct xrdp_rdp* self, struct stream* s,
|
||||
g_writeln("xrdp_process_offscreen_bmpcache: bad len");
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint32_le(s, i32);
|
||||
self->client_info.offscreen_support_level = i32;
|
||||
in_uint16_le(s, i32);
|
||||
@@ -987,7 +1022,7 @@ xrdp_process_offscreen_bmpcache(struct xrdp_rdp* self, struct stream* s,
|
||||
|
||||
/*****************************************************************************/
|
||||
static int APP_CC
|
||||
xrdp_process_capset_rail(struct xrdp_rdp* self, struct stream* s, int len)
|
||||
xrdp_process_capset_rail(struct xrdp_rdp *self, struct stream *s, int len)
|
||||
{
|
||||
int i32;
|
||||
|
||||
@@ -996,6 +1031,7 @@ xrdp_process_capset_rail(struct xrdp_rdp* self, struct stream* s, int len)
|
||||
g_writeln("xrdp_process_capset_rail: bad len");
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint32_le(s, i32);
|
||||
self->client_info.rail_support_level = i32;
|
||||
g_writeln("xrdp_process_capset_rail: rail_support_level %d",
|
||||
@@ -1005,7 +1041,7 @@ xrdp_process_capset_rail(struct xrdp_rdp* self, struct stream* s, int len)
|
||||
|
||||
/*****************************************************************************/
|
||||
static int APP_CC
|
||||
xrdp_process_capset_window(struct xrdp_rdp* self, struct stream* s, int len)
|
||||
xrdp_process_capset_window(struct xrdp_rdp *self, struct stream *s, int len)
|
||||
{
|
||||
int i32;
|
||||
|
||||
@@ -1014,6 +1050,7 @@ xrdp_process_capset_window(struct xrdp_rdp* self, struct stream* s, int len)
|
||||
g_writeln("xrdp_process_capset_window: bad len");
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint32_le(s, i32);
|
||||
self->client_info.wnd_support_level = i32;
|
||||
in_uint8(s, i32);
|
||||
@@ -1030,17 +1067,18 @@ xrdp_process_capset_window(struct xrdp_rdp* self, struct stream* s, int len)
|
||||
|
||||
/*****************************************************************************/
|
||||
static int APP_CC
|
||||
xrdp_process_capset_codecs(struct xrdp_rdp* self, struct stream* s, int len)
|
||||
xrdp_process_capset_codecs(struct xrdp_rdp *self, struct stream *s, int len)
|
||||
{
|
||||
int codec_id;
|
||||
int codec_count;
|
||||
int index;
|
||||
int codec_properties_length;
|
||||
int i1;
|
||||
char* codec_guid;
|
||||
char* next_guid;
|
||||
char *codec_guid;
|
||||
char *next_guid;
|
||||
|
||||
in_uint8(s, codec_count);
|
||||
|
||||
for (index = 0; index < codec_count; index++)
|
||||
{
|
||||
codec_guid = s->p;
|
||||
@@ -1048,6 +1086,7 @@ xrdp_process_capset_codecs(struct xrdp_rdp* self, struct stream* s, int len)
|
||||
in_uint8(s, codec_id);
|
||||
in_uint16_le(s, codec_properties_length);
|
||||
next_guid = s->p + codec_properties_length;
|
||||
|
||||
if (g_memcmp(codec_guid, XR_CODEC_GUID_NSCODEC, 16) == 0)
|
||||
{
|
||||
g_writeln("xrdp_process_capset_codecs: nscodec codec id %d prop len %d",
|
||||
@@ -1080,14 +1119,16 @@ xrdp_process_capset_codecs(struct xrdp_rdp* self, struct stream* s, int len)
|
||||
{
|
||||
g_writeln("xrdp_process_capset_codecs: unknown codec id %d", codec_id);
|
||||
}
|
||||
|
||||
s->p = next_guid;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
int APP_CC
|
||||
xrdp_rdp_process_confirm_active(struct xrdp_rdp* self, struct stream* s)
|
||||
xrdp_rdp_process_confirm_active(struct xrdp_rdp *self, struct stream *s)
|
||||
{
|
||||
int cap_len;
|
||||
int source_len;
|
||||
@@ -1095,7 +1136,7 @@ xrdp_rdp_process_confirm_active(struct xrdp_rdp* self, struct stream* s)
|
||||
int index;
|
||||
int type;
|
||||
int len;
|
||||
char* p;
|
||||
char *p;
|
||||
|
||||
DEBUG(("in xrdp_rdp_process_confirm_active"));
|
||||
in_uint8s(s, 4); /* rdp_shareid */
|
||||
@@ -1105,11 +1146,13 @@ xrdp_rdp_process_confirm_active(struct xrdp_rdp* self, struct stream* s)
|
||||
in_uint8s(s, source_len);
|
||||
in_uint16_le(s, num_caps);
|
||||
in_uint8s(s, 2); /* pad */
|
||||
|
||||
for (index = 0; index < num_caps; index++)
|
||||
{
|
||||
p = s->p;
|
||||
in_uint16_le(s, type);
|
||||
in_uint16_le(s, len);
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case RDP_CAPSET_GENERAL: /* 1 */
|
||||
@@ -1194,15 +1237,17 @@ xrdp_rdp_process_confirm_active(struct xrdp_rdp* self, struct stream* s)
|
||||
g_writeln("unknown in xrdp_rdp_process_confirm_active %d", type);
|
||||
break;
|
||||
}
|
||||
|
||||
s->p = p + len;
|
||||
}
|
||||
|
||||
DEBUG(("out xrdp_rdp_process_confirm_active"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
static int APP_CC
|
||||
xrdp_rdp_process_data_pointer(struct xrdp_rdp* self, struct stream* s)
|
||||
xrdp_rdp_process_data_pointer(struct xrdp_rdp *self, struct stream *s)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -1210,7 +1255,7 @@ xrdp_rdp_process_data_pointer(struct xrdp_rdp* self, struct stream* s)
|
||||
/*****************************************************************************/
|
||||
/* RDP_DATA_PDU_INPUT */
|
||||
static int APP_CC
|
||||
xrdp_rdp_process_data_input(struct xrdp_rdp* self, struct stream* s)
|
||||
xrdp_rdp_process_data_input(struct xrdp_rdp *self, struct stream *s)
|
||||
{
|
||||
int num_events;
|
||||
int index;
|
||||
@@ -1223,6 +1268,7 @@ xrdp_rdp_process_data_input(struct xrdp_rdp* self, struct stream* s)
|
||||
in_uint16_le(s, num_events);
|
||||
in_uint8s(s, 2); /* pad */
|
||||
DEBUG(("in xrdp_rdp_process_data_input %d events", num_events));
|
||||
|
||||
for (index = 0; index < num_events; index++)
|
||||
{
|
||||
in_uint32_le(s, time);
|
||||
@@ -1232,6 +1278,7 @@ xrdp_rdp_process_data_input(struct xrdp_rdp* self, struct stream* s)
|
||||
in_sint16_le(s, param2);
|
||||
DEBUG(("xrdp_rdp_process_data_input event %4.4x flags %4.4x param1 %d \
|
||||
param2 %d time %d", msg_type, device_flags, param1, param2, time));
|
||||
|
||||
if (self->session->callback != 0)
|
||||
{
|
||||
/* msg_type can be
|
||||
@@ -1243,64 +1290,73 @@ param2 %d time %d", msg_type, device_flags, param1, param2, time));
|
||||
device_flags, time);
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG(("out xrdp_rdp_process_data_input"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
static int APP_CC
|
||||
xrdp_rdp_send_synchronise(struct xrdp_rdp* self)
|
||||
xrdp_rdp_send_synchronise(struct xrdp_rdp *self)
|
||||
{
|
||||
struct stream* s;
|
||||
struct stream *s;
|
||||
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
|
||||
if (xrdp_rdp_init_data(self, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
out_uint16_le(s, 1);
|
||||
out_uint16_le(s, 1002);
|
||||
s_mark_end(s);
|
||||
|
||||
if (xrdp_rdp_send_data(self, s, RDP_DATA_PDU_SYNCHRONISE) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
static int APP_CC
|
||||
xrdp_rdp_send_control(struct xrdp_rdp* self, int action)
|
||||
xrdp_rdp_send_control(struct xrdp_rdp *self, int action)
|
||||
{
|
||||
struct stream* s;
|
||||
struct stream *s;
|
||||
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
|
||||
if (xrdp_rdp_init_data(self, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
out_uint16_le(s, action);
|
||||
out_uint16_le(s, 0); /* userid */
|
||||
out_uint32_le(s, 1002); /* control id */
|
||||
s_mark_end(s);
|
||||
|
||||
if (xrdp_rdp_send_data(self, s, RDP_DATA_PDU_CONTROL) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
static int APP_CC
|
||||
xrdp_rdp_process_data_control(struct xrdp_rdp* self, struct stream* s)
|
||||
xrdp_rdp_process_data_control(struct xrdp_rdp *self, struct stream *s)
|
||||
{
|
||||
int action;
|
||||
|
||||
@@ -1308,6 +1364,7 @@ xrdp_rdp_process_data_control(struct xrdp_rdp* self, struct stream* s)
|
||||
in_uint16_le(s, action);
|
||||
in_uint8s(s, 2); /* user id */
|
||||
in_uint8s(s, 4); /* control id */
|
||||
|
||||
if (action == RDP_CTL_REQUEST_CONTROL)
|
||||
{
|
||||
DEBUG(("xrdp_rdp_process_data_control got RDP_CTL_REQUEST_CONTROL"));
|
||||
@@ -1322,12 +1379,13 @@ xrdp_rdp_process_data_control(struct xrdp_rdp* self, struct stream* s)
|
||||
{
|
||||
DEBUG(("xrdp_rdp_process_data_control unknown action"));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
static int APP_CC
|
||||
xrdp_rdp_process_data_sync(struct xrdp_rdp* self)
|
||||
xrdp_rdp_process_data_sync(struct xrdp_rdp *self)
|
||||
{
|
||||
DEBUG(("xrdp_rdp_process_data_sync"));
|
||||
return 0;
|
||||
@@ -1335,7 +1393,7 @@ xrdp_rdp_process_data_sync(struct xrdp_rdp* self)
|
||||
|
||||
/*****************************************************************************/
|
||||
static int APP_CC
|
||||
xrdp_rdp_process_screen_update(struct xrdp_rdp* self, struct stream* s)
|
||||
xrdp_rdp_process_screen_update(struct xrdp_rdp *self, struct stream *s)
|
||||
{
|
||||
int op;
|
||||
int left;
|
||||
@@ -1352,40 +1410,46 @@ xrdp_rdp_process_screen_update(struct xrdp_rdp* self, struct stream* s)
|
||||
in_uint16_le(s, bottom);
|
||||
cx = (right - left) + 1;
|
||||
cy = (bottom - top) + 1;
|
||||
|
||||
if (self->session->callback != 0)
|
||||
{
|
||||
self->session->callback(self->session->id, 0x4444, left, top, cx, cy);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
static int APP_CC
|
||||
xrdp_rdp_send_unknown1(struct xrdp_rdp* self)
|
||||
xrdp_rdp_send_unknown1(struct xrdp_rdp *self)
|
||||
{
|
||||
struct stream* s;
|
||||
struct stream *s;
|
||||
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
|
||||
if (xrdp_rdp_init_data(self, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
out_uint8a(s, g_unknown1, 172);
|
||||
s_mark_end(s);
|
||||
|
||||
if (xrdp_rdp_send_data(self, s, 0x28) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
static int APP_CC
|
||||
xrdp_rdp_process_data_font(struct xrdp_rdp* self, struct stream* s)
|
||||
xrdp_rdp_process_data_font(struct xrdp_rdp *self, struct stream *s)
|
||||
{
|
||||
int seq;
|
||||
|
||||
@@ -1393,16 +1457,19 @@ xrdp_rdp_process_data_font(struct xrdp_rdp* self, struct stream* s)
|
||||
in_uint8s(s, 2); /* num of fonts */
|
||||
in_uint8s(s, 2); /* unknown */
|
||||
in_uint16_le(s, seq);
|
||||
|
||||
/* 419 client sends Seq 1, then 2 */
|
||||
/* 2600 clients sends only Seq 3 */
|
||||
if (seq == 2 || seq == 3) /* after second font message, we are up and */
|
||||
{ /* running */
|
||||
{
|
||||
/* running */
|
||||
DEBUG(("sending unknown1"));
|
||||
xrdp_rdp_send_unknown1(self);
|
||||
self->session->up_and_running = 1;
|
||||
DEBUG(("up_and_running set"));
|
||||
xrdp_rdp_send_data_update_sync(self);
|
||||
}
|
||||
|
||||
DEBUG(("out xrdp_rdp_process_data_font"));
|
||||
return 0;
|
||||
}
|
||||
@@ -1410,23 +1477,27 @@ xrdp_rdp_process_data_font(struct xrdp_rdp* self, struct stream* s)
|
||||
/*****************************************************************************/
|
||||
/* sent 37 pdu */
|
||||
static int APP_CC
|
||||
xrdp_rdp_send_disconnect_query_response(struct xrdp_rdp* self)
|
||||
xrdp_rdp_send_disconnect_query_response(struct xrdp_rdp *self)
|
||||
{
|
||||
struct stream* s;
|
||||
struct stream *s;
|
||||
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
|
||||
if (xrdp_rdp_init_data(self, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
s_mark_end(s);
|
||||
|
||||
if (xrdp_rdp_send_data(self, s, 37) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
return 0;
|
||||
}
|
||||
@@ -1435,24 +1506,28 @@ xrdp_rdp_send_disconnect_query_response(struct xrdp_rdp* self)
|
||||
/*****************************************************************************/
|
||||
/* sent RDP_DATA_PDU_DISCONNECT 47 pdu */
|
||||
static int APP_CC
|
||||
xrdp_rdp_send_disconnect_reason(struct xrdp_rdp* self, int reason)
|
||||
xrdp_rdp_send_disconnect_reason(struct xrdp_rdp *self, int reason)
|
||||
{
|
||||
struct stream* s;
|
||||
struct stream *s;
|
||||
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
|
||||
if (xrdp_rdp_init_data(self, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
out_uint32_le(s, reason);
|
||||
s_mark_end(s);
|
||||
|
||||
if (xrdp_rdp_send_data(self, s, RDP_DATA_PDU_DISCONNECT) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
return 0;
|
||||
}
|
||||
@@ -1461,7 +1536,7 @@ xrdp_rdp_send_disconnect_reason(struct xrdp_rdp* self, int reason)
|
||||
/*****************************************************************************/
|
||||
/* RDP_PDU_DATA */
|
||||
int APP_CC
|
||||
xrdp_rdp_process_data(struct xrdp_rdp* self, struct stream* s)
|
||||
xrdp_rdp_process_data(struct xrdp_rdp *self, struct stream *s)
|
||||
{
|
||||
int len;
|
||||
int data_type;
|
||||
@@ -1474,6 +1549,7 @@ xrdp_rdp_process_data(struct xrdp_rdp* self, struct stream* s)
|
||||
in_uint8(s, ctype);
|
||||
in_uint16_le(s, clen);
|
||||
DEBUG(("xrdp_rdp_process_data code %d", data_type));
|
||||
|
||||
switch (data_type)
|
||||
{
|
||||
case RDP_DATA_PDU_POINTER: /* 27(0x1b) */
|
||||
@@ -1510,12 +1586,13 @@ xrdp_rdp_process_data(struct xrdp_rdp* self, struct stream* s)
|
||||
g_writeln("unknown in xrdp_rdp_process_data %d", data_type);
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
int APP_CC
|
||||
xrdp_rdp_disconnect(struct xrdp_rdp* self)
|
||||
xrdp_rdp_disconnect(struct xrdp_rdp *self)
|
||||
{
|
||||
int rv;
|
||||
|
||||
@@ -1527,26 +1604,30 @@ xrdp_rdp_disconnect(struct xrdp_rdp* self)
|
||||
|
||||
/*****************************************************************************/
|
||||
int APP_CC
|
||||
xrdp_rdp_send_deactive(struct xrdp_rdp* self)
|
||||
xrdp_rdp_send_deactive(struct xrdp_rdp *self)
|
||||
{
|
||||
struct stream* s;
|
||||
struct stream *s;
|
||||
|
||||
DEBUG(("in xrdp_rdp_send_deactive"));
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
|
||||
if (xrdp_rdp_init(self, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
DEBUG(("out xrdp_rdp_send_deactive error"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
s_mark_end(s);
|
||||
|
||||
if (xrdp_rdp_send(self, s, RDP_PDU_DEACTIVATE) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
DEBUG(("out xrdp_rdp_send_deactive error"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
DEBUG(("out xrdp_rdp_send_deactive"));
|
||||
return 0;
|
||||
|
||||
+204
-101
@@ -1,42 +1,45 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2004-2010
|
||||
|
||||
secure layer
|
||||
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* secure layer
|
||||
*/
|
||||
|
||||
#include "libxrdp.h"
|
||||
|
||||
/* some compilers need unsigned char to avoid warnings */
|
||||
static tui8 g_pad_54[40] =
|
||||
{ 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54,
|
||||
{
|
||||
54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54,
|
||||
54, 54, 54, 54, 54, 54, 54, 54 };
|
||||
54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54,
|
||||
54, 54, 54, 54, 54, 54, 54, 54
|
||||
};
|
||||
|
||||
/* some compilers need unsigned char to avoid warnings */
|
||||
static tui8 g_pad_92[48] =
|
||||
{ 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92,
|
||||
{
|
||||
92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92,
|
||||
92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92 };
|
||||
92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92,
|
||||
92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92
|
||||
};
|
||||
|
||||
/* some compilers need unsigned char to avoid warnings */
|
||||
static tui8 g_lic1[322] =
|
||||
{ 0x80, 0x00, 0x3e, 0x01, 0x01, 0x02, 0x3e, 0x01,
|
||||
{
|
||||
0x80, 0x00, 0x3e, 0x01, 0x01, 0x02, 0x3e, 0x01,
|
||||
0x7b, 0x3c, 0x31, 0xa6, 0xae, 0xe8, 0x74, 0xf6,
|
||||
0xb4, 0xa5, 0x03, 0x90, 0xe7, 0xc2, 0xc7, 0x39,
|
||||
0xba, 0x53, 0x1c, 0x30, 0x54, 0x6e, 0x90, 0x05,
|
||||
@@ -76,24 +79,29 @@ static tui8 g_lic1[322] =
|
||||
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||
0x0e, 0x00, 0x0e, 0x00, 0x6d, 0x69, 0x63, 0x72,
|
||||
0x6f, 0x73, 0x6f, 0x66, 0x74, 0x2e, 0x63, 0x6f,
|
||||
0x6d, 0x00 };
|
||||
0x6d, 0x00
|
||||
};
|
||||
|
||||
/* some compilers need unsigned char to avoid warnings */
|
||||
static tui8 g_lic2[20] =
|
||||
{ 0x80, 0x00, 0x10, 0x00, 0xff, 0x02, 0x10, 0x00,
|
||||
{
|
||||
0x80, 0x00, 0x10, 0x00, 0xff, 0x02, 0x10, 0x00,
|
||||
0x07, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
|
||||
0x28, 0x14, 0x00, 0x00 };
|
||||
0x28, 0x14, 0x00, 0x00
|
||||
};
|
||||
|
||||
/* mce */
|
||||
/* some compilers need unsigned char to avoid warnings */
|
||||
static tui8 g_lic3[20] =
|
||||
{ 0x80, 0x02, 0x10, 0x00, 0xff, 0x03, 0x10, 0x00,
|
||||
{
|
||||
0x80, 0x02, 0x10, 0x00, 0xff, 0x03, 0x10, 0x00,
|
||||
0x07, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
|
||||
0xf3, 0x99, 0x00, 0x00 };
|
||||
0xf3, 0x99, 0x00, 0x00
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
static void APP_CC
|
||||
hex_str_to_bin(char* in, char* out, int out_len)
|
||||
hex_str_to_bin(char *in, char *out, int out_len)
|
||||
{
|
||||
int in_index;
|
||||
int in_len;
|
||||
@@ -104,6 +112,7 @@ hex_str_to_bin(char* in, char* out, int out_len)
|
||||
in_len = g_strlen(in);
|
||||
out_index = 0;
|
||||
in_index = 0;
|
||||
|
||||
while (in_index <= (in_len - 4))
|
||||
{
|
||||
if ((in[in_index] == '0') && (in[in_index + 1] == 'x'))
|
||||
@@ -111,29 +120,33 @@ hex_str_to_bin(char* in, char* out, int out_len)
|
||||
hex[0] = in[in_index + 2];
|
||||
hex[1] = in[in_index + 3];
|
||||
hex[2] = 0;
|
||||
|
||||
if (out_index < out_len)
|
||||
{
|
||||
val = g_htoi(hex);
|
||||
out[out_index] = val;
|
||||
}
|
||||
|
||||
out_index++;
|
||||
}
|
||||
|
||||
in_index++;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
struct xrdp_sec* APP_CC
|
||||
xrdp_sec_create(struct xrdp_rdp* owner, struct trans* trans, int crypt_level,
|
||||
struct xrdp_sec *APP_CC
|
||||
xrdp_sec_create(struct xrdp_rdp *owner, struct trans *trans, int crypt_level,
|
||||
int channel_code)
|
||||
{
|
||||
struct xrdp_sec* self;
|
||||
struct xrdp_sec *self;
|
||||
|
||||
DEBUG((" in xrdp_sec_create"));
|
||||
self = (struct xrdp_sec*)g_malloc(sizeof(struct xrdp_sec), 1);
|
||||
self = (struct xrdp_sec *)g_malloc(sizeof(struct xrdp_sec), 1);
|
||||
self->rdp_layer = owner;
|
||||
self->rc4_key_size = 1; /* 1 = 40 bit, 2 = 128 bit */
|
||||
self->crypt_level = 1; /* 1, 2, 3 = low, medium, high */
|
||||
|
||||
switch (crypt_level)
|
||||
{
|
||||
case 1:
|
||||
@@ -152,16 +165,21 @@ xrdp_sec_create(struct xrdp_rdp* owner, struct trans* trans, int crypt_level,
|
||||
g_writeln("Fatal : Illegal crypt_level");
|
||||
break ;
|
||||
}
|
||||
|
||||
self->channel_code = channel_code;
|
||||
if(self->decrypt_rc4_info!=NULL)
|
||||
|
||||
if (self->decrypt_rc4_info != NULL)
|
||||
{
|
||||
g_writeln("xrdp_sec_create - decrypt_rc4_info already created !!!");
|
||||
}
|
||||
|
||||
self->decrypt_rc4_info = ssl_rc4_info_create();
|
||||
if(self->encrypt_rc4_info!=NULL)
|
||||
|
||||
if (self->encrypt_rc4_info != NULL)
|
||||
{
|
||||
g_writeln("xrdp_sec_create - encrypt_rc4_info already created !!!");
|
||||
}
|
||||
|
||||
self->encrypt_rc4_info = ssl_rc4_info_create();
|
||||
self->mcs_layer = xrdp_mcs_create(self, trans, &self->client_mcs_data,
|
||||
&self->server_mcs_data);
|
||||
@@ -172,13 +190,14 @@ xrdp_sec_create(struct xrdp_rdp* owner, struct trans* trans, int crypt_level,
|
||||
|
||||
/*****************************************************************************/
|
||||
void APP_CC
|
||||
xrdp_sec_delete(struct xrdp_sec* self)
|
||||
xrdp_sec_delete(struct xrdp_sec *self)
|
||||
{
|
||||
if (self == 0)
|
||||
{
|
||||
g_writeln("xrdp_sec_delete: indata is null");
|
||||
return;
|
||||
}
|
||||
|
||||
xrdp_channel_delete(self->chan_layer);
|
||||
xrdp_mcs_delete(self->mcs_layer);
|
||||
ssl_rc4_info_delete(self->decrypt_rc4_info); /* TODO clear all data */
|
||||
@@ -186,19 +205,20 @@ xrdp_sec_delete(struct xrdp_sec* self)
|
||||
g_free(self->client_mcs_data.data);
|
||||
g_free(self->server_mcs_data.data);
|
||||
/* Crypto information must always be cleared */
|
||||
g_memset(self,0,sizeof(struct xrdp_sec));
|
||||
g_memset(self, 0, sizeof(struct xrdp_sec));
|
||||
g_free(self);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
int APP_CC
|
||||
xrdp_sec_init(struct xrdp_sec* self, struct stream* s)
|
||||
xrdp_sec_init(struct xrdp_sec *self, struct stream *s)
|
||||
{
|
||||
if (xrdp_mcs_init(self->mcs_layer, s) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (self->crypt_level > 1)
|
||||
{
|
||||
s_push_layer(s, sec_hdr, 4 + 8);
|
||||
@@ -207,13 +227,14 @@ xrdp_sec_init(struct xrdp_sec* self, struct stream* s)
|
||||
{
|
||||
s_push_layer(s, sec_hdr, 4);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Reduce key entropy from 64 to 40 bits */
|
||||
static void APP_CC
|
||||
xrdp_sec_make_40bit(char* key)
|
||||
xrdp_sec_make_40bit(char *key)
|
||||
{
|
||||
key[0] = 0xd1;
|
||||
key[1] = 0x26;
|
||||
@@ -224,32 +245,34 @@ xrdp_sec_make_40bit(char* key)
|
||||
/* returns error */
|
||||
/* update an encryption key */
|
||||
static int APP_CC
|
||||
xrdp_sec_update(char* key, char* update_key, int key_len)
|
||||
xrdp_sec_update(char *key, char *update_key, int key_len)
|
||||
{
|
||||
char shasig[20];
|
||||
void* sha1_info;
|
||||
void* md5_info;
|
||||
void* rc4_info;
|
||||
void *sha1_info;
|
||||
void *md5_info;
|
||||
void *rc4_info;
|
||||
|
||||
sha1_info = ssl_sha1_info_create();
|
||||
md5_info = ssl_md5_info_create();
|
||||
rc4_info = ssl_rc4_info_create();
|
||||
ssl_sha1_clear(sha1_info);
|
||||
ssl_sha1_transform(sha1_info, update_key, key_len);
|
||||
ssl_sha1_transform(sha1_info, (char*)g_pad_54, 40);
|
||||
ssl_sha1_transform(sha1_info, (char *)g_pad_54, 40);
|
||||
ssl_sha1_transform(sha1_info, key, key_len);
|
||||
ssl_sha1_complete(sha1_info, shasig);
|
||||
ssl_md5_clear(md5_info);
|
||||
ssl_md5_transform(md5_info, update_key, key_len);
|
||||
ssl_md5_transform(md5_info, (char*)g_pad_92, 48);
|
||||
ssl_md5_transform(md5_info, (char *)g_pad_92, 48);
|
||||
ssl_md5_transform(md5_info, shasig, 20);
|
||||
ssl_md5_complete(md5_info, key);
|
||||
ssl_rc4_set_key(rc4_info, key, key_len);
|
||||
ssl_rc4_crypt(rc4_info, key, key_len);
|
||||
|
||||
if (key_len == 8)
|
||||
{
|
||||
xrdp_sec_make_40bit(key);
|
||||
}
|
||||
|
||||
ssl_sha1_info_delete(sha1_info);
|
||||
ssl_md5_info_delete(md5_info);
|
||||
ssl_rc4_info_delete(rc4_info);
|
||||
@@ -258,7 +281,7 @@ xrdp_sec_update(char* key, char* update_key, int key_len)
|
||||
|
||||
/*****************************************************************************/
|
||||
static void APP_CC
|
||||
xrdp_sec_decrypt(struct xrdp_sec* self, char* data, int len)
|
||||
xrdp_sec_decrypt(struct xrdp_sec *self, char *data, int len)
|
||||
{
|
||||
if (self->decrypt_use_count == 4096)
|
||||
{
|
||||
@@ -268,13 +291,14 @@ xrdp_sec_decrypt(struct xrdp_sec* self, char* data, int len)
|
||||
self->rc4_key_len);
|
||||
self->decrypt_use_count = 0;
|
||||
}
|
||||
|
||||
ssl_rc4_crypt(self->decrypt_rc4_info, data, len);
|
||||
self->decrypt_use_count++;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
static void APP_CC
|
||||
xrdp_sec_encrypt(struct xrdp_sec* self, char* data, int len)
|
||||
xrdp_sec_encrypt(struct xrdp_sec *self, char *data, int len)
|
||||
{
|
||||
if (self->encrypt_use_count == 4096)
|
||||
{
|
||||
@@ -284,30 +308,34 @@ xrdp_sec_encrypt(struct xrdp_sec* self, char* data, int len)
|
||||
self->rc4_key_len);
|
||||
self->encrypt_use_count = 0;
|
||||
}
|
||||
|
||||
ssl_rc4_crypt(self->encrypt_rc4_info, data, len);
|
||||
self->encrypt_use_count++;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
static int APP_CC
|
||||
unicode_in(struct stream* s, int uni_len, char* dst, int dst_len)
|
||||
unicode_in(struct stream *s, int uni_len, char *dst, int dst_len)
|
||||
{
|
||||
int dst_index;
|
||||
int src_index;
|
||||
|
||||
dst_index = 0;
|
||||
src_index = 0;
|
||||
|
||||
while (src_index < uni_len)
|
||||
{
|
||||
if (dst_index >= dst_len || src_index > 512)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
in_uint8(s, dst[dst_index]);
|
||||
in_uint8s(s, 1);
|
||||
dst_index++;
|
||||
src_index += 2;
|
||||
}
|
||||
|
||||
in_uint8s(s, 2);
|
||||
return 0;
|
||||
}
|
||||
@@ -315,7 +343,7 @@ unicode_in(struct stream* s, int uni_len, char* dst, int dst_len)
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
static int APP_CC
|
||||
xrdp_sec_process_logon_info(struct xrdp_sec* self, struct stream* s)
|
||||
xrdp_sec_process_logon_info(struct xrdp_sec *self, struct stream *s)
|
||||
{
|
||||
int flags = 0;
|
||||
int len_domain = 0;
|
||||
@@ -329,61 +357,83 @@ xrdp_sec_process_logon_info(struct xrdp_sec* self, struct stream* s)
|
||||
char tmpdata[256];
|
||||
|
||||
/* initialize (zero out) local variables */
|
||||
g_memset(tmpdata,0,sizeof(char)*256);
|
||||
g_memset(tmpdata, 0, sizeof(char) * 256);
|
||||
in_uint8s(s, 4);
|
||||
in_uint32_le(s, flags);
|
||||
DEBUG(("in xrdp_sec_process_logon_info flags $%x", flags));
|
||||
|
||||
/* this is the first test that the decrypt is working */
|
||||
if ((flags & RDP_LOGON_NORMAL) != RDP_LOGON_NORMAL) /* 0x33 */
|
||||
{ /* must be or error */
|
||||
{
|
||||
/* must be or error */
|
||||
DEBUG(("xrdp_sec_process_logon_info: flags wrong, major error"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (flags & RDP_LOGON_LEAVE_AUDIO)
|
||||
{
|
||||
self->rdp_layer->client_info.sound_code = 1;
|
||||
DEBUG(("flag RDP_LOGON_LEAVE_AUDIO found"));
|
||||
}
|
||||
|
||||
if ((flags & RDP_LOGON_AUTO) && (!self->rdp_layer->client_info.is_mce))
|
||||
/* todo, for now not allowing autologon and mce both */
|
||||
{
|
||||
self->rdp_layer->client_info.rdp_autologin = 1;
|
||||
DEBUG(("flag RDP_LOGON_AUTO found"));
|
||||
}
|
||||
|
||||
if (flags & RDP_COMPRESSION)
|
||||
{
|
||||
self->rdp_layer->client_info.rdp_compression = 1;
|
||||
DEBUG(("flag RDP_COMPRESSION found"));
|
||||
}
|
||||
|
||||
in_uint16_le(s, len_domain);
|
||||
if (len_domain > 511) {
|
||||
|
||||
if (len_domain > 511)
|
||||
{
|
||||
DEBUG(("ERROR [xrdp_sec_process_logon_info()]: len_domain > 511"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint16_le(s, len_user);
|
||||
if (len_user > 511) {
|
||||
|
||||
if (len_user > 511)
|
||||
{
|
||||
DEBUG(("ERROR [xrdp_sec_process_logon_info()]: len_user > 511"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint16_le(s, len_password);
|
||||
if (len_password > 511) {
|
||||
|
||||
if (len_password > 511)
|
||||
{
|
||||
DEBUG(("ERROR [xrdp_sec_process_logon_info()]: len_password > 511"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint16_le(s, len_program);
|
||||
if (len_program > 511) {
|
||||
|
||||
if (len_program > 511)
|
||||
{
|
||||
DEBUG(("ERROR [xrdp_sec_process_logon_info()]: len_program > 511"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint16_le(s, len_directory);
|
||||
if (len_directory > 511) {
|
||||
|
||||
if (len_directory > 511)
|
||||
{
|
||||
DEBUG(("ERROR [xrdp_sec_process_logon_info()]: len_directory > 511"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
unicode_in(s, len_domain, self->rdp_layer->client_info.domain, 255);
|
||||
DEBUG(("domain %s", self->rdp_layer->client_info.domain));
|
||||
unicode_in(s, len_user, self->rdp_layer->client_info.username, 255);
|
||||
DEBUG(("username %s", self->rdp_layer->client_info.username));
|
||||
|
||||
if (flags & RDP_LOGON_AUTO)
|
||||
{
|
||||
unicode_in(s, len_password, self->rdp_layer->client_info.password, 255);
|
||||
@@ -393,10 +443,12 @@ xrdp_sec_process_logon_info(struct xrdp_sec* self, struct stream* s)
|
||||
{
|
||||
in_uint8s(s, len_password + 2);
|
||||
}
|
||||
|
||||
unicode_in(s, len_program, self->rdp_layer->client_info.program, 255);
|
||||
DEBUG(("program %s", self->rdp_layer->client_info.program));
|
||||
unicode_in(s, len_directory, self->rdp_layer->client_info.directory, 255);
|
||||
DEBUG(("directory %s", self->rdp_layer->client_info.directory));
|
||||
|
||||
if (flags & RDP_LOGON_BLOB)
|
||||
{
|
||||
in_uint8s(s, 2); /* unknown */
|
||||
@@ -411,6 +463,7 @@ xrdp_sec_process_logon_info(struct xrdp_sec* self, struct stream* s)
|
||||
in_uint8s(s, 26); /* skip stuff */
|
||||
in_uint32_le(s, self->rdp_layer->client_info.rdp5_performanceflags);
|
||||
}
|
||||
|
||||
DEBUG(("out xrdp_sec_process_logon_info"));
|
||||
return 0;
|
||||
}
|
||||
@@ -418,24 +471,28 @@ xrdp_sec_process_logon_info(struct xrdp_sec* self, struct stream* s)
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
static int APP_CC
|
||||
xrdp_sec_send_lic_initial(struct xrdp_sec* self)
|
||||
xrdp_sec_send_lic_initial(struct xrdp_sec *self)
|
||||
{
|
||||
struct stream* s = (struct stream *)NULL;
|
||||
struct stream *s = (struct stream *)NULL;
|
||||
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
|
||||
if (xrdp_mcs_init(self->mcs_layer, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
out_uint8a(s, g_lic1, 322);
|
||||
s_mark_end(s);
|
||||
|
||||
if (xrdp_mcs_send(self->mcs_layer, s, MCS_GLOBAL_CHANNEL) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
return 0;
|
||||
}
|
||||
@@ -443,24 +500,28 @@ xrdp_sec_send_lic_initial(struct xrdp_sec* self)
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
static int APP_CC
|
||||
xrdp_sec_send_lic_response(struct xrdp_sec* self)
|
||||
xrdp_sec_send_lic_response(struct xrdp_sec *self)
|
||||
{
|
||||
struct stream* s;
|
||||
struct stream *s;
|
||||
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
|
||||
if (xrdp_mcs_init(self->mcs_layer, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
out_uint8a(s, g_lic2, 20);
|
||||
s_mark_end(s);
|
||||
|
||||
if (xrdp_mcs_send(self->mcs_layer, s, MCS_GLOBAL_CHANNEL) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
return 0;
|
||||
}
|
||||
@@ -468,48 +529,53 @@ xrdp_sec_send_lic_response(struct xrdp_sec* self)
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
static int APP_CC
|
||||
xrdp_sec_send_media_lic_response(struct xrdp_sec* self)
|
||||
xrdp_sec_send_media_lic_response(struct xrdp_sec *self)
|
||||
{
|
||||
struct stream* s;
|
||||
struct stream *s;
|
||||
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
|
||||
if (xrdp_mcs_init(self->mcs_layer, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
out_uint8a(s, g_lic3, sizeof(g_lic3));
|
||||
s_mark_end(s);
|
||||
|
||||
if (xrdp_mcs_send(self->mcs_layer, s, MCS_GLOBAL_CHANNEL) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
static void APP_CC
|
||||
xrdp_sec_rsa_op(char* out, char* in, char* mod, char* exp)
|
||||
xrdp_sec_rsa_op(char *out, char *in, char *mod, char *exp)
|
||||
{
|
||||
ssl_mod_exp(out, 64, in, 64, mod, 64, exp, 64);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
static void APP_CC
|
||||
xrdp_sec_hash_48(char* out, char* in, char* salt1, char* salt2, int salt)
|
||||
xrdp_sec_hash_48(char *out, char *in, char *salt1, char *salt2, int salt)
|
||||
{
|
||||
int i;
|
||||
void* sha1_info;
|
||||
void* md5_info;
|
||||
void *sha1_info;
|
||||
void *md5_info;
|
||||
char pad[4];
|
||||
char sha1_sig[20];
|
||||
char md5_sig[16];
|
||||
|
||||
sha1_info = ssl_sha1_info_create();
|
||||
md5_info = ssl_md5_info_create();
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
g_memset(pad, salt + i, 4);
|
||||
@@ -525,15 +591,16 @@ xrdp_sec_hash_48(char* out, char* in, char* salt1, char* salt2, int salt)
|
||||
ssl_md5_complete(md5_info, md5_sig);
|
||||
g_memcpy(out + i * 16, md5_sig, 16);
|
||||
}
|
||||
|
||||
ssl_sha1_info_delete(sha1_info);
|
||||
ssl_md5_info_delete(md5_info);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
static void APP_CC
|
||||
xrdp_sec_hash_16(char* out, char* in, char* salt1, char* salt2)
|
||||
xrdp_sec_hash_16(char *out, char *in, char *salt1, char *salt2)
|
||||
{
|
||||
void* md5_info;
|
||||
void *md5_info;
|
||||
|
||||
md5_info = ssl_md5_info_create();
|
||||
ssl_md5_clear(md5_info);
|
||||
@@ -546,7 +613,7 @@ xrdp_sec_hash_16(char* out, char* in, char* salt1, char* salt2)
|
||||
|
||||
/*****************************************************************************/
|
||||
static void APP_CC
|
||||
xrdp_sec_establish_keys(struct xrdp_sec* self)
|
||||
xrdp_sec_establish_keys(struct xrdp_sec *self)
|
||||
{
|
||||
char session_key[48];
|
||||
char temp_hash[48];
|
||||
@@ -563,6 +630,7 @@ xrdp_sec_establish_keys(struct xrdp_sec* self)
|
||||
self->server_random);
|
||||
xrdp_sec_hash_16(self->decrypt_key, session_key + 32, self->client_random,
|
||||
self->server_random);
|
||||
|
||||
if (self->rc4_key_size == 1)
|
||||
{
|
||||
xrdp_sec_make_40bit(self->sign_key);
|
||||
@@ -574,6 +642,7 @@ xrdp_sec_establish_keys(struct xrdp_sec* self)
|
||||
{
|
||||
self->rc4_key_len = 16;
|
||||
}
|
||||
|
||||
g_memcpy(self->decrypt_update_key, self->decrypt_key, 16);
|
||||
g_memcpy(self->encrypt_update_key, self->encrypt_key, 16);
|
||||
ssl_rc4_set_key(self->decrypt_rc4_info, self->decrypt_key, self->rc4_key_len);
|
||||
@@ -583,24 +652,28 @@ xrdp_sec_establish_keys(struct xrdp_sec* self)
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
int APP_CC
|
||||
xrdp_sec_recv(struct xrdp_sec* self, struct stream* s, int* chan)
|
||||
xrdp_sec_recv(struct xrdp_sec *self, struct stream *s, int *chan)
|
||||
{
|
||||
int flags;
|
||||
int len;
|
||||
|
||||
DEBUG((" in xrdp_sec_recv"));
|
||||
|
||||
if (xrdp_mcs_recv(self->mcs_layer, s, chan) != 0)
|
||||
{
|
||||
DEBUG((" out xrdp_sec_recv error"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint32_le(s, flags);
|
||||
DEBUG((" in xrdp_sec_recv flags $%x", flags));
|
||||
|
||||
if (flags & SEC_ENCRYPT) /* 0x08 */
|
||||
{
|
||||
in_uint8s(s, 8); /* signature */
|
||||
xrdp_sec_decrypt(self, s->p, (int)(s->end - s->p));
|
||||
}
|
||||
|
||||
if (flags & SEC_CLIENT_RANDOM) /* 0x01 */
|
||||
{
|
||||
in_uint32_le(s, len);
|
||||
@@ -612,6 +685,7 @@ xrdp_sec_recv(struct xrdp_sec* self, struct stream* s, int* chan)
|
||||
DEBUG((" out xrdp_sec_recv"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (flags & SEC_LOGON_INFO) /* 0x40 */
|
||||
{
|
||||
if (xrdp_sec_process_logon_info(self, s) != 0)
|
||||
@@ -619,6 +693,7 @@ xrdp_sec_recv(struct xrdp_sec* self, struct stream* s, int* chan)
|
||||
DEBUG((" out xrdp_sec_recv error"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (self->rdp_layer->client_info.is_mce)
|
||||
{
|
||||
if (xrdp_sec_send_media_lic_response(self) != 0)
|
||||
@@ -626,18 +701,22 @@ xrdp_sec_recv(struct xrdp_sec* self, struct stream* s, int* chan)
|
||||
DEBUG((" out xrdp_sec_recv error"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
DEBUG((" out xrdp_sec_recv"));
|
||||
return -1; /* special error that means send demand active */
|
||||
}
|
||||
|
||||
if (xrdp_sec_send_lic_initial(self) != 0)
|
||||
{
|
||||
DEBUG((" out xrdp_sec_recv error"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
*chan = 1; /* just set a non existing channel and exit */
|
||||
DEBUG((" out xrdp_sec_recv"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (flags & SEC_LICENCE_NEG) /* 0x80 */
|
||||
{
|
||||
if (xrdp_sec_send_lic_response(self) != 0)
|
||||
@@ -645,9 +724,11 @@ xrdp_sec_recv(struct xrdp_sec* self, struct stream* s, int* chan)
|
||||
DEBUG((" out xrdp_sec_recv error"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
DEBUG((" out xrdp_sec_recv"));
|
||||
return -1; /* special error that means send demand active */
|
||||
}
|
||||
|
||||
DEBUG((" out xrdp_sec_recv"));
|
||||
return 0;
|
||||
}
|
||||
@@ -655,7 +736,7 @@ xrdp_sec_recv(struct xrdp_sec* self, struct stream* s, int* chan)
|
||||
/*****************************************************************************/
|
||||
/* Output a uint32 into a buffer (little-endian) */
|
||||
static void
|
||||
buf_out_uint32(char* buffer, int value)
|
||||
buf_out_uint32(char *buffer, int value)
|
||||
{
|
||||
buffer[0] = (value) & 0xff;
|
||||
buffer[1] = (value >> 8) & 0xff;
|
||||
@@ -666,27 +747,27 @@ buf_out_uint32(char* buffer, int value)
|
||||
/*****************************************************************************/
|
||||
/* Generate a MAC hash (5.2.3.1), using a combination of SHA1 and MD5 */
|
||||
static void APP_CC
|
||||
xrdp_sec_sign(struct xrdp_sec* self, char* out, int out_len,
|
||||
char* data, int data_len)
|
||||
xrdp_sec_sign(struct xrdp_sec *self, char *out, int out_len,
|
||||
char *data, int data_len)
|
||||
{
|
||||
char shasig[20];
|
||||
char md5sig[16];
|
||||
char lenhdr[4];
|
||||
void* sha1_info;
|
||||
void* md5_info;
|
||||
void *sha1_info;
|
||||
void *md5_info;
|
||||
|
||||
buf_out_uint32(lenhdr, data_len);
|
||||
sha1_info = ssl_sha1_info_create();
|
||||
md5_info = ssl_md5_info_create();
|
||||
ssl_sha1_clear(sha1_info);
|
||||
ssl_sha1_transform(sha1_info, self->sign_key, self->rc4_key_len);
|
||||
ssl_sha1_transform(sha1_info, (char*)g_pad_54, 40);
|
||||
ssl_sha1_transform(sha1_info, (char *)g_pad_54, 40);
|
||||
ssl_sha1_transform(sha1_info, lenhdr, 4);
|
||||
ssl_sha1_transform(sha1_info, data, data_len);
|
||||
ssl_sha1_complete(sha1_info, shasig);
|
||||
ssl_md5_clear(md5_info);
|
||||
ssl_md5_transform(md5_info, self->sign_key, self->rc4_key_len);
|
||||
ssl_md5_transform(md5_info, (char*)g_pad_92, 48);
|
||||
ssl_md5_transform(md5_info, (char *)g_pad_92, 48);
|
||||
ssl_md5_transform(md5_info, shasig, 20);
|
||||
ssl_md5_complete(md5_info, md5sig);
|
||||
g_memcpy(out, md5sig, out_len);
|
||||
@@ -697,12 +778,13 @@ xrdp_sec_sign(struct xrdp_sec* self, char* out, int out_len,
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
int APP_CC
|
||||
xrdp_sec_send(struct xrdp_sec* self, struct stream* s, int chan)
|
||||
xrdp_sec_send(struct xrdp_sec *self, struct stream *s, int chan)
|
||||
{
|
||||
int datalen;
|
||||
|
||||
DEBUG((" in xrdp_sec_send"));
|
||||
s_pop_layer(s, sec_hdr);
|
||||
|
||||
if (self->crypt_level > 1)
|
||||
{
|
||||
out_uint32_le(s, SEC_ENCRYPT);
|
||||
@@ -714,10 +796,12 @@ xrdp_sec_send(struct xrdp_sec* self, struct stream* s, int chan)
|
||||
{
|
||||
out_uint32_le(s, 0);
|
||||
}
|
||||
|
||||
if (xrdp_mcs_send(self->mcs_layer, s, chan) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
DEBUG((" out xrdp_sec_send"));
|
||||
return 0;
|
||||
}
|
||||
@@ -726,23 +810,26 @@ xrdp_sec_send(struct xrdp_sec* self, struct stream* s, int chan)
|
||||
/* this adds the mcs channels in the list of channels to be used when
|
||||
creating the server mcs data */
|
||||
static int APP_CC
|
||||
xrdp_sec_process_mcs_data_channels(struct xrdp_sec* self, struct stream* s)
|
||||
xrdp_sec_process_mcs_data_channels(struct xrdp_sec *self, struct stream *s)
|
||||
{
|
||||
int num_channels;
|
||||
int index;
|
||||
struct mcs_channel_item* channel_item;
|
||||
struct mcs_channel_item *channel_item;
|
||||
|
||||
DEBUG(("processing channels, channel_code is %d", self->channel_code));
|
||||
|
||||
/* this is an option set in xrdp.ini */
|
||||
if (self->channel_code != 1) /* are channels on? */
|
||||
{
|
||||
g_writeln("Processing channel data from client - The channel is off");
|
||||
return 0;
|
||||
}
|
||||
|
||||
in_uint32_le(s, num_channels);
|
||||
|
||||
for (index = 0; index < num_channels; index++)
|
||||
{
|
||||
channel_item = (struct mcs_channel_item*)
|
||||
channel_item = (struct mcs_channel_item *)
|
||||
g_malloc(sizeof(struct mcs_channel_item), 1);
|
||||
in_uint8a(s, channel_item->name, 8);
|
||||
in_uint32_le(s, channel_item->flags);
|
||||
@@ -751,6 +838,7 @@ xrdp_sec_process_mcs_data_channels(struct xrdp_sec* self, struct stream* s)
|
||||
DEBUG(("got channel flags %8.8x name %s", channel_item->flags,
|
||||
channel_item->name));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -758,10 +846,10 @@ xrdp_sec_process_mcs_data_channels(struct xrdp_sec* self, struct stream* s)
|
||||
/* process client mcs data, we need some things in here to create the server
|
||||
mcs data */
|
||||
int APP_CC
|
||||
xrdp_sec_process_mcs_data(struct xrdp_sec* self)
|
||||
xrdp_sec_process_mcs_data(struct xrdp_sec *self)
|
||||
{
|
||||
struct stream* s = (struct stream *)NULL;
|
||||
char* hold_p = (char *)NULL;
|
||||
struct stream *s = (struct stream *)NULL;
|
||||
char *hold_p = (char *)NULL;
|
||||
int tag = 0;
|
||||
int size = 0;
|
||||
|
||||
@@ -770,17 +858,20 @@ xrdp_sec_process_mcs_data(struct xrdp_sec* self)
|
||||
s->p = s->data;
|
||||
/* skip header */
|
||||
in_uint8s(s, 23);
|
||||
|
||||
while (s_check_rem(s, 4))
|
||||
{
|
||||
hold_p = s->p;
|
||||
in_uint16_le(s, tag);
|
||||
in_uint16_le(s, size);
|
||||
|
||||
if (size < 4 || !s_check_rem(s, size - 4))
|
||||
{
|
||||
g_writeln("error in xrdp_sec_process_mcs_data tag %d size %d",
|
||||
tag, size);
|
||||
break;
|
||||
}
|
||||
|
||||
switch (tag)
|
||||
{
|
||||
case SEC_TAG_CLI_INFO:
|
||||
@@ -797,8 +888,10 @@ xrdp_sec_process_mcs_data(struct xrdp_sec* self)
|
||||
tag, size);
|
||||
break;
|
||||
}
|
||||
|
||||
s->p = hold_p + size;
|
||||
}
|
||||
|
||||
/* set p to beginning */
|
||||
s->p = s->data;
|
||||
return 0;
|
||||
@@ -807,9 +900,9 @@ xrdp_sec_process_mcs_data(struct xrdp_sec* self)
|
||||
/*****************************************************************************/
|
||||
/* prepare server mcs data to send in mcs layer */
|
||||
int APP_CC
|
||||
xrdp_sec_out_mcs_data(struct xrdp_sec* self)
|
||||
xrdp_sec_out_mcs_data(struct xrdp_sec *self)
|
||||
{
|
||||
struct stream* s;
|
||||
struct stream *s;
|
||||
int num_channels_even;
|
||||
int num_channels;
|
||||
int index;
|
||||
@@ -847,6 +940,7 @@ xrdp_sec_out_mcs_data(struct xrdp_sec* self)
|
||||
out_uint16_le(s, 8 + (num_channels_even * 2)); /* len */
|
||||
out_uint16_le(s, MCS_GLOBAL_CHANNEL); /* 1003, 0x03eb main channel */
|
||||
out_uint16_le(s, num_channels); /* number of other channels */
|
||||
|
||||
for (index = 0; index < num_channels_even; index++)
|
||||
{
|
||||
if (index < num_channels)
|
||||
@@ -859,6 +953,7 @@ xrdp_sec_out_mcs_data(struct xrdp_sec* self)
|
||||
out_uint16_le(s, 0);
|
||||
}
|
||||
}
|
||||
|
||||
out_uint16_le(s, SEC_TAG_SRV_CRYPT);
|
||||
out_uint16_le(s, 0x00ec); /* len is 236 */
|
||||
out_uint32_le(s, self->rc4_key_size); /* key len 1 = 40 bit 2 = 128 bit */
|
||||
@@ -894,10 +989,10 @@ xrdp_sec_out_mcs_data(struct xrdp_sec* self)
|
||||
/*****************************************************************************/
|
||||
/* process the mcs client data we received from the mcs layer */
|
||||
static void APP_CC
|
||||
xrdp_sec_in_mcs_data(struct xrdp_sec* self)
|
||||
xrdp_sec_in_mcs_data(struct xrdp_sec *self)
|
||||
{
|
||||
struct stream* s = (struct stream *)NULL;
|
||||
struct xrdp_client_info* client_info = (struct xrdp_client_info *)NULL;
|
||||
struct stream *s = (struct stream *)NULL;
|
||||
struct xrdp_client_info *client_info = (struct xrdp_client_info *)NULL;
|
||||
int index = 0;
|
||||
char c = 0;
|
||||
|
||||
@@ -909,6 +1004,7 @@ xrdp_sec_in_mcs_data(struct xrdp_sec* self)
|
||||
g_memset(client_info->hostname, 0, 32);
|
||||
c = 1;
|
||||
index = 0;
|
||||
|
||||
while (index < 16 && c != 0)
|
||||
{
|
||||
in_uint8(s, c);
|
||||
@@ -916,6 +1012,7 @@ xrdp_sec_in_mcs_data(struct xrdp_sec* self)
|
||||
client_info->hostname[index] = c;
|
||||
index++;
|
||||
}
|
||||
|
||||
/* get build */
|
||||
s->p = s->data;
|
||||
in_uint8s(s, 43);
|
||||
@@ -929,16 +1026,16 @@ xrdp_sec_in_mcs_data(struct xrdp_sec* self)
|
||||
|
||||
/*****************************************************************************/
|
||||
int APP_CC
|
||||
xrdp_sec_incoming(struct xrdp_sec* self)
|
||||
xrdp_sec_incoming(struct xrdp_sec *self)
|
||||
{
|
||||
struct list* items = NULL;
|
||||
struct list* values = NULL;
|
||||
struct list *items = NULL;
|
||||
struct list *values = NULL;
|
||||
int index = 0;
|
||||
char* item = NULL;
|
||||
char* value = NULL;
|
||||
char *item = NULL;
|
||||
char *value = NULL;
|
||||
char key_file[256];
|
||||
|
||||
g_memset(key_file,0,sizeof(char)*256);
|
||||
g_memset(key_file, 0, sizeof(char) * 256);
|
||||
|
||||
DEBUG((" in xrdp_sec_incoming"));
|
||||
g_random(self->server_random, 32);
|
||||
@@ -947,6 +1044,7 @@ xrdp_sec_incoming(struct xrdp_sec* self)
|
||||
values = list_create();
|
||||
values->auto_free = 1;
|
||||
g_snprintf(key_file, 255, "%s/rsakeys.ini", XRDP_CFG_PATH);
|
||||
|
||||
if (file_by_name_read_section(key_file, "keys", items, values) != 0)
|
||||
{
|
||||
/* this is a show stopper */
|
||||
@@ -955,10 +1053,12 @@ xrdp_sec_incoming(struct xrdp_sec* self)
|
||||
list_delete(values);
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (index = 0; index < items->count; index++)
|
||||
{
|
||||
item = (char*)list_get_item(items, index);
|
||||
value = (char*)list_get_item(values, index);
|
||||
item = (char *)list_get_item(items, index);
|
||||
value = (char *)list_get_item(values, index);
|
||||
|
||||
if (g_strcasecmp(item, "pub_exp") == 0)
|
||||
{
|
||||
hex_str_to_bin(value, self->pub_exp, 4);
|
||||
@@ -976,12 +1076,15 @@ xrdp_sec_incoming(struct xrdp_sec* self)
|
||||
hex_str_to_bin(value, self->pri_exp, 64);
|
||||
}
|
||||
}
|
||||
|
||||
list_delete(items);
|
||||
list_delete(values);
|
||||
|
||||
if (xrdp_mcs_incoming(self->mcs_layer) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifdef XRDP_DEBUG
|
||||
g_writeln("client mcs data received");
|
||||
g_hexdump(self->client_mcs_data.data,
|
||||
@@ -997,7 +1100,7 @@ xrdp_sec_incoming(struct xrdp_sec* self)
|
||||
|
||||
/*****************************************************************************/
|
||||
int APP_CC
|
||||
xrdp_sec_disconnect(struct xrdp_sec* self)
|
||||
xrdp_sec_disconnect(struct xrdp_sec *self)
|
||||
{
|
||||
int rv;
|
||||
|
||||
|
||||
+25
-22
@@ -21,12 +21,12 @@
|
||||
#include "freerdp/codec/rfx.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
struct xrdp_surface* APP_CC
|
||||
xrdp_surface_create(struct xrdp_session* session, struct xrdp_fastpath* fastpath)
|
||||
struct xrdp_surface *APP_CC
|
||||
xrdp_surface_create(struct xrdp_session *session, struct xrdp_fastpath *fastpath)
|
||||
{
|
||||
struct xrdp_surface* self;
|
||||
struct xrdp_surface *self;
|
||||
|
||||
self = (struct xrdp_surface*)g_malloc(sizeof(struct xrdp_surface), 1);
|
||||
self = (struct xrdp_surface *)g_malloc(sizeof(struct xrdp_surface), 1);
|
||||
self->session = session;
|
||||
self->fastpath = fastpath;
|
||||
self->rfx_context = rfx_context_new();
|
||||
@@ -36,17 +36,18 @@ xrdp_surface_create(struct xrdp_session* session, struct xrdp_fastpath* fastpath
|
||||
|
||||
/*****************************************************************************/
|
||||
void APP_CC
|
||||
xrdp_surface_delete(struct xrdp_surface* self)
|
||||
xrdp_surface_delete(struct xrdp_surface *self)
|
||||
{
|
||||
STREAM* s;
|
||||
RFX_CONTEXT* rfx_context;
|
||||
STREAM *s;
|
||||
RFX_CONTEXT *rfx_context;
|
||||
|
||||
if (self == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
s = (STREAM*)(self->s);
|
||||
rfx_context = (RFX_CONTEXT*)(self->rfx_context);
|
||||
|
||||
s = (STREAM *)(self->s);
|
||||
rfx_context = (RFX_CONTEXT *)(self->rfx_context);
|
||||
free_stream(self->out_s);
|
||||
stream_free(s);
|
||||
rfx_context_free(rfx_context);
|
||||
@@ -56,26 +57,26 @@ xrdp_surface_delete(struct xrdp_surface* self)
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
int APP_CC
|
||||
xrdp_surface_reset(struct xrdp_surface* self)
|
||||
xrdp_surface_reset(struct xrdp_surface *self)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
int APP_CC
|
||||
xrdp_surface_init(struct xrdp_surface* self)
|
||||
xrdp_surface_init(struct xrdp_surface *self)
|
||||
{
|
||||
int width;
|
||||
int height;
|
||||
RFX_CONTEXT* rfx_context;
|
||||
RFX_CONTEXT *rfx_context;
|
||||
|
||||
rfx_context = (RFX_CONTEXT*)(self->rfx_context);
|
||||
rfx_context = (RFX_CONTEXT *)(self->rfx_context);
|
||||
width = self->session->client_info->width;
|
||||
height= self->session->client_info->height;
|
||||
height = self->session->client_info->height;
|
||||
|
||||
rfx_context->mode = self->session->client_info->rfx_entropy;
|
||||
rfx_context->width = width;
|
||||
rfx_context->height= height;
|
||||
rfx_context->height = height;
|
||||
|
||||
make_stream(self->out_s);
|
||||
init_stream(self->out_s, 2 * 3 * width * height + 22);
|
||||
@@ -85,21 +86,22 @@ xrdp_surface_init(struct xrdp_surface* self)
|
||||
|
||||
/*****************************************************************************/
|
||||
int APP_CC
|
||||
xrdp_surface_send_surface_bits(struct xrdp_surface* self,int bpp, char* data,
|
||||
xrdp_surface_send_surface_bits(struct xrdp_surface *self, int bpp, char *data,
|
||||
int x, int y, int cx, int cy)
|
||||
{
|
||||
RFX_RECT rect;
|
||||
char* buf;
|
||||
char *buf;
|
||||
int Bpp;
|
||||
int i;
|
||||
int j;
|
||||
int codecId;
|
||||
uint32 bitmapDataLength;
|
||||
STREAM* s;
|
||||
RFX_CONTEXT* rfx_context;
|
||||
STREAM *s;
|
||||
RFX_CONTEXT *rfx_context;
|
||||
|
||||
s = (STREAM *)(self->s);
|
||||
rfx_context = (RFX_CONTEXT *)(self->rfx_context);
|
||||
|
||||
s = (STREAM*)(self->s);
|
||||
rfx_context = (RFX_CONTEXT*)(self->rfx_context);
|
||||
if ((bpp == 24) || (bpp == 32))
|
||||
{
|
||||
}
|
||||
@@ -108,6 +110,7 @@ xrdp_surface_send_surface_bits(struct xrdp_surface* self,int bpp, char* data,
|
||||
g_writeln("bpp = %d is not supported\n", bpp);
|
||||
return 1;
|
||||
}
|
||||
|
||||
Bpp = 4;
|
||||
|
||||
rect.x = 0;
|
||||
@@ -147,7 +150,7 @@ xrdp_surface_send_surface_bits(struct xrdp_surface* self,int bpp, char* data,
|
||||
|
||||
/*****************************************************************************/
|
||||
int APP_CC
|
||||
xrdp_surface_send_frame_marker(struct xrdp_surface* self,
|
||||
xrdp_surface_send_frame_marker(struct xrdp_surface *self,
|
||||
uint16 frameAction, uint32 frameId)
|
||||
{
|
||||
init_stream(self->out_s, 0);
|
||||
|
||||
+31
-29
@@ -1,35 +1,33 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2004-2010
|
||||
|
||||
tcp layer
|
||||
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004 - 2012
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* tcp layer
|
||||
*/
|
||||
|
||||
#include "libxrdp.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
struct xrdp_tcp* APP_CC
|
||||
xrdp_tcp_create(struct xrdp_iso* owner, struct trans* trans)
|
||||
struct xrdp_tcp *APP_CC
|
||||
xrdp_tcp_create(struct xrdp_iso *owner, struct trans *trans)
|
||||
{
|
||||
struct xrdp_tcp* self;
|
||||
struct xrdp_tcp *self;
|
||||
|
||||
DEBUG((" in xrdp_tcp_create"));
|
||||
self = (struct xrdp_tcp*)g_malloc(sizeof(struct xrdp_tcp), 1);
|
||||
self = (struct xrdp_tcp *)g_malloc(sizeof(struct xrdp_tcp), 1);
|
||||
self->iso_layer = owner;
|
||||
self->trans = trans;
|
||||
DEBUG((" out xrdp_tcp_create"));
|
||||
@@ -38,7 +36,7 @@ xrdp_tcp_create(struct xrdp_iso* owner, struct trans* trans)
|
||||
|
||||
/*****************************************************************************/
|
||||
void APP_CC
|
||||
xrdp_tcp_delete(struct xrdp_tcp* self)
|
||||
xrdp_tcp_delete(struct xrdp_tcp *self)
|
||||
{
|
||||
g_free(self);
|
||||
}
|
||||
@@ -47,7 +45,7 @@ xrdp_tcp_delete(struct xrdp_tcp* self)
|
||||
/* get out stream ready for data */
|
||||
/* returns error */
|
||||
int APP_CC
|
||||
xrdp_tcp_init(struct xrdp_tcp* self, struct stream* s)
|
||||
xrdp_tcp_init(struct xrdp_tcp *self, struct stream *s)
|
||||
{
|
||||
init_stream(s, 8192);
|
||||
return 0;
|
||||
@@ -56,15 +54,17 @@ xrdp_tcp_init(struct xrdp_tcp* self, struct stream* s)
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
int APP_CC
|
||||
xrdp_tcp_recv(struct xrdp_tcp* self, struct stream* s, int len)
|
||||
xrdp_tcp_recv(struct xrdp_tcp *self, struct stream *s, int len)
|
||||
{
|
||||
DEBUG((" in xrdp_tcp_recv, gota get %d bytes", len));
|
||||
init_stream(s, len);
|
||||
|
||||
if (trans_force_read_s(self->trans, s, len) != 0)
|
||||
{
|
||||
DEBUG((" error in trans_force_read_s"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
DEBUG((" out xrdp_tcp_recv"));
|
||||
return 0;
|
||||
}
|
||||
@@ -72,16 +72,18 @@ xrdp_tcp_recv(struct xrdp_tcp* self, struct stream* s, int len)
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
int APP_CC
|
||||
xrdp_tcp_send(struct xrdp_tcp* self, struct stream* s)
|
||||
xrdp_tcp_send(struct xrdp_tcp *self, struct stream *s)
|
||||
{
|
||||
int len;
|
||||
len = s->end - s->data;
|
||||
DEBUG((" in xrdp_tcp_send, gota send %d bytes", len));
|
||||
|
||||
if (trans_force_write_s(self->trans, s) != 0)
|
||||
{
|
||||
DEBUG((" error in trans_force_write_s"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
DEBUG((" out xrdp_tcp_send, sent %d bytes ok", len));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,31 +1,29 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2007-2010
|
||||
|
||||
media center
|
||||
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* media center
|
||||
*/
|
||||
|
||||
#include "mc.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* return error */
|
||||
int DEFAULT_CC
|
||||
lib_mod_start(struct mod* mod, int w, int h, int bpp)
|
||||
lib_mod_start(struct mod *mod, int w, int h, int bpp)
|
||||
{
|
||||
LIB_DEBUG(mod, "in lib_mod_start");
|
||||
mod->width = w;
|
||||
@@ -38,7 +36,7 @@ lib_mod_start(struct mod* mod, int w, int h, int bpp)
|
||||
/******************************************************************************/
|
||||
/* return error */
|
||||
int DEFAULT_CC
|
||||
lib_mod_connect(struct mod* mod)
|
||||
lib_mod_connect(struct mod *mod)
|
||||
{
|
||||
LIB_DEBUG(mod, "in lib_mod_connect");
|
||||
LIB_DEBUG(mod, "out lib_mod_connect");
|
||||
@@ -48,7 +46,7 @@ lib_mod_connect(struct mod* mod)
|
||||
/******************************************************************************/
|
||||
/* return error */
|
||||
int DEFAULT_CC
|
||||
lib_mod_event(struct mod* mod, int msg, long param1, long param2,
|
||||
lib_mod_event(struct mod *mod, int msg, long param1, long param2,
|
||||
long param3, long param4)
|
||||
{
|
||||
LIB_DEBUG(mod, "in lib_mod_event");
|
||||
@@ -59,7 +57,7 @@ lib_mod_event(struct mod* mod, int msg, long param1, long param2,
|
||||
/******************************************************************************/
|
||||
/* return error */
|
||||
int DEFAULT_CC
|
||||
lib_mod_signal(struct mod* mod)
|
||||
lib_mod_signal(struct mod *mod)
|
||||
{
|
||||
LIB_DEBUG(mod, "in lib_mod_signal");
|
||||
LIB_DEBUG(mod, "out lib_mod_signal");
|
||||
@@ -69,7 +67,7 @@ lib_mod_signal(struct mod* mod)
|
||||
/******************************************************************************/
|
||||
/* return error */
|
||||
int DEFAULT_CC
|
||||
lib_mod_end(struct mod* mod)
|
||||
lib_mod_end(struct mod *mod)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -77,18 +75,18 @@ lib_mod_end(struct mod* mod)
|
||||
/******************************************************************************/
|
||||
/* return error */
|
||||
int DEFAULT_CC
|
||||
lib_mod_set_param(struct mod* mod, char* name, char* value)
|
||||
lib_mod_set_param(struct mod *mod, char *name, char *value)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
struct mod* EXPORT_CC
|
||||
struct mod *EXPORT_CC
|
||||
mod_init(void)
|
||||
{
|
||||
struct mod* mod;
|
||||
struct mod *mod;
|
||||
|
||||
mod = (struct mod*)g_malloc(sizeof(struct mod), 1);
|
||||
mod = (struct mod *)g_malloc(sizeof(struct mod), 1);
|
||||
mod->size = sizeof(struct mod);
|
||||
mod->version = CURRENT_MOD_VER;
|
||||
mod->handle = (long)mod;
|
||||
@@ -103,12 +101,13 @@ mod_init(void)
|
||||
|
||||
/******************************************************************************/
|
||||
int EXPORT_CC
|
||||
mod_exit(struct mod* mod)
|
||||
mod_exit(struct mod *mod)
|
||||
{
|
||||
if (mod == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
g_free(mod);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,24 +1,22 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2007-2010
|
||||
|
||||
media center
|
||||
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* media center
|
||||
*/
|
||||
|
||||
/* include other h files */
|
||||
#include "arch.h"
|
||||
|
||||
@@ -1,31 +1,29 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
|
||||
librdp main file
|
||||
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* librdp main file
|
||||
*/
|
||||
|
||||
#include "rdp.h"
|
||||
|
||||
/******************************************************************************/
|
||||
/* return error */
|
||||
int DEFAULT_CC
|
||||
lib_mod_start(struct mod* mod, int w, int h, int bpp)
|
||||
lib_mod_start(struct mod *mod, int w, int h, int bpp)
|
||||
{
|
||||
DEBUG(("in lib_mod_start"));
|
||||
mod->width = w;
|
||||
@@ -41,7 +39,7 @@ lib_mod_start(struct mod* mod, int w, int h, int bpp)
|
||||
/******************************************************************************/
|
||||
/* return error */
|
||||
int DEFAULT_CC
|
||||
lib_mod_connect(struct mod* mod)
|
||||
lib_mod_connect(struct mod *mod)
|
||||
{
|
||||
DEBUG(("in lib_mod_connect"));
|
||||
/* clear screen */
|
||||
@@ -49,6 +47,7 @@ lib_mod_connect(struct mod* mod)
|
||||
mod->server_set_fgcolor(mod, 0);
|
||||
mod->server_fill_rect(mod, 0, 0, mod->width, mod->height);
|
||||
mod->server_end_update(mod);
|
||||
|
||||
/* connect */
|
||||
if (rdp_rdp_connect(mod->rdp_layer, mod->ip, mod->port) == 0)
|
||||
{
|
||||
@@ -59,6 +58,7 @@ lib_mod_connect(struct mod* mod)
|
||||
DEBUG(("out lib_mod_connect"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEBUG(("out lib_mod_connect error"));
|
||||
return 1;
|
||||
}
|
||||
@@ -66,18 +66,20 @@ lib_mod_connect(struct mod* mod)
|
||||
/******************************************************************************/
|
||||
/* return error */
|
||||
int DEFAULT_CC
|
||||
lib_mod_event(struct mod* mod, int msg, long param1, long param2,
|
||||
lib_mod_event(struct mod *mod, int msg, long param1, long param2,
|
||||
long param3, long param4)
|
||||
{
|
||||
struct stream* s;
|
||||
struct stream *s;
|
||||
|
||||
if (!mod->up_and_running)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEBUG(("in lib_mod_event"));
|
||||
make_stream(s);
|
||||
init_stream(s, 8192 * 2);
|
||||
|
||||
switch (msg)
|
||||
{
|
||||
case 15:
|
||||
@@ -147,6 +149,7 @@ lib_mod_event(struct mod* mod, int msg, long param1, long param2,
|
||||
(param2 >> 16) & 0xffff, param2 & 0xffff);
|
||||
break;
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
DEBUG(("out lib_mod_event"));
|
||||
return 0;
|
||||
@@ -155,29 +158,35 @@ lib_mod_event(struct mod* mod, int msg, long param1, long param2,
|
||||
/******************************************************************************/
|
||||
/* return error */
|
||||
int DEFAULT_CC
|
||||
lib_mod_signal(struct mod* mod)
|
||||
lib_mod_signal(struct mod *mod)
|
||||
{
|
||||
int type;
|
||||
int cont;
|
||||
struct stream* s;
|
||||
struct stream *s;
|
||||
|
||||
DEBUG(("in lib_mod_signal"));
|
||||
|
||||
if (mod->in_s == 0)
|
||||
{
|
||||
make_stream(mod->in_s);
|
||||
}
|
||||
|
||||
s = mod->in_s;
|
||||
init_stream(s, 8192 * 2);
|
||||
cont = 1;
|
||||
|
||||
while (cont)
|
||||
{
|
||||
type = 0;
|
||||
|
||||
if (rdp_rdp_recv(mod->rdp_layer, s, &type) != 0)
|
||||
{
|
||||
DEBUG(("out lib_mod_signal error rdp_rdp_recv failed"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
DEBUG(("lib_mod_signal type %d", type));
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case RDP_PDU_DATA:
|
||||
@@ -197,8 +206,10 @@ lib_mod_signal(struct mod* mod)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
cont = s->next_packet < s->end;
|
||||
}
|
||||
|
||||
DEBUG(("out lib_mod_signal"));
|
||||
return 0;
|
||||
}
|
||||
@@ -206,29 +217,32 @@ lib_mod_signal(struct mod* mod)
|
||||
/******************************************************************************/
|
||||
/* return error */
|
||||
int DEFAULT_CC
|
||||
lib_mod_end(struct mod* mod)
|
||||
lib_mod_end(struct mod *mod)
|
||||
{
|
||||
rdp_rdp_delete(mod->rdp_layer);
|
||||
mod->rdp_layer = 0;
|
||||
free_stream(mod->in_s);
|
||||
mod->in_s = 0;
|
||||
|
||||
if (mod->sck_obj != 0)
|
||||
{
|
||||
g_delete_wait_obj_from_socket(mod->sck_obj);
|
||||
mod->sck_obj = 0;
|
||||
}
|
||||
|
||||
if (mod->sck != 0)
|
||||
{
|
||||
g_tcp_close(mod->sck);
|
||||
mod->sck = 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/* return error */
|
||||
int DEFAULT_CC
|
||||
lib_mod_set_param(struct mod* mod, char* name, char* value)
|
||||
lib_mod_set_param(struct mod *mod, char *name, char *value)
|
||||
{
|
||||
if (g_strncasecmp(name, "ip", 255) == 0)
|
||||
{
|
||||
@@ -254,18 +268,20 @@ lib_mod_set_param(struct mod* mod, char* name, char* value)
|
||||
{
|
||||
mod->keylayout = g_atoi(value);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/* return error */
|
||||
int DEFAULT_CC
|
||||
lib_mod_get_wait_objs(struct mod* mod, tbus* read_objs, int* rcount,
|
||||
tbus* write_objs, int* wcount, int* timeout)
|
||||
lib_mod_get_wait_objs(struct mod *mod, tbus *read_objs, int *rcount,
|
||||
tbus *write_objs, int *wcount, int *timeout)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = *rcount;
|
||||
|
||||
if (mod != 0)
|
||||
{
|
||||
if (mod->sck_obj != 0)
|
||||
@@ -273,6 +289,7 @@ lib_mod_get_wait_objs(struct mod* mod, tbus* read_objs, int* rcount,
|
||||
read_objs[i++] = mod->sck_obj;
|
||||
}
|
||||
}
|
||||
|
||||
*rcount = i;
|
||||
return 0;
|
||||
}
|
||||
@@ -280,11 +297,12 @@ lib_mod_get_wait_objs(struct mod* mod, tbus* read_objs, int* rcount,
|
||||
/******************************************************************************/
|
||||
/* return error */
|
||||
int DEFAULT_CC
|
||||
lib_mod_check_wait_objs(struct mod* mod)
|
||||
lib_mod_check_wait_objs(struct mod *mod)
|
||||
{
|
||||
int rv;
|
||||
|
||||
rv = 0;
|
||||
|
||||
if (mod != 0)
|
||||
{
|
||||
if (mod->sck_obj != 0)
|
||||
@@ -295,17 +313,18 @@ lib_mod_check_wait_objs(struct mod* mod)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
struct mod* EXPORT_CC
|
||||
struct mod *EXPORT_CC
|
||||
mod_init(void)
|
||||
{
|
||||
struct mod* mod;
|
||||
struct mod *mod;
|
||||
|
||||
DEBUG(("in mod_init"));
|
||||
mod = (struct mod*)g_malloc(sizeof(struct mod), 1);
|
||||
mod = (struct mod *)g_malloc(sizeof(struct mod), 1);
|
||||
mod->size = sizeof(struct mod);
|
||||
mod->version = CURRENT_MOD_VER;
|
||||
mod->handle = (long)mod;
|
||||
@@ -324,7 +343,7 @@ mod_init(void)
|
||||
|
||||
/******************************************************************************/
|
||||
int EXPORT_CC
|
||||
mod_exit(struct mod* mod)
|
||||
mod_exit(struct mod *mod)
|
||||
{
|
||||
DEBUG(("in mod_exit"));
|
||||
g_free(mod);
|
||||
|
||||
@@ -1,24 +1,22 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
|
||||
librdp main header file
|
||||
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* librdp main header file
|
||||
*/
|
||||
|
||||
/* include other h files */
|
||||
#include "arch.h"
|
||||
|
||||
+109
-38
@@ -1,24 +1,22 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
|
||||
librdp bitmap routines
|
||||
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* librdp bitmap routines
|
||||
*/
|
||||
|
||||
#include "rdp.h"
|
||||
|
||||
@@ -35,35 +33,35 @@
|
||||
|
||||
/******************************************************************************/
|
||||
#define REPEAT(statement) \
|
||||
{ \
|
||||
{ \
|
||||
while ((count > 0) && (x < width)) \
|
||||
{ \
|
||||
statement; \
|
||||
count--; \
|
||||
x++; \
|
||||
} \
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
#define MASK_UPDATE \
|
||||
{ \
|
||||
{ \
|
||||
mixmask <<= 1; \
|
||||
if ((mixmask & 0xff) == 0) \
|
||||
{ \
|
||||
mask = fom_mask ? fom_mask : CVAL(input); \
|
||||
mixmask = 1; \
|
||||
} \
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/* 1 byte bitmap decompress */
|
||||
/* returns boolean */
|
||||
static int APP_CC
|
||||
bitmap_decompress1(char* output, int width, int height, char* input, int size)
|
||||
bitmap_decompress1(char *output, int width, int height, char *input, int size)
|
||||
{
|
||||
char* prevline;
|
||||
char* line;
|
||||
char* end;
|
||||
char *prevline;
|
||||
char *line;
|
||||
char *end;
|
||||
char color1;
|
||||
char color2;
|
||||
char mix;
|
||||
@@ -98,6 +96,7 @@ bitmap_decompress1(char* output, int width, int height, char* input, int size)
|
||||
fom_mask = 0;
|
||||
code = CVAL(input);
|
||||
opcode = code >> 4;
|
||||
|
||||
/* Handle different opcode forms */
|
||||
switch (opcode)
|
||||
{
|
||||
@@ -110,6 +109,7 @@ bitmap_decompress1(char* output, int width, int height, char* input, int size)
|
||||
break;
|
||||
case 0xf:
|
||||
opcode = code & 0xf;
|
||||
|
||||
if (opcode < 9)
|
||||
{
|
||||
count = CVAL(input);
|
||||
@@ -119,6 +119,7 @@ bitmap_decompress1(char* output, int width, int height, char* input, int size)
|
||||
{
|
||||
count = (opcode < 0xb) ? 8 : 1;
|
||||
}
|
||||
|
||||
offset = 0;
|
||||
break;
|
||||
default:
|
||||
@@ -127,10 +128,12 @@ bitmap_decompress1(char* output, int width, int height, char* input, int size)
|
||||
offset = 32;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Handle strange cases for counts */
|
||||
if (offset != 0)
|
||||
{
|
||||
isfillormix = ((opcode == 2) || (opcode == 7));
|
||||
|
||||
if (count == 0)
|
||||
{
|
||||
if (isfillormix)
|
||||
@@ -147,14 +150,17 @@ bitmap_decompress1(char* output, int width, int height, char* input, int size)
|
||||
count <<= 3;
|
||||
}
|
||||
}
|
||||
|
||||
/* Read preliminary data */
|
||||
switch (opcode)
|
||||
{
|
||||
case 0: /* Fill */
|
||||
|
||||
if ((lastopcode == opcode) && !((x == width) && (prevline == 0)))
|
||||
{
|
||||
insertmix = 1;
|
||||
}
|
||||
|
||||
break;
|
||||
case 8: /* Bicolor */
|
||||
color1 = CVAL(input);
|
||||
@@ -177,8 +183,10 @@ bitmap_decompress1(char* output, int width, int height, char* input, int size)
|
||||
fom_mask = 5;
|
||||
break;
|
||||
}
|
||||
|
||||
lastopcode = opcode;
|
||||
mixmask = 0;
|
||||
|
||||
/* Output body */
|
||||
while (count > 0)
|
||||
{
|
||||
@@ -188,14 +196,17 @@ bitmap_decompress1(char* output, int width, int height, char* input, int size)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
x = 0;
|
||||
height--;
|
||||
prevline = line;
|
||||
line = output + height * width;
|
||||
}
|
||||
|
||||
switch (opcode)
|
||||
{
|
||||
case 0: /* Fill */
|
||||
|
||||
if (insertmix)
|
||||
{
|
||||
if (prevline == 0)
|
||||
@@ -206,10 +217,12 @@ bitmap_decompress1(char* output, int width, int height, char* input, int size)
|
||||
{
|
||||
line[x] = prevline[x] ^ mix;
|
||||
}
|
||||
|
||||
insertmix = 0;
|
||||
count--;
|
||||
x++;
|
||||
}
|
||||
|
||||
if (prevline == 0)
|
||||
{
|
||||
REPEAT(line[x] = 0)
|
||||
@@ -218,8 +231,10 @@ bitmap_decompress1(char* output, int width, int height, char* input, int size)
|
||||
{
|
||||
REPEAT(line[x] = prevline[x])
|
||||
}
|
||||
|
||||
break;
|
||||
case 1: /* Mix */
|
||||
|
||||
if (prevline == 0)
|
||||
{
|
||||
REPEAT(line[x] = mix)
|
||||
@@ -228,13 +243,16 @@ bitmap_decompress1(char* output, int width, int height, char* input, int size)
|
||||
{
|
||||
REPEAT(line[x] = prevline[x] ^ mix)
|
||||
}
|
||||
|
||||
break;
|
||||
case 2: /* Fill or Mix */
|
||||
|
||||
if (prevline == 0)
|
||||
{
|
||||
REPEAT
|
||||
(
|
||||
MASK_UPDATE;
|
||||
|
||||
if (mask & mixmask)
|
||||
{
|
||||
line[x] = mix;
|
||||
@@ -250,6 +268,7 @@ bitmap_decompress1(char* output, int width, int height, char* input, int size)
|
||||
REPEAT
|
||||
(
|
||||
MASK_UPDATE;
|
||||
|
||||
if (mask & mixmask)
|
||||
{
|
||||
line[x] = prevline[x] ^ mix;
|
||||
@@ -260,6 +279,7 @@ bitmap_decompress1(char* output, int width, int height, char* input, int size)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
break;
|
||||
case 3: /* Color */
|
||||
REPEAT(line[x] = color2)
|
||||
@@ -270,6 +290,7 @@ bitmap_decompress1(char* output, int width, int height, char* input, int size)
|
||||
case 8: /* Bicolor */
|
||||
REPEAT
|
||||
(
|
||||
|
||||
if (bicolor)
|
||||
{
|
||||
line[x] = color2;
|
||||
@@ -295,6 +316,7 @@ bitmap_decompress1(char* output, int width, int height, char* input, int size)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -302,11 +324,11 @@ bitmap_decompress1(char* output, int width, int height, char* input, int size)
|
||||
/* 2 byte bitmap decompress */
|
||||
/* returns boolean */
|
||||
static int APP_CC
|
||||
bitmap_decompress2(char* output, int width, int height, char* input, int size)
|
||||
bitmap_decompress2(char *output, int width, int height, char *input, int size)
|
||||
{
|
||||
char* prevline;
|
||||
char* line;
|
||||
char* end;
|
||||
char *prevline;
|
||||
char *line;
|
||||
char *end;
|
||||
char color1[2];
|
||||
char color2[2];
|
||||
char mix[2];
|
||||
@@ -344,6 +366,7 @@ bitmap_decompress2(char* output, int width, int height, char* input, int size)
|
||||
fom_mask = 0;
|
||||
code = CVAL(input);
|
||||
opcode = code >> 4;
|
||||
|
||||
/* Handle different opcode forms */
|
||||
switch (opcode)
|
||||
{
|
||||
@@ -356,6 +379,7 @@ bitmap_decompress2(char* output, int width, int height, char* input, int size)
|
||||
break;
|
||||
case 0xf:
|
||||
opcode = code & 0xf;
|
||||
|
||||
if (opcode < 9)
|
||||
{
|
||||
count = CVAL(input);
|
||||
@@ -365,6 +389,7 @@ bitmap_decompress2(char* output, int width, int height, char* input, int size)
|
||||
{
|
||||
count = (opcode < 0xb) ? 8 : 1;
|
||||
}
|
||||
|
||||
offset = 0;
|
||||
break;
|
||||
default:
|
||||
@@ -373,10 +398,12 @@ bitmap_decompress2(char* output, int width, int height, char* input, int size)
|
||||
offset = 32;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Handle strange cases for counts */
|
||||
if (offset != 0)
|
||||
{
|
||||
isfillormix = ((opcode == 2) || (opcode == 7));
|
||||
|
||||
if (count == 0)
|
||||
{
|
||||
if (isfillormix)
|
||||
@@ -393,14 +420,17 @@ bitmap_decompress2(char* output, int width, int height, char* input, int size)
|
||||
count <<= 3;
|
||||
}
|
||||
}
|
||||
|
||||
/* Read preliminary data */
|
||||
switch (opcode)
|
||||
{
|
||||
case 0: /* Fill */
|
||||
|
||||
if ((lastopcode == opcode) && !((x == width) && (prevline == 0)))
|
||||
{
|
||||
insertmix = 1;
|
||||
}
|
||||
|
||||
break;
|
||||
case 8: /* Bicolor */
|
||||
color1[EIK0] = CVAL(input);
|
||||
@@ -426,8 +456,10 @@ bitmap_decompress2(char* output, int width, int height, char* input, int size)
|
||||
fom_mask = 5;
|
||||
break;
|
||||
}
|
||||
|
||||
lastopcode = opcode;
|
||||
mixmask = 0;
|
||||
|
||||
/* Output body */
|
||||
while (count > 0)
|
||||
{
|
||||
@@ -437,14 +469,17 @@ bitmap_decompress2(char* output, int width, int height, char* input, int size)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
x = 0;
|
||||
height--;
|
||||
prevline = line;
|
||||
line = output + height * (width * 2);
|
||||
}
|
||||
|
||||
switch (opcode)
|
||||
{
|
||||
case 0: /* Fill */
|
||||
|
||||
if (insertmix)
|
||||
{
|
||||
if (prevline == 0)
|
||||
@@ -457,10 +492,12 @@ bitmap_decompress2(char* output, int width, int height, char* input, int size)
|
||||
line[x * 2 + 0] = prevline[x * 2 + 0] ^ mix[0];
|
||||
line[x * 2 + 1] = prevline[x * 2 + 1] ^ mix[1];
|
||||
}
|
||||
|
||||
insertmix = 0;
|
||||
count--;
|
||||
x++;
|
||||
}
|
||||
|
||||
if (prevline == 0)
|
||||
{
|
||||
REPEAT
|
||||
@@ -477,8 +514,10 @@ bitmap_decompress2(char* output, int width, int height, char* input, int size)
|
||||
line[x * 2 + 1] = prevline[x * 2 + 1];
|
||||
)
|
||||
}
|
||||
|
||||
break;
|
||||
case 1: /* Mix */
|
||||
|
||||
if (prevline == 0)
|
||||
{
|
||||
REPEAT
|
||||
@@ -495,13 +534,16 @@ bitmap_decompress2(char* output, int width, int height, char* input, int size)
|
||||
line[x * 2 + 1] = prevline[x * 2 + 1] ^ mix[1];
|
||||
)
|
||||
}
|
||||
|
||||
break;
|
||||
case 2: /* Fill or Mix */
|
||||
|
||||
if (prevline == 0)
|
||||
{
|
||||
REPEAT
|
||||
(
|
||||
MASK_UPDATE;
|
||||
|
||||
if (mask & mixmask)
|
||||
{
|
||||
line[x * 2 + 0] = mix[0];
|
||||
@@ -519,6 +561,7 @@ bitmap_decompress2(char* output, int width, int height, char* input, int size)
|
||||
REPEAT
|
||||
(
|
||||
MASK_UPDATE;
|
||||
|
||||
if (mask & mixmask)
|
||||
{
|
||||
line[x * 2 + 0] = prevline[x * 2 + 0] ^ mix[0];
|
||||
@@ -531,6 +574,7 @@ bitmap_decompress2(char* output, int width, int height, char* input, int size)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
break;
|
||||
case 3: /* Color */
|
||||
REPEAT
|
||||
@@ -549,6 +593,7 @@ bitmap_decompress2(char* output, int width, int height, char* input, int size)
|
||||
case 8: /* Bicolor */
|
||||
REPEAT
|
||||
(
|
||||
|
||||
if (bicolor)
|
||||
{
|
||||
line[x * 2 + 0] = color2[0];
|
||||
@@ -584,6 +629,7 @@ bitmap_decompress2(char* output, int width, int height, char* input, int size)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -591,11 +637,11 @@ bitmap_decompress2(char* output, int width, int height, char* input, int size)
|
||||
/* 3 byte bitmap decompress */
|
||||
/* returns boolean */
|
||||
static int APP_CC
|
||||
bitmap_decompress3(char* output, int width, int height, char* input, int size)
|
||||
bitmap_decompress3(char *output, int width, int height, char *input, int size)
|
||||
{
|
||||
char* prevline;
|
||||
char* line;
|
||||
char* end;
|
||||
char *prevline;
|
||||
char *line;
|
||||
char *end;
|
||||
char color1[3];
|
||||
char color2[3];
|
||||
char mix[3];
|
||||
@@ -636,6 +682,7 @@ bitmap_decompress3(char* output, int width, int height, char* input, int size)
|
||||
fom_mask = 0;
|
||||
code = CVAL(input);
|
||||
opcode = code >> 4;
|
||||
|
||||
/* Handle different opcode forms */
|
||||
switch (opcode)
|
||||
{
|
||||
@@ -648,6 +695,7 @@ bitmap_decompress3(char* output, int width, int height, char* input, int size)
|
||||
break;
|
||||
case 0xf:
|
||||
opcode = code & 0xf;
|
||||
|
||||
if (opcode < 9)
|
||||
{
|
||||
count = CVAL(input);
|
||||
@@ -657,6 +705,7 @@ bitmap_decompress3(char* output, int width, int height, char* input, int size)
|
||||
{
|
||||
count = (opcode < 0xb) ? 8 : 1;
|
||||
}
|
||||
|
||||
offset = 0;
|
||||
break;
|
||||
default:
|
||||
@@ -665,10 +714,12 @@ bitmap_decompress3(char* output, int width, int height, char* input, int size)
|
||||
offset = 32;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Handle strange cases for counts */
|
||||
if (offset != 0)
|
||||
{
|
||||
isfillormix = ((opcode == 2) || (opcode == 7));
|
||||
|
||||
if (count == 0)
|
||||
{
|
||||
if (isfillormix)
|
||||
@@ -685,14 +736,17 @@ bitmap_decompress3(char* output, int width, int height, char* input, int size)
|
||||
count <<= 3;
|
||||
}
|
||||
}
|
||||
|
||||
/* Read preliminary data */
|
||||
switch (opcode)
|
||||
{
|
||||
case 0: /* Fill */
|
||||
|
||||
if ((lastopcode == opcode) && !((x == width) && (prevline == 0)))
|
||||
{
|
||||
insertmix = 1;
|
||||
}
|
||||
|
||||
break;
|
||||
case 8: /* Bicolor */
|
||||
color1[0] = CVAL(input);
|
||||
@@ -721,8 +775,10 @@ bitmap_decompress3(char* output, int width, int height, char* input, int size)
|
||||
fom_mask = 5;
|
||||
break;
|
||||
}
|
||||
|
||||
lastopcode = opcode;
|
||||
mixmask = 0;
|
||||
|
||||
/* Output body */
|
||||
while (count > 0)
|
||||
{
|
||||
@@ -732,14 +788,17 @@ bitmap_decompress3(char* output, int width, int height, char* input, int size)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
x = 0;
|
||||
height--;
|
||||
prevline = line;
|
||||
line = output + height * (width * 3);
|
||||
}
|
||||
|
||||
switch (opcode)
|
||||
{
|
||||
case 0: /* Fill */
|
||||
|
||||
if (insertmix)
|
||||
{
|
||||
if (prevline == 0)
|
||||
@@ -754,10 +813,12 @@ bitmap_decompress3(char* output, int width, int height, char* input, int size)
|
||||
line[x * 3 + 1] = prevline[x * 3 + 1] ^ mix[1];
|
||||
line[x * 3 + 2] = prevline[x * 3 + 2] ^ mix[2];
|
||||
}
|
||||
|
||||
insertmix = 0;
|
||||
count--;
|
||||
x++;
|
||||
}
|
||||
|
||||
if (prevline == 0)
|
||||
{
|
||||
REPEAT
|
||||
@@ -776,8 +837,10 @@ bitmap_decompress3(char* output, int width, int height, char* input, int size)
|
||||
line[x * 3 + 2] = prevline[x * 3 + 2];
|
||||
)
|
||||
}
|
||||
|
||||
break;
|
||||
case 1: /* Mix */
|
||||
|
||||
if (prevline == 0)
|
||||
{
|
||||
REPEAT
|
||||
@@ -796,13 +859,16 @@ bitmap_decompress3(char* output, int width, int height, char* input, int size)
|
||||
line[x * 3 + 2] = prevline[x * 3 + 2] ^ mix[2];
|
||||
)
|
||||
}
|
||||
|
||||
break;
|
||||
case 2: /* Fill or Mix */
|
||||
|
||||
if (prevline == 0)
|
||||
{
|
||||
REPEAT
|
||||
(
|
||||
MASK_UPDATE;
|
||||
|
||||
if (mask & mixmask)
|
||||
{
|
||||
line[x * 3 + 0] = mix[0];
|
||||
@@ -822,6 +888,7 @@ bitmap_decompress3(char* output, int width, int height, char* input, int size)
|
||||
REPEAT
|
||||
(
|
||||
MASK_UPDATE;
|
||||
|
||||
if (mask & mixmask)
|
||||
{
|
||||
line[x * 3 + 0] = prevline[x * 3 + 0] ^ mix[0];
|
||||
@@ -836,6 +903,7 @@ bitmap_decompress3(char* output, int width, int height, char* input, int size)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
break;
|
||||
case 3: /* Color */
|
||||
REPEAT
|
||||
@@ -856,6 +924,7 @@ bitmap_decompress3(char* output, int width, int height, char* input, int size)
|
||||
case 8: /* Bicolor */
|
||||
REPEAT
|
||||
(
|
||||
|
||||
if (bicolor)
|
||||
{
|
||||
line[x * 3 + 0] = color2[0];
|
||||
@@ -895,13 +964,14 @@ bitmap_decompress3(char* output, int width, int height, char* input, int size)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* returns boolean */
|
||||
int APP_CC
|
||||
rdp_bitmap_decompress(char* output, int width, int height, char* input,
|
||||
rdp_bitmap_decompress(char *output, int width, int height, char *input,
|
||||
int size, int Bpp)
|
||||
{
|
||||
int rv;
|
||||
@@ -921,5 +991,6 @@ rdp_bitmap_decompress(char* output, int width, int height, char* input,
|
||||
rv = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
+55
-35
@@ -1,34 +1,32 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
|
||||
librdp iso layer
|
||||
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* librdp iso layer
|
||||
*/
|
||||
|
||||
#include "rdp.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
struct rdp_iso* APP_CC
|
||||
rdp_iso_create(struct rdp_mcs* owner)
|
||||
struct rdp_iso *APP_CC
|
||||
rdp_iso_create(struct rdp_mcs *owner)
|
||||
{
|
||||
struct rdp_iso* self;
|
||||
struct rdp_iso *self;
|
||||
|
||||
self = (struct rdp_iso*)g_malloc(sizeof(struct rdp_iso), 1);
|
||||
self = (struct rdp_iso *)g_malloc(sizeof(struct rdp_iso), 1);
|
||||
self->mcs_layer = owner;
|
||||
self->tcp_layer = rdp_tcp_create(self);
|
||||
return self;
|
||||
@@ -36,12 +34,13 @@ rdp_iso_create(struct rdp_mcs* owner)
|
||||
|
||||
/*****************************************************************************/
|
||||
void APP_CC
|
||||
rdp_iso_delete(struct rdp_iso* self)
|
||||
rdp_iso_delete(struct rdp_iso *self)
|
||||
{
|
||||
if (self == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
rdp_tcp_delete(self->tcp_layer);
|
||||
g_free(self);
|
||||
}
|
||||
@@ -49,32 +48,39 @@ rdp_iso_delete(struct rdp_iso* self)
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
static int APP_CC
|
||||
rdp_iso_recv_msg(struct rdp_iso* self, struct stream* s, int* code)
|
||||
rdp_iso_recv_msg(struct rdp_iso *self, struct stream *s, int *code)
|
||||
{
|
||||
int ver;
|
||||
int len;
|
||||
|
||||
*code = 0;
|
||||
|
||||
if (rdp_tcp_recv(self->tcp_layer, s, 4) != 0)
|
||||
{
|
||||
DEBUG((" out rdp_iso_recv_msg error rdp_tcp_recv 1 failed"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint8(s, ver);
|
||||
|
||||
if (ver != 3)
|
||||
{
|
||||
DEBUG((" out rdp_iso_recv_msg error ver != 3"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint8s(s, 1);
|
||||
in_uint16_be(s, len);
|
||||
|
||||
if (rdp_tcp_recv(self->tcp_layer, s, len - 4) != 0)
|
||||
{
|
||||
DEBUG((" out rdp_iso_recv_msg error rdp_tcp_recv 2 failed"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint8s(s, 1);
|
||||
in_uint8(s, *code);
|
||||
|
||||
if (*code == ISO_PDU_DT)
|
||||
{
|
||||
in_uint8s(s, 1);
|
||||
@@ -83,17 +89,19 @@ rdp_iso_recv_msg(struct rdp_iso* self, struct stream* s, int* code)
|
||||
{
|
||||
in_uint8s(s, 5);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
static int APP_CC
|
||||
rdp_iso_send_msg(struct rdp_iso* self, struct stream* s, int code)
|
||||
rdp_iso_send_msg(struct rdp_iso *self, struct stream *s, int code)
|
||||
{
|
||||
if (rdp_tcp_init(self->tcp_layer, s) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
out_uint8(s, 3);
|
||||
out_uint8(s, 0);
|
||||
out_uint16_be(s, 11); /* length */
|
||||
@@ -103,17 +111,19 @@ rdp_iso_send_msg(struct rdp_iso* self, struct stream* s, int code)
|
||||
out_uint16_le(s, 0);
|
||||
out_uint8(s, 0);
|
||||
s_mark_end(s);
|
||||
|
||||
if (rdp_tcp_send(self->tcp_layer, s) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
int APP_CC
|
||||
rdp_iso_recv(struct rdp_iso* self, struct stream* s)
|
||||
rdp_iso_recv(struct rdp_iso *self, struct stream *s)
|
||||
{
|
||||
int code;
|
||||
|
||||
@@ -121,17 +131,19 @@ rdp_iso_recv(struct rdp_iso* self, struct stream* s)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (code != ISO_PDU_DT)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
int APP_CC
|
||||
rdp_iso_init(struct rdp_iso* self, struct stream* s)
|
||||
rdp_iso_init(struct rdp_iso *self, struct stream *s)
|
||||
{
|
||||
rdp_tcp_init(self->tcp_layer, s);
|
||||
s_push_layer(s, iso_hdr, 7);
|
||||
@@ -141,7 +153,7 @@ rdp_iso_init(struct rdp_iso* self, struct stream* s)
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
int APP_CC
|
||||
rdp_iso_send(struct rdp_iso* self, struct stream* s)
|
||||
rdp_iso_send(struct rdp_iso *self, struct stream *s)
|
||||
{
|
||||
int len;
|
||||
|
||||
@@ -153,30 +165,34 @@ rdp_iso_send(struct rdp_iso* self, struct stream* s)
|
||||
out_uint8(s, 2);
|
||||
out_uint8(s, ISO_PDU_DT);
|
||||
out_uint8(s, 0x80);
|
||||
|
||||
if (rdp_tcp_send(self->tcp_layer, s) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
int APP_CC
|
||||
rdp_iso_connect(struct rdp_iso* self, char* ip, char* port)
|
||||
rdp_iso_connect(struct rdp_iso *self, char *ip, char *port)
|
||||
{
|
||||
int code;
|
||||
struct stream* s;
|
||||
struct stream *s;
|
||||
|
||||
DEBUG((" in rdp_iso_connect"));
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
|
||||
if (rdp_tcp_connect(self->tcp_layer, ip, port) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
DEBUG((" out rdp_iso_connect error rdp_tcp_connect failed"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (rdp_iso_send_msg(self, s, ISO_PDU_CR) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
@@ -184,7 +200,9 @@ rdp_iso_connect(struct rdp_iso* self, char* ip, char* port)
|
||||
DEBUG((" out rdp_iso_connect error rdp_iso_send_msg failed"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
init_stream(s, 8192);
|
||||
|
||||
if (rdp_iso_recv_msg(self, s, &code) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
@@ -192,6 +210,7 @@ rdp_iso_connect(struct rdp_iso* self, char* ip, char* port)
|
||||
DEBUG((" out rdp_iso_connect error rdp_iso_recv_msg failed"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (code != ISO_PDU_CC)
|
||||
{
|
||||
free_stream(s);
|
||||
@@ -199,6 +218,7 @@ rdp_iso_connect(struct rdp_iso* self, char* ip, char* port)
|
||||
DEBUG((" out rdp_iso_connect error code != ISO_PDU_CC"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
DEBUG((" out rdp_iso_connect"));
|
||||
return 0;
|
||||
@@ -206,9 +226,9 @@ rdp_iso_connect(struct rdp_iso* self, char* ip, char* port)
|
||||
|
||||
/*****************************************************************************/
|
||||
int APP_CC
|
||||
rdp_iso_disconnect(struct rdp_iso* self)
|
||||
rdp_iso_disconnect(struct rdp_iso *self)
|
||||
{
|
||||
struct stream* s;
|
||||
struct stream *s;
|
||||
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
|
||||
+63
-52
@@ -1,54 +1,53 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
|
||||
licence
|
||||
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* licence
|
||||
*/
|
||||
|
||||
#include "rdp.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
struct rdp_lic* APP_CC
|
||||
rdp_lic_create(struct rdp_sec* owner)
|
||||
struct rdp_lic *APP_CC
|
||||
rdp_lic_create(struct rdp_sec *owner)
|
||||
{
|
||||
struct rdp_lic* self;
|
||||
struct rdp_lic *self;
|
||||
|
||||
self = (struct rdp_lic*)g_malloc(sizeof(struct rdp_lic), 1);
|
||||
self = (struct rdp_lic *)g_malloc(sizeof(struct rdp_lic), 1);
|
||||
self->sec_layer = owner;
|
||||
return self;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void APP_CC
|
||||
rdp_lic_delete(struct rdp_lic* self)
|
||||
rdp_lic_delete(struct rdp_lic *self)
|
||||
{
|
||||
if (self == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
g_free(self);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Generate a session key and RC4 keys, given client and server randoms */
|
||||
static void APP_CC
|
||||
rdp_lic_generate_keys(struct rdp_lic* self, char* client_random,
|
||||
char* server_random, char* pre_master_secret)
|
||||
rdp_lic_generate_keys(struct rdp_lic *self, char *client_random,
|
||||
char *server_random, char *pre_master_secret)
|
||||
{
|
||||
char master_secret[48];
|
||||
char key_block[48];
|
||||
@@ -67,7 +66,7 @@ rdp_lic_generate_keys(struct rdp_lic* self, char* client_random,
|
||||
|
||||
/*****************************************************************************/
|
||||
static void APP_CC
|
||||
rdp_lic_generate_hwid(struct rdp_lic* self, char* hwid)
|
||||
rdp_lic_generate_hwid(struct rdp_lic *self, char *hwid)
|
||||
{
|
||||
rdp_sec_buf_out_uint32(hwid, 2);
|
||||
g_strncpy(hwid + 4, self->sec_layer->rdp_layer->mod->hostname,
|
||||
@@ -77,13 +76,13 @@ rdp_lic_generate_hwid(struct rdp_lic* self, char* hwid)
|
||||
/*****************************************************************************/
|
||||
/* Present an existing licence to the server */
|
||||
static void APP_CC
|
||||
rdp_lic_present(struct rdp_lic* self, char* client_random, char* rsa_data,
|
||||
char* licence_data, int licence_size, char* hwid,
|
||||
char* signature)
|
||||
rdp_lic_present(struct rdp_lic *self, char *client_random, char *rsa_data,
|
||||
char *licence_data, int licence_size, char *hwid,
|
||||
char *signature)
|
||||
{
|
||||
int sec_flags;
|
||||
int length;
|
||||
struct stream* s;
|
||||
struct stream *s;
|
||||
|
||||
sec_flags = SEC_LICENCE_NEG;
|
||||
length = 16 + SEC_RANDOM_SIZE + SEC_MODULUS_SIZE + SEC_PADDING_SIZE +
|
||||
@@ -117,14 +116,14 @@ rdp_lic_present(struct rdp_lic* self, char* client_random, char* rsa_data,
|
||||
/*****************************************************************************/
|
||||
/* Send a licence request packet */
|
||||
static void APP_CC
|
||||
rdp_lic_send_request(struct rdp_lic* self, char* client_random,
|
||||
char* rsa_data, char* user, char* host)
|
||||
rdp_lic_send_request(struct rdp_lic *self, char *client_random,
|
||||
char *rsa_data, char *user, char *host)
|
||||
{
|
||||
int sec_flags;
|
||||
int userlen;
|
||||
int hostlen;
|
||||
int length;
|
||||
struct stream* s;
|
||||
struct stream *s;
|
||||
|
||||
sec_flags = SEC_LICENCE_NEG;
|
||||
userlen = g_strlen(user) + 1;
|
||||
@@ -158,15 +157,15 @@ rdp_lic_send_request(struct rdp_lic* self, char* client_random,
|
||||
/*****************************************************************************/
|
||||
/* Process a licence demand packet */
|
||||
static void APP_CC
|
||||
rdp_lic_process_demand(struct rdp_lic* self, struct stream* s)
|
||||
rdp_lic_process_demand(struct rdp_lic *self, struct stream *s)
|
||||
{
|
||||
char null_data[SEC_MODULUS_SIZE];
|
||||
char* server_random;
|
||||
char *server_random;
|
||||
char signature[LICENCE_SIGNATURE_SIZE];
|
||||
char hwid[LICENCE_HWID_SIZE];
|
||||
char* licence_data;
|
||||
char *licence_data;
|
||||
int licence_size;
|
||||
void* crypt_key;
|
||||
void *crypt_key;
|
||||
|
||||
licence_data = 0;
|
||||
/* Retrieve the server random from the incoming packet */
|
||||
@@ -176,6 +175,7 @@ rdp_lic_process_demand(struct rdp_lic* self, struct stream* s)
|
||||
g_memset(null_data, 0, sizeof(null_data));
|
||||
rdp_lic_generate_keys(self, null_data, server_random, null_data);
|
||||
licence_size = 0; /* todo load_licence(&licence_data); */
|
||||
|
||||
if (licence_size > 0)
|
||||
{
|
||||
/* Generate a signature for the HWID buffer */
|
||||
@@ -192,6 +192,7 @@ rdp_lic_process_demand(struct rdp_lic* self, struct stream* s)
|
||||
g_free(licence_data);
|
||||
return;
|
||||
}
|
||||
|
||||
rdp_lic_send_request(self, null_data, null_data,
|
||||
self->sec_layer->rdp_layer->mod->username,
|
||||
self->sec_layer->rdp_layer->mod->hostname);
|
||||
@@ -200,12 +201,12 @@ rdp_lic_process_demand(struct rdp_lic* self, struct stream* s)
|
||||
/*****************************************************************************/
|
||||
/* Send an authentication response packet */
|
||||
static void APP_CC
|
||||
rdp_lic_send_authresp(struct rdp_lic* self, char* token, char* crypt_hwid,
|
||||
char* signature)
|
||||
rdp_lic_send_authresp(struct rdp_lic *self, char *token, char *crypt_hwid,
|
||||
char *signature)
|
||||
{
|
||||
int sec_flags;
|
||||
int length;
|
||||
struct stream* s;
|
||||
struct stream *s;
|
||||
|
||||
sec_flags = SEC_LICENCE_NEG;
|
||||
length = 58;
|
||||
@@ -231,18 +232,20 @@ rdp_lic_send_authresp(struct rdp_lic* self, char* token, char* crypt_hwid,
|
||||
/* Parse an authentication request packet */
|
||||
/* returns boolean */
|
||||
static int APP_CC
|
||||
rdp_lic_parse_authreq(struct rdp_lic* self, struct stream* s,
|
||||
char** token, char** signature)
|
||||
rdp_lic_parse_authreq(struct rdp_lic *self, struct stream *s,
|
||||
char **token, char **signature)
|
||||
{
|
||||
int tokenlen;
|
||||
|
||||
in_uint8s(s, 6); /* unknown: f8 3d 15 00 04 f6 */
|
||||
in_uint16_le(s, tokenlen);
|
||||
|
||||
if (tokenlen != LICENCE_TOKEN_SIZE)
|
||||
{
|
||||
/* error("token len %d\n", tokenlen); */
|
||||
return 0;
|
||||
}
|
||||
|
||||
in_uint8p(s, *token, tokenlen);
|
||||
in_uint8p(s, *signature, LICENCE_SIGNATURE_SIZE);
|
||||
return s_check_end(s);
|
||||
@@ -251,17 +254,17 @@ rdp_lic_parse_authreq(struct rdp_lic* self, struct stream* s,
|
||||
/*****************************************************************************/
|
||||
/* Process an authentication request packet */
|
||||
static void APP_CC
|
||||
rdp_lic_process_authreq(struct rdp_lic* self, struct stream* s)
|
||||
rdp_lic_process_authreq(struct rdp_lic *self, struct stream *s)
|
||||
{
|
||||
char* in_token;
|
||||
char* in_sig;
|
||||
char *in_token;
|
||||
char *in_sig;
|
||||
char out_token[LICENCE_TOKEN_SIZE];
|
||||
char decrypt_token[LICENCE_TOKEN_SIZE];
|
||||
char hwid[LICENCE_HWID_SIZE];
|
||||
char crypt_hwid[LICENCE_HWID_SIZE];
|
||||
char sealed_buffer[LICENCE_TOKEN_SIZE + LICENCE_HWID_SIZE];
|
||||
char out_sig[LICENCE_SIGNATURE_SIZE];
|
||||
void* crypt_key;
|
||||
void *crypt_key;
|
||||
|
||||
in_token = 0;
|
||||
in_sig = 0;
|
||||
@@ -290,53 +293,61 @@ rdp_lic_process_authreq(struct rdp_lic* self, struct stream* s)
|
||||
/*****************************************************************************/
|
||||
/* Process an licence issue packet */
|
||||
static void APP_CC
|
||||
rdp_lic_process_issue(struct rdp_lic* self, struct stream* s)
|
||||
rdp_lic_process_issue(struct rdp_lic *self, struct stream *s)
|
||||
{
|
||||
void* crypt_key;
|
||||
void *crypt_key;
|
||||
int length;
|
||||
int check;
|
||||
int i;
|
||||
|
||||
in_uint8s(s, 2); /* 3d 45 - unknown */
|
||||
in_uint16_le(s, length);
|
||||
|
||||
if (!s_check_rem(s, length))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
crypt_key = ssl_rc4_info_create();
|
||||
ssl_rc4_set_key(crypt_key, self->licence_key, 16);
|
||||
ssl_rc4_crypt(crypt_key, s->p, length);
|
||||
ssl_rc4_info_delete(crypt_key);
|
||||
in_uint16_le(s, check);
|
||||
|
||||
if (check != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
self->licence_issued = 1;
|
||||
in_uint8s(s, 2); /* pad */
|
||||
/* advance to fourth string */
|
||||
length = 0;
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
in_uint8s(s, length);
|
||||
in_uint32_le(s, length);
|
||||
|
||||
if (!s_check_rem(s, length))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* todo save_licence(s->p, length); */
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/* Process a licence packet */
|
||||
void APP_CC
|
||||
rdp_lic_process(struct rdp_lic* self, struct stream* s)
|
||||
rdp_lic_process(struct rdp_lic *self, struct stream *s)
|
||||
{
|
||||
int tag;
|
||||
|
||||
in_uint8(s, tag);
|
||||
in_uint8s(s, 3); /* version, length */
|
||||
|
||||
switch (tag)
|
||||
{
|
||||
case LICENCE_TAG_DEMAND:
|
||||
|
||||
+120
-54
@@ -1,36 +1,34 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
|
||||
librdp mcs layer
|
||||
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* librdp mcs layer
|
||||
*/
|
||||
|
||||
#include "rdp.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
struct rdp_mcs* APP_CC
|
||||
rdp_mcs_create(struct rdp_sec* owner,
|
||||
struct stream* client_mcs_data,
|
||||
struct stream* server_mcs_data)
|
||||
struct rdp_mcs *APP_CC
|
||||
rdp_mcs_create(struct rdp_sec *owner,
|
||||
struct stream *client_mcs_data,
|
||||
struct stream *server_mcs_data)
|
||||
{
|
||||
struct rdp_mcs* self;
|
||||
struct rdp_mcs *self;
|
||||
|
||||
self = (struct rdp_mcs*)g_malloc(sizeof(struct rdp_mcs), 1);
|
||||
self = (struct rdp_mcs *)g_malloc(sizeof(struct rdp_mcs), 1);
|
||||
self->sec_layer = owner;
|
||||
self->userid = 1;
|
||||
self->client_mcs_data = client_mcs_data;
|
||||
@@ -41,12 +39,13 @@ rdp_mcs_create(struct rdp_sec* owner,
|
||||
|
||||
/*****************************************************************************/
|
||||
void APP_CC
|
||||
rdp_mcs_delete(struct rdp_mcs* self)
|
||||
rdp_mcs_delete(struct rdp_mcs *self)
|
||||
{
|
||||
if (self == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
rdp_iso_delete(self->iso_layer);
|
||||
g_free(self);
|
||||
}
|
||||
@@ -54,32 +53,38 @@ rdp_mcs_delete(struct rdp_mcs* self)
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
int APP_CC
|
||||
rdp_mcs_recv(struct rdp_mcs* self, struct stream* s, int* chan)
|
||||
rdp_mcs_recv(struct rdp_mcs *self, struct stream *s, int *chan)
|
||||
{
|
||||
int appid;
|
||||
int opcode;
|
||||
int len;
|
||||
|
||||
DEBUG((" in rdp_mcs_recv"));
|
||||
|
||||
if (rdp_iso_recv(self->iso_layer, s) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint8(s, opcode);
|
||||
appid = opcode >> 2;
|
||||
|
||||
if (appid != MCS_SDIN)
|
||||
{
|
||||
DEBUG((" out rdp_mcs_recv error"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint8s(s, 2);
|
||||
in_uint16_be(s, *chan);
|
||||
in_uint8s(s, 1);
|
||||
in_uint8(s, len);
|
||||
|
||||
if (len & 0x80)
|
||||
{
|
||||
in_uint8s(s, 1);
|
||||
}
|
||||
|
||||
DEBUG((" out rdp_mcs_recv"));
|
||||
return 0;
|
||||
}
|
||||
@@ -87,7 +92,7 @@ rdp_mcs_recv(struct rdp_mcs* self, struct stream* s, int* chan)
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
static int APP_CC
|
||||
rdp_mcs_ber_out_header(struct rdp_mcs* self, struct stream* s,
|
||||
rdp_mcs_ber_out_header(struct rdp_mcs *self, struct stream *s,
|
||||
int tag_val, int len)
|
||||
{
|
||||
if (tag_val > 0xff)
|
||||
@@ -98,6 +103,7 @@ rdp_mcs_ber_out_header(struct rdp_mcs* self, struct stream* s,
|
||||
{
|
||||
out_uint8(s, tag_val);
|
||||
}
|
||||
|
||||
if (len >= 0x80)
|
||||
{
|
||||
out_uint8(s, 0x82);
|
||||
@@ -107,6 +113,7 @@ rdp_mcs_ber_out_header(struct rdp_mcs* self, struct stream* s,
|
||||
{
|
||||
out_uint8(s, len);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -114,7 +121,7 @@ rdp_mcs_ber_out_header(struct rdp_mcs* self, struct stream* s,
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
static int APP_CC
|
||||
rdp_mcs_ber_out_int8(struct rdp_mcs* self, struct stream* s, int value)
|
||||
rdp_mcs_ber_out_int8(struct rdp_mcs *self, struct stream *s, int value)
|
||||
{
|
||||
rdp_mcs_ber_out_header(self, s, BER_TAG_INTEGER, 1);
|
||||
out_uint8(s, value);
|
||||
@@ -125,7 +132,7 @@ rdp_mcs_ber_out_int8(struct rdp_mcs* self, struct stream* s, int value)
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
static int APP_CC
|
||||
rdp_mcs_ber_out_int16(struct rdp_mcs* self, struct stream* s, int value)
|
||||
rdp_mcs_ber_out_int16(struct rdp_mcs *self, struct stream *s, int value)
|
||||
{
|
||||
rdp_mcs_ber_out_header(self, s, BER_TAG_INTEGER, 2);
|
||||
out_uint8(s, (value >> 8));
|
||||
@@ -137,7 +144,7 @@ rdp_mcs_ber_out_int16(struct rdp_mcs* self, struct stream* s, int value)
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
static int APP_CC
|
||||
rdp_mcs_ber_out_int24(struct rdp_mcs* self, struct stream* s, int value)
|
||||
rdp_mcs_ber_out_int24(struct rdp_mcs *self, struct stream *s, int value)
|
||||
{
|
||||
rdp_mcs_ber_out_header(self, s, BER_TAG_INTEGER, 3);
|
||||
out_uint8(s, (value >> 16));
|
||||
@@ -150,7 +157,7 @@ rdp_mcs_ber_out_int24(struct rdp_mcs* self, struct stream* s, int value)
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
static int APP_CC
|
||||
rdp_mcs_out_domain_params(struct rdp_mcs* self, struct stream* s,
|
||||
rdp_mcs_out_domain_params(struct rdp_mcs *self, struct stream *s,
|
||||
int max_channels,
|
||||
int max_users, int max_tokens,
|
||||
int max_pdu_size)
|
||||
@@ -170,21 +177,23 @@ rdp_mcs_out_domain_params(struct rdp_mcs* self, struct stream* s,
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
static int APP_CC
|
||||
rdp_mcs_send_connection_initial(struct rdp_mcs* self)
|
||||
rdp_mcs_send_connection_initial(struct rdp_mcs *self)
|
||||
{
|
||||
int data_len;
|
||||
int len;
|
||||
struct stream* s;
|
||||
struct stream *s;
|
||||
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
data_len = self->client_mcs_data->end - self->client_mcs_data->data;
|
||||
len = 7 + 3 * 34 + 4 + data_len;
|
||||
|
||||
if (rdp_iso_init(self->iso_layer, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rdp_mcs_ber_out_header(self, s, MCS_CONNECT_INITIAL, len);
|
||||
rdp_mcs_ber_out_header(self, s, BER_TAG_OCTET_STRING, 0); /* calling domain */
|
||||
rdp_mcs_ber_out_header(self, s, BER_TAG_OCTET_STRING, 0); /* called domain */
|
||||
@@ -196,11 +205,13 @@ rdp_mcs_send_connection_initial(struct rdp_mcs* self)
|
||||
rdp_mcs_ber_out_header(self, s, BER_TAG_OCTET_STRING, data_len);
|
||||
out_uint8p(s, self->client_mcs_data->data, data_len);
|
||||
s_mark_end(s);
|
||||
|
||||
if (rdp_iso_send(self->iso_layer, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
return 0;
|
||||
}
|
||||
@@ -208,8 +219,8 @@ rdp_mcs_send_connection_initial(struct rdp_mcs* self)
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
static int APP_CC
|
||||
rdp_mcs_ber_parse_header(struct rdp_mcs* self, struct stream* s,
|
||||
int tag_val, int* len)
|
||||
rdp_mcs_ber_parse_header(struct rdp_mcs *self, struct stream *s,
|
||||
int tag_val, int *len)
|
||||
{
|
||||
int tag;
|
||||
int l;
|
||||
@@ -223,15 +234,19 @@ rdp_mcs_ber_parse_header(struct rdp_mcs* self, struct stream* s,
|
||||
{
|
||||
in_uint8(s, tag);
|
||||
}
|
||||
|
||||
if (tag != tag_val)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint8(s, l);
|
||||
|
||||
if (l & 0x80)
|
||||
{
|
||||
l = l & ~0x80;
|
||||
*len = 0;
|
||||
|
||||
while (l > 0)
|
||||
{
|
||||
in_uint8(s, i);
|
||||
@@ -243,6 +258,7 @@ rdp_mcs_ber_parse_header(struct rdp_mcs* self, struct stream* s,
|
||||
{
|
||||
*len = l;
|
||||
}
|
||||
|
||||
if (s_check(s))
|
||||
{
|
||||
return 0;
|
||||
@@ -256,7 +272,7 @@ rdp_mcs_ber_parse_header(struct rdp_mcs* self, struct stream* s,
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
static int APP_CC
|
||||
rdp_mcs_parse_domain_params(struct rdp_mcs* self, struct stream* s)
|
||||
rdp_mcs_parse_domain_params(struct rdp_mcs *self, struct stream *s)
|
||||
{
|
||||
int len;
|
||||
|
||||
@@ -264,7 +280,9 @@ rdp_mcs_parse_domain_params(struct rdp_mcs* self, struct stream* s)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint8s(s, len);
|
||||
|
||||
if (s_check(s))
|
||||
{
|
||||
return 0;
|
||||
@@ -278,38 +296,45 @@ rdp_mcs_parse_domain_params(struct rdp_mcs* self, struct stream* s)
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
static int APP_CC
|
||||
rdp_mcs_recv_connection_response(struct rdp_mcs* self)
|
||||
rdp_mcs_recv_connection_response(struct rdp_mcs *self)
|
||||
{
|
||||
int len;
|
||||
int res;
|
||||
struct stream* s;
|
||||
struct stream *s;
|
||||
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
|
||||
if (rdp_iso_recv(self->iso_layer, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rdp_mcs_ber_parse_header(self, s, MCS_CONNECT_RESPONSE, &len);
|
||||
rdp_mcs_ber_parse_header(self, s, BER_TAG_RESULT, &len);
|
||||
in_uint8(s, res);
|
||||
|
||||
if (res != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rdp_mcs_ber_parse_header(self, s, BER_TAG_INTEGER, &len);
|
||||
in_uint8s(s, len); /* connect id */
|
||||
rdp_mcs_parse_domain_params(self, s);
|
||||
rdp_mcs_ber_parse_header(self, s, BER_TAG_OCTET_STRING, &len);
|
||||
|
||||
if (len > self->server_mcs_data->size)
|
||||
{
|
||||
len = self->server_mcs_data->size;
|
||||
}
|
||||
|
||||
in_uint8a(s, self->server_mcs_data->data, len);
|
||||
self->server_mcs_data->p = self->server_mcs_data->data;
|
||||
self->server_mcs_data->end = self->server_mcs_data->data + len;
|
||||
|
||||
if (s_check_end(s))
|
||||
{
|
||||
free_stream(s);
|
||||
@@ -325,26 +350,30 @@ rdp_mcs_recv_connection_response(struct rdp_mcs* self)
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
static int APP_CC
|
||||
rdp_mcs_send_edrq(struct rdp_mcs* self)
|
||||
rdp_mcs_send_edrq(struct rdp_mcs *self)
|
||||
{
|
||||
struct stream* s;
|
||||
struct stream *s;
|
||||
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
|
||||
if (rdp_iso_init(self->iso_layer, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
out_uint8(s, (MCS_EDRQ << 2));
|
||||
out_uint16_be(s, 0x100); /* height */
|
||||
out_uint16_be(s, 0x100); /* interval */
|
||||
s_mark_end(s);
|
||||
|
||||
if (rdp_iso_send(self->iso_layer, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
return 0;
|
||||
}
|
||||
@@ -352,24 +381,28 @@ rdp_mcs_send_edrq(struct rdp_mcs* self)
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
static int APP_CC
|
||||
rdp_mcs_send_aurq(struct rdp_mcs* self)
|
||||
rdp_mcs_send_aurq(struct rdp_mcs *self)
|
||||
{
|
||||
struct stream* s;
|
||||
struct stream *s;
|
||||
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
|
||||
if (rdp_iso_init(self->iso_layer, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
out_uint8(s, (MCS_AURQ << 2));
|
||||
s_mark_end(s);
|
||||
|
||||
if (rdp_iso_send(self->iso_layer, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
return 0;
|
||||
}
|
||||
@@ -377,40 +410,48 @@ rdp_mcs_send_aurq(struct rdp_mcs* self)
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
static int APP_CC
|
||||
rdp_mcs_recv_aucf(struct rdp_mcs* self)
|
||||
rdp_mcs_recv_aucf(struct rdp_mcs *self)
|
||||
{
|
||||
int opcode;
|
||||
int res;
|
||||
struct stream* s;
|
||||
struct stream *s;
|
||||
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
|
||||
if (rdp_iso_recv(self->iso_layer, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint8(s, opcode);
|
||||
|
||||
if ((opcode >> 2) != MCS_AUCF)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint8(s, res);
|
||||
|
||||
if (res != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (opcode & 2)
|
||||
{
|
||||
in_uint16_be(s, self->userid);
|
||||
}
|
||||
|
||||
if (!(s_check_end(s)))
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
return 0;
|
||||
}
|
||||
@@ -418,26 +459,30 @@ rdp_mcs_recv_aucf(struct rdp_mcs* self)
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
static int APP_CC
|
||||
rdp_mcs_send_cjrq(struct rdp_mcs* self, int chanid)
|
||||
rdp_mcs_send_cjrq(struct rdp_mcs *self, int chanid)
|
||||
{
|
||||
struct stream* s;
|
||||
struct stream *s;
|
||||
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
|
||||
if (rdp_iso_init(self->iso_layer, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
out_uint8(s, (MCS_CJRQ << 2));
|
||||
out_uint16_be(s, self->userid);
|
||||
out_uint16_be(s, chanid);
|
||||
s_mark_end(s);
|
||||
|
||||
if (rdp_iso_send(self->iso_layer, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
return 0;
|
||||
}
|
||||
@@ -445,41 +490,50 @@ rdp_mcs_send_cjrq(struct rdp_mcs* self, int chanid)
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
static int APP_CC
|
||||
rdp_mcs_recv_cjcf(struct rdp_mcs* self)
|
||||
rdp_mcs_recv_cjcf(struct rdp_mcs *self)
|
||||
{
|
||||
int opcode;
|
||||
int res;
|
||||
struct stream* s;
|
||||
struct stream *s;
|
||||
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
|
||||
if (rdp_iso_recv(self->iso_layer, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint8(s, opcode);
|
||||
|
||||
if ((opcode >> 2) != MCS_CJCF)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint8(s, res);
|
||||
|
||||
if (res != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint8s(s, 4); /* mcs_userid, req_chanid */
|
||||
|
||||
if (opcode & 2)
|
||||
{
|
||||
in_uint8s(s, 2); /* join_chanid */
|
||||
}
|
||||
|
||||
if (!(s_check_end(s)))
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
return 0;
|
||||
}
|
||||
@@ -487,15 +541,18 @@ rdp_mcs_recv_cjcf(struct rdp_mcs* self)
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
int APP_CC
|
||||
rdp_mcs_connect(struct rdp_mcs* self, char* ip, char* port)
|
||||
rdp_mcs_connect(struct rdp_mcs *self, char *ip, char *port)
|
||||
{
|
||||
DEBUG((" in rdp_mcs_connect"));
|
||||
|
||||
if (rdp_iso_connect(self->iso_layer, ip, port) != 0)
|
||||
{
|
||||
DEBUG((" out rdp_mcs_connect error rdp_iso_connect failed"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
rdp_mcs_send_connection_initial(self);
|
||||
|
||||
if (rdp_mcs_recv_connection_response(self) != 0)
|
||||
{
|
||||
rdp_iso_disconnect(self->iso_layer);
|
||||
@@ -503,28 +560,35 @@ rdp_mcs_connect(struct rdp_mcs* self, char* ip, char* port)
|
||||
failed"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
rdp_mcs_send_edrq(self);
|
||||
rdp_mcs_send_aurq(self);
|
||||
|
||||
if (rdp_mcs_recv_aucf(self) != 0)
|
||||
{
|
||||
rdp_iso_disconnect(self->iso_layer);
|
||||
DEBUG((" out rdp_mcs_connect error rdp_mcs_recv_aucf failed"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
rdp_mcs_send_cjrq(self, self->userid + 1001);
|
||||
|
||||
if (rdp_mcs_recv_cjcf(self) != 0)
|
||||
{
|
||||
rdp_iso_disconnect(self->iso_layer);
|
||||
DEBUG((" out rdp_mcs_connect error rdp_mcs_recv_cjcf 1 failed"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
rdp_mcs_send_cjrq(self, MCS_GLOBAL_CHANNEL);
|
||||
|
||||
if (rdp_mcs_recv_cjcf(self) != 0)
|
||||
{
|
||||
rdp_iso_disconnect(self->iso_layer);
|
||||
DEBUG((" out rdp_mcs_connect error rdp_mcs_recv_cjcf 2 failed"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
DEBUG((" out rdp_mcs_connect"));
|
||||
return 0;
|
||||
}
|
||||
@@ -532,7 +596,7 @@ failed"));
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
int APP_CC
|
||||
rdp_mcs_init(struct rdp_mcs* self, struct stream* s)
|
||||
rdp_mcs_init(struct rdp_mcs *self, struct stream *s)
|
||||
{
|
||||
rdp_iso_init(self->iso_layer, s);
|
||||
s_push_layer(s, mcs_hdr, 8);
|
||||
@@ -542,7 +606,7 @@ rdp_mcs_init(struct rdp_mcs* self, struct stream* s)
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
int APP_CC
|
||||
rdp_mcs_send(struct rdp_mcs* self, struct stream* s)
|
||||
rdp_mcs_send(struct rdp_mcs *self, struct stream *s)
|
||||
{
|
||||
int len;
|
||||
|
||||
@@ -554,9 +618,11 @@ rdp_mcs_send(struct rdp_mcs* self, struct stream* s)
|
||||
out_uint16_be(s, MCS_GLOBAL_CHANNEL);
|
||||
out_uint8(s, 0x70);
|
||||
out_uint16_be(s, len);
|
||||
|
||||
if (rdp_iso_send(self->iso_layer, s) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
+270
-110
File diff suppressed because it is too large
Load Diff
+177
-99
@@ -1,24 +1,22 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
|
||||
librdp rdp layer
|
||||
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* librdp rdp layer
|
||||
*/
|
||||
|
||||
#include "rdp.h"
|
||||
|
||||
@@ -27,12 +25,12 @@
|
||||
#endif
|
||||
|
||||
/*****************************************************************************/
|
||||
struct rdp_rdp* APP_CC
|
||||
rdp_rdp_create(struct mod* owner)
|
||||
struct rdp_rdp *APP_CC
|
||||
rdp_rdp_create(struct mod *owner)
|
||||
{
|
||||
struct rdp_rdp* self;
|
||||
struct rdp_rdp *self;
|
||||
|
||||
self = (struct rdp_rdp*)g_malloc(sizeof(struct rdp_rdp), 1);
|
||||
self = (struct rdp_rdp *)g_malloc(sizeof(struct rdp_rdp), 1);
|
||||
self->mod = owner;
|
||||
self->sec_layer = rdp_sec_create(self);
|
||||
self->bitmap_compression = 1;
|
||||
@@ -45,31 +43,35 @@ rdp_rdp_create(struct mod* owner)
|
||||
|
||||
/*****************************************************************************/
|
||||
void APP_CC
|
||||
rdp_rdp_delete(struct rdp_rdp* self)
|
||||
rdp_rdp_delete(struct rdp_rdp *self)
|
||||
{
|
||||
if (self == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
rdp_orders_delete(self->orders);
|
||||
rdp_sec_delete(self->sec_layer);
|
||||
|
||||
if (self->rec_fd != 0)
|
||||
{
|
||||
g_file_close(self->rec_fd);
|
||||
self->rec_fd = 0;
|
||||
}
|
||||
|
||||
g_free(self);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/* Initialise an RDP packet */
|
||||
int APP_CC
|
||||
rdp_rdp_init(struct rdp_rdp* self, struct stream* s)
|
||||
rdp_rdp_init(struct rdp_rdp *self, struct stream *s)
|
||||
{
|
||||
if (rdp_sec_init(self->sec_layer, s, SEC_ENCRYPT) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
s_push_layer(s, rdp_hdr, 6);
|
||||
return 0;
|
||||
}
|
||||
@@ -77,7 +79,7 @@ rdp_rdp_init(struct rdp_rdp* self, struct stream* s)
|
||||
/******************************************************************************/
|
||||
/* Send an RDP packet */
|
||||
int APP_CC
|
||||
rdp_rdp_send(struct rdp_rdp* self, struct stream* s, int pdu_type)
|
||||
rdp_rdp_send(struct rdp_rdp *self, struct stream *s, int pdu_type)
|
||||
{
|
||||
int len;
|
||||
int sec_flags;
|
||||
@@ -88,22 +90,25 @@ rdp_rdp_send(struct rdp_rdp* self, struct stream* s, int pdu_type)
|
||||
out_uint16_le(s, pdu_type | 0x10);
|
||||
out_uint16_le(s, self->sec_layer->mcs_layer->userid);
|
||||
sec_flags = SEC_ENCRYPT;
|
||||
|
||||
if (rdp_sec_send(self->sec_layer, s, sec_flags) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/* Initialise an RDP data packet */
|
||||
int APP_CC
|
||||
rdp_rdp_init_data(struct rdp_rdp* self, struct stream* s)
|
||||
rdp_rdp_init_data(struct rdp_rdp *self, struct stream *s)
|
||||
{
|
||||
if (rdp_sec_init(self->sec_layer, s, SEC_ENCRYPT) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
s_push_layer(s, rdp_hdr, 18);
|
||||
return 0;
|
||||
}
|
||||
@@ -111,7 +116,7 @@ rdp_rdp_init_data(struct rdp_rdp* self, struct stream* s)
|
||||
/******************************************************************************/
|
||||
/* Send an RDP data packet */
|
||||
int APP_CC
|
||||
rdp_rdp_send_data(struct rdp_rdp* self, struct stream* s, int pdu_data_type)
|
||||
rdp_rdp_send_data(struct rdp_rdp *self, struct stream *s, int pdu_data_type)
|
||||
{
|
||||
int len;
|
||||
int sec_flags;
|
||||
@@ -129,17 +134,19 @@ rdp_rdp_send_data(struct rdp_rdp* self, struct stream* s, int pdu_data_type)
|
||||
out_uint8(s, 0); /* compress type */
|
||||
out_uint16_le(s, 0); /* compress len */
|
||||
sec_flags = SEC_ENCRYPT;
|
||||
|
||||
if (rdp_sec_send(self->sec_layer, s, sec_flags) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/* Output general capability set */
|
||||
static int APP_CC
|
||||
rdp_rdp_out_general_caps(struct rdp_rdp* self, struct stream* s)
|
||||
rdp_rdp_out_general_caps(struct rdp_rdp *self, struct stream *s)
|
||||
{
|
||||
out_uint16_le(s, RDP_CAPSET_GENERAL);
|
||||
out_uint16_le(s, RDP_CAPLEN_GENERAL);
|
||||
@@ -159,7 +166,7 @@ rdp_rdp_out_general_caps(struct rdp_rdp* self, struct stream* s)
|
||||
/******************************************************************************/
|
||||
/* Output bitmap capability set */
|
||||
static int APP_CC
|
||||
rdp_rdp_out_bitmap_caps(struct rdp_rdp* self, struct stream* s)
|
||||
rdp_rdp_out_bitmap_caps(struct rdp_rdp *self, struct stream *s)
|
||||
{
|
||||
out_uint16_le(s, RDP_CAPSET_BITMAP);
|
||||
out_uint16_le(s, RDP_CAPLEN_BITMAP);
|
||||
@@ -181,7 +188,7 @@ rdp_rdp_out_bitmap_caps(struct rdp_rdp* self, struct stream* s)
|
||||
/******************************************************************************/
|
||||
/* Output order capability set */
|
||||
static int APP_CC
|
||||
rdp_rdp_out_order_caps(struct rdp_rdp* self, struct stream* s)
|
||||
rdp_rdp_out_order_caps(struct rdp_rdp *self, struct stream *s)
|
||||
{
|
||||
char order_caps[32];
|
||||
|
||||
@@ -224,7 +231,7 @@ rdp_rdp_out_order_caps(struct rdp_rdp* self, struct stream* s)
|
||||
/******************************************************************************/
|
||||
/* Output bitmap cache capability set */
|
||||
static int APP_CC
|
||||
rdp_rdp_out_bmpcache_caps(struct rdp_rdp* self, struct stream* s)
|
||||
rdp_rdp_out_bmpcache_caps(struct rdp_rdp *self, struct stream *s)
|
||||
{
|
||||
int Bpp = 0;
|
||||
|
||||
@@ -244,7 +251,7 @@ rdp_rdp_out_bmpcache_caps(struct rdp_rdp* self, struct stream* s)
|
||||
/******************************************************************************/
|
||||
/* Output control capability set */
|
||||
static int APP_CC
|
||||
rdp_rdp_out_control_caps(struct rdp_rdp* self, struct stream* s)
|
||||
rdp_rdp_out_control_caps(struct rdp_rdp *self, struct stream *s)
|
||||
{
|
||||
out_uint16_le(s, RDP_CAPSET_CONTROL);
|
||||
out_uint16_le(s, RDP_CAPLEN_CONTROL);
|
||||
@@ -258,7 +265,7 @@ rdp_rdp_out_control_caps(struct rdp_rdp* self, struct stream* s)
|
||||
/******************************************************************************/
|
||||
/* Output activation capability set */
|
||||
static int APP_CC
|
||||
rdp_rdp_out_activate_caps(struct rdp_rdp* self, struct stream* s)
|
||||
rdp_rdp_out_activate_caps(struct rdp_rdp *self, struct stream *s)
|
||||
{
|
||||
out_uint16_le(s, RDP_CAPSET_ACTIVATE);
|
||||
out_uint16_le(s, RDP_CAPLEN_ACTIVATE);
|
||||
@@ -272,7 +279,7 @@ rdp_rdp_out_activate_caps(struct rdp_rdp* self, struct stream* s)
|
||||
/******************************************************************************/
|
||||
/* Output pointer capability set */
|
||||
static int APP_CC
|
||||
rdp_rdp_out_pointer_caps(struct rdp_rdp* self, struct stream* s)
|
||||
rdp_rdp_out_pointer_caps(struct rdp_rdp *self, struct stream *s)
|
||||
{
|
||||
out_uint16_le(s, RDP_CAPSET_POINTER);
|
||||
out_uint16_le(s, RDP_CAPLEN_POINTER_MONO);
|
||||
@@ -284,7 +291,7 @@ rdp_rdp_out_pointer_caps(struct rdp_rdp* self, struct stream* s)
|
||||
/******************************************************************************/
|
||||
/* Output share capability set */
|
||||
static int APP_CC
|
||||
rdp_rdp_out_share_caps(struct rdp_rdp* self, struct stream* s)
|
||||
rdp_rdp_out_share_caps(struct rdp_rdp *self, struct stream *s)
|
||||
{
|
||||
out_uint16_le(s, RDP_CAPSET_SHARE);
|
||||
out_uint16_le(s, RDP_CAPLEN_SHARE);
|
||||
@@ -296,7 +303,7 @@ rdp_rdp_out_share_caps(struct rdp_rdp* self, struct stream* s)
|
||||
/******************************************************************************/
|
||||
/* Output color cache capability set */
|
||||
static int APP_CC
|
||||
rdp_rdp_out_colcache_caps(struct rdp_rdp* self, struct stream* s)
|
||||
rdp_rdp_out_colcache_caps(struct rdp_rdp *self, struct stream *s)
|
||||
{
|
||||
out_uint16_le(s, RDP_CAPSET_COLCACHE);
|
||||
out_uint16_le(s, RDP_CAPLEN_COLCACHE);
|
||||
@@ -305,38 +312,40 @@ rdp_rdp_out_colcache_caps(struct rdp_rdp* self, struct stream* s)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static char caps_0x0d[] = {
|
||||
0x01, 0x00, 0x00, 0x00, 0x09, 0x04, 0x00, 0x00,
|
||||
0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00
|
||||
static char caps_0x0d[] =
|
||||
{
|
||||
0x01, 0x00, 0x00, 0x00, 0x09, 0x04, 0x00, 0x00,
|
||||
0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
static char caps_0x0c[] = { 0x01, 0x00, 0x00, 0x00 };
|
||||
|
||||
static char caps_0x0e[] = { 0x01, 0x00, 0x00, 0x00 };
|
||||
|
||||
static char caps_0x10[] = {
|
||||
0xFE, 0x00, 0x04, 0x00, 0xFE, 0x00, 0x04, 0x00,
|
||||
0xFE, 0x00, 0x08, 0x00, 0xFE, 0x00, 0x08, 0x00,
|
||||
0xFE, 0x00, 0x10, 0x00, 0xFE, 0x00, 0x20, 0x00,
|
||||
0xFE, 0x00, 0x40, 0x00, 0xFE, 0x00, 0x80, 0x00,
|
||||
0xFE, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x08,
|
||||
0x00, 0x01, 0x00, 0x01, 0x02, 0x00, 0x00, 0x00
|
||||
static char caps_0x10[] =
|
||||
{
|
||||
0xFE, 0x00, 0x04, 0x00, 0xFE, 0x00, 0x04, 0x00,
|
||||
0xFE, 0x00, 0x08, 0x00, 0xFE, 0x00, 0x08, 0x00,
|
||||
0xFE, 0x00, 0x10, 0x00, 0xFE, 0x00, 0x20, 0x00,
|
||||
0xFE, 0x00, 0x40, 0x00, 0xFE, 0x00, 0x80, 0x00,
|
||||
0xFE, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x08,
|
||||
0x00, 0x01, 0x00, 0x01, 0x02, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
/* Output unknown capability sets */
|
||||
static int APP_CC
|
||||
rdp_rdp_out_unknown_caps(struct rdp_rdp* self, struct stream* s, int id,
|
||||
int length, char* caps)
|
||||
rdp_rdp_out_unknown_caps(struct rdp_rdp *self, struct stream *s, int id,
|
||||
int length, char *caps)
|
||||
{
|
||||
out_uint16_le(s, id);
|
||||
out_uint16_le(s, length);
|
||||
@@ -349,7 +358,7 @@ rdp_rdp_out_unknown_caps(struct rdp_rdp* self, struct stream* s, int id,
|
||||
/******************************************************************************/
|
||||
/* Send a confirm active PDU */
|
||||
static int APP_CC
|
||||
rdp_rdp_send_confirm_active(struct rdp_rdp* self, struct stream* s)
|
||||
rdp_rdp_send_confirm_active(struct rdp_rdp *self, struct stream *s)
|
||||
{
|
||||
int sec_flags;
|
||||
int caplen;
|
||||
@@ -362,10 +371,12 @@ rdp_rdp_send_confirm_active(struct rdp_rdp* self, struct stream* s)
|
||||
RDP_CAPLEN_POINTER_MONO + RDP_CAPLEN_SHARE +
|
||||
0x58 + 0x08 + 0x08 + 0x34 /* unknown caps */ +
|
||||
4 /* w2k fix, why? */ ;
|
||||
|
||||
if (rdp_sec_init(self->sec_layer, s, sec_flags) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
out_uint16_le(s, 2 + 14 + caplen + sizeof(RDP_SOURCE));
|
||||
out_uint16_le(s, (RDP_PDU_CONFIRM_ACTIVE | 0x10)); /* Version 1 */
|
||||
out_uint16_le(s, (self->sec_layer->mcs_layer->userid + 1001));
|
||||
@@ -390,28 +401,32 @@ rdp_rdp_send_confirm_active(struct rdp_rdp* self, struct stream* s)
|
||||
rdp_rdp_out_unknown_caps(self, s, 0x0e, 0x08, caps_0x0e);
|
||||
rdp_rdp_out_unknown_caps(self, s, 0x10, 0x34, caps_0x10); /* glyph cache? */
|
||||
s_mark_end(s);
|
||||
|
||||
if (rdp_sec_send(self->sec_layer, s, sec_flags) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/* Process a color pointer PDU */
|
||||
static int APP_CC
|
||||
rdp_rdp_process_color_pointer_pdu(struct rdp_rdp* self, struct stream* s)
|
||||
rdp_rdp_process_color_pointer_pdu(struct rdp_rdp *self, struct stream *s)
|
||||
{
|
||||
int cache_idx;
|
||||
int dlen;
|
||||
int mlen;
|
||||
struct rdp_cursor* cursor;
|
||||
struct rdp_cursor *cursor;
|
||||
|
||||
in_uint16_le(s, cache_idx);
|
||||
|
||||
if (cache_idx >= sizeof(self->cursors) / sizeof(cursor))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
cursor = self->cursors + cache_idx;
|
||||
in_uint16_le(s, cursor->x);
|
||||
in_uint16_le(s, cursor->y);
|
||||
@@ -419,10 +434,12 @@ rdp_rdp_process_color_pointer_pdu(struct rdp_rdp* self, struct stream* s)
|
||||
in_uint16_le(s, cursor->height);
|
||||
in_uint16_le(s, mlen); /* mask length */
|
||||
in_uint16_le(s, dlen); /* data length */
|
||||
|
||||
if ((mlen > sizeof(cursor->mask)) || (dlen > sizeof(cursor->data)))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint8a(s, cursor->data, dlen);
|
||||
in_uint8a(s, cursor->mask, mlen);
|
||||
self->mod->server_set_cursor(self->mod, cursor->x, cursor->y,
|
||||
@@ -433,16 +450,18 @@ rdp_rdp_process_color_pointer_pdu(struct rdp_rdp* self, struct stream* s)
|
||||
/******************************************************************************/
|
||||
/* Process a cached pointer PDU */
|
||||
static int APP_CC
|
||||
rdp_rdp_process_cached_pointer_pdu(struct rdp_rdp* self, struct stream* s)
|
||||
rdp_rdp_process_cached_pointer_pdu(struct rdp_rdp *self, struct stream *s)
|
||||
{
|
||||
int cache_idx;
|
||||
struct rdp_cursor* cursor;
|
||||
struct rdp_cursor *cursor;
|
||||
|
||||
in_uint16_le(s, cache_idx);
|
||||
|
||||
if (cache_idx >= sizeof(self->cursors) / sizeof(cursor))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
cursor = self->cursors + cache_idx;
|
||||
self->mod->server_set_cursor(self->mod, cursor->x, cursor->y,
|
||||
cursor->data, cursor->mask);
|
||||
@@ -452,16 +471,17 @@ rdp_rdp_process_cached_pointer_pdu(struct rdp_rdp* self, struct stream* s)
|
||||
/******************************************************************************/
|
||||
/* Process a system pointer PDU */
|
||||
static int APP_CC
|
||||
rdp_rdp_process_system_pointer_pdu(struct rdp_rdp* self, struct stream* s)
|
||||
rdp_rdp_process_system_pointer_pdu(struct rdp_rdp *self, struct stream *s)
|
||||
{
|
||||
int system_pointer_type;
|
||||
struct rdp_cursor* cursor;
|
||||
struct rdp_cursor *cursor;
|
||||
|
||||
in_uint16_le(s, system_pointer_type);
|
||||
|
||||
switch (system_pointer_type)
|
||||
{
|
||||
case RDP_NULL_POINTER:
|
||||
cursor = (struct rdp_cursor*)g_malloc(sizeof(struct rdp_cursor), 1);
|
||||
cursor = (struct rdp_cursor *)g_malloc(sizeof(struct rdp_cursor), 1);
|
||||
g_memset(cursor->mask, 0xff, sizeof(cursor->mask));
|
||||
self->mod->server_set_cursor(self->mod, cursor->x, cursor->y,
|
||||
cursor->data, cursor->mask);
|
||||
@@ -470,13 +490,14 @@ rdp_rdp_process_system_pointer_pdu(struct rdp_rdp* self, struct stream* s)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/* Process a pointer PDU */
|
||||
static int APP_CC
|
||||
rdp_rdp_process_pointer_pdu(struct rdp_rdp* self, struct stream* s)
|
||||
rdp_rdp_process_pointer_pdu(struct rdp_rdp *self, struct stream *s)
|
||||
{
|
||||
int message_type;
|
||||
int x;
|
||||
@@ -486,6 +507,7 @@ rdp_rdp_process_pointer_pdu(struct rdp_rdp* self, struct stream* s)
|
||||
rv = 0;
|
||||
in_uint16_le(s, message_type);
|
||||
in_uint8s(s, 2); /* pad */
|
||||
|
||||
switch (message_type)
|
||||
{
|
||||
case RDP_POINTER_MOVE:
|
||||
@@ -504,13 +526,14 @@ rdp_rdp_process_pointer_pdu(struct rdp_rdp* self, struct stream* s)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/* Process bitmap updates */
|
||||
static void APP_CC
|
||||
rdp_rdp_process_bitmap_updates(struct rdp_rdp* self, struct stream* s)
|
||||
rdp_rdp_process_bitmap_updates(struct rdp_rdp *self, struct stream *s)
|
||||
{
|
||||
int num_updates = 0;
|
||||
int left = 0;
|
||||
@@ -529,11 +552,12 @@ rdp_rdp_process_bitmap_updates(struct rdp_rdp* self, struct stream* s)
|
||||
int i = 0;
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
char* data = NULL;
|
||||
char* bmpdata0 = NULL;
|
||||
char* bmpdata1 = NULL;
|
||||
char *data = NULL;
|
||||
char *bmpdata0 = NULL;
|
||||
char *bmpdata1 = NULL;
|
||||
|
||||
in_uint16_le(s, num_updates);
|
||||
|
||||
for (i = 0; i < num_updates; i++)
|
||||
{
|
||||
in_uint16_le(s, left);
|
||||
@@ -548,7 +572,8 @@ rdp_rdp_process_bitmap_updates(struct rdp_rdp* self, struct stream* s)
|
||||
in_uint16_le(s, bufsize);
|
||||
cx = (right - left) + 1;
|
||||
cy = (bottom - top) + 1;
|
||||
bmpdata0 = (char*)g_malloc(width * height * Bpp, 0);
|
||||
bmpdata0 = (char *)g_malloc(width * height * Bpp, 0);
|
||||
|
||||
if (compress)
|
||||
{
|
||||
if (compress & 0x400)
|
||||
@@ -561,6 +586,7 @@ rdp_rdp_process_bitmap_updates(struct rdp_rdp* self, struct stream* s)
|
||||
in_uint16_le(s, size);
|
||||
in_uint8s(s, 4); /* line_size, final_size */
|
||||
}
|
||||
|
||||
in_uint8p(s, data, size);
|
||||
rdp_bitmap_decompress(bmpdata0, width, height, data, size, Bpp);
|
||||
bmpdata1 = rdp_orders_convert_bitmap(bpp, self->mod->xrdp_bpp,
|
||||
@@ -574,6 +600,7 @@ rdp_rdp_process_bitmap_updates(struct rdp_rdp* self, struct stream* s)
|
||||
for (y = 0; y < height; y++)
|
||||
{
|
||||
data = bmpdata0 + ((height - y) - 1) * (width * Bpp);
|
||||
|
||||
if (Bpp == 1)
|
||||
{
|
||||
for (x = 0; x < width; x++)
|
||||
@@ -585,7 +612,7 @@ rdp_rdp_process_bitmap_updates(struct rdp_rdp* self, struct stream* s)
|
||||
{
|
||||
for (x = 0; x < width; x++)
|
||||
{
|
||||
in_uint16_le(s, ((tui16*)data)[x]);
|
||||
in_uint16_le(s, ((tui16 *)data)[x]);
|
||||
}
|
||||
}
|
||||
else if (Bpp == 3)
|
||||
@@ -598,16 +625,19 @@ rdp_rdp_process_bitmap_updates(struct rdp_rdp* self, struct stream* s)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bmpdata1 = rdp_orders_convert_bitmap(bpp, self->mod->xrdp_bpp,
|
||||
bmpdata0, width, height,
|
||||
self->colormap.colors);
|
||||
self->mod->server_paint_rect(self->mod, left, top, cx, cy, bmpdata1,
|
||||
width, height, 0, 0);
|
||||
}
|
||||
|
||||
if (bmpdata0 != bmpdata1)
|
||||
{
|
||||
g_free(bmpdata1);
|
||||
}
|
||||
|
||||
g_free(bmpdata0);
|
||||
}
|
||||
}
|
||||
@@ -615,7 +645,7 @@ rdp_rdp_process_bitmap_updates(struct rdp_rdp* self, struct stream* s)
|
||||
/******************************************************************************/
|
||||
/* Process a palette update */
|
||||
static void APP_CC
|
||||
rdp_rdp_process_palette(struct rdp_rdp* self, struct stream* s)
|
||||
rdp_rdp_process_palette(struct rdp_rdp *self, struct stream *s)
|
||||
{
|
||||
int i;
|
||||
int r;
|
||||
@@ -625,6 +655,7 @@ rdp_rdp_process_palette(struct rdp_rdp* self, struct stream* s)
|
||||
in_uint8s(s, 2); /* pad */
|
||||
in_uint16_le(s, self->colormap.ncolors);
|
||||
in_uint8s(s, 2); /* pad */
|
||||
|
||||
for (i = 0; i < self->colormap.ncolors; i++)
|
||||
{
|
||||
in_uint8(s, r);
|
||||
@@ -632,19 +663,21 @@ rdp_rdp_process_palette(struct rdp_rdp* self, struct stream* s)
|
||||
in_uint8(s, b);
|
||||
self->colormap.colors[i] = (r << 16) | (g << 8) | b;
|
||||
}
|
||||
|
||||
//ui_set_colormap(hmap);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/* Process an update PDU */
|
||||
static int APP_CC
|
||||
rdp_rdp_process_update_pdu(struct rdp_rdp* self, struct stream* s)
|
||||
rdp_rdp_process_update_pdu(struct rdp_rdp *self, struct stream *s)
|
||||
{
|
||||
int update_type;
|
||||
int count;
|
||||
|
||||
in_uint16_le(s, update_type);
|
||||
self->mod->server_begin_update(self->mod);
|
||||
|
||||
switch (update_type)
|
||||
{
|
||||
case RDP_UPDATE_ORDERS:
|
||||
@@ -664,6 +697,7 @@ rdp_rdp_process_update_pdu(struct rdp_rdp* self, struct stream* s)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
self->mod->server_end_update(self->mod);
|
||||
return 0;
|
||||
}
|
||||
@@ -671,24 +705,26 @@ rdp_rdp_process_update_pdu(struct rdp_rdp* self, struct stream* s)
|
||||
|
||||
/******************************************************************************/
|
||||
void APP_CC
|
||||
rdp_rdp_out_unistr(struct stream* s, char* text)
|
||||
rdp_rdp_out_unistr(struct stream *s, char *text)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
|
||||
while (text[i] != 0)
|
||||
{
|
||||
out_uint8(s, text[i]);
|
||||
out_uint8(s, 0);
|
||||
i++;
|
||||
}
|
||||
|
||||
out_uint8(s, 0);
|
||||
out_uint8(s, 0);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
int APP_CC
|
||||
rdp_rdp_send_login_info(struct rdp_rdp* self, int flags)
|
||||
rdp_rdp_send_login_info(struct rdp_rdp *self, int flags)
|
||||
{
|
||||
int len_domain;
|
||||
int len_username;
|
||||
@@ -696,7 +732,7 @@ rdp_rdp_send_login_info(struct rdp_rdp* self, int flags)
|
||||
int len_program;
|
||||
int len_directory;
|
||||
int sec_flags;
|
||||
struct stream* s;
|
||||
struct stream *s;
|
||||
|
||||
DEBUG(("in rdp_rdp_send_login_info"));
|
||||
make_stream(s);
|
||||
@@ -707,12 +743,14 @@ rdp_rdp_send_login_info(struct rdp_rdp* self, int flags)
|
||||
len_program = 2 * g_strlen(self->mod->program);
|
||||
len_directory = 2 * g_strlen(self->mod->directory);
|
||||
sec_flags = SEC_LOGON_INFO | SEC_ENCRYPT;
|
||||
|
||||
if (rdp_sec_init(self->sec_layer, s, sec_flags) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
DEBUG(("out rdp_rdp_send_login_info error 1"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
out_uint32_le(s, 0);
|
||||
out_uint32_le(s, flags);
|
||||
out_uint16_le(s, len_domain);
|
||||
@@ -726,12 +764,14 @@ rdp_rdp_send_login_info(struct rdp_rdp* self, int flags)
|
||||
rdp_rdp_out_unistr(s, self->mod->program);
|
||||
rdp_rdp_out_unistr(s, self->mod->directory);
|
||||
s_mark_end(s);
|
||||
|
||||
if (rdp_sec_send(self->sec_layer, s, sec_flags) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
DEBUG(("out rdp_rdp_send_login_info error 2"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
DEBUG(("out rdp_rdp_send_login_info"));
|
||||
return 0;
|
||||
@@ -739,33 +779,37 @@ rdp_rdp_send_login_info(struct rdp_rdp* self, int flags)
|
||||
|
||||
/******************************************************************************/
|
||||
int APP_CC
|
||||
rdp_rdp_connect(struct rdp_rdp* self, char* ip, char* port)
|
||||
rdp_rdp_connect(struct rdp_rdp *self, char *ip, char *port)
|
||||
{
|
||||
int flags;
|
||||
|
||||
DEBUG(("in rdp_rdp_connect"));
|
||||
flags = RDP_LOGON_NORMAL;
|
||||
|
||||
if (g_strlen(self->mod->password) > 0)
|
||||
{
|
||||
flags |= RDP_LOGON_AUTO;
|
||||
}
|
||||
|
||||
if (rdp_sec_connect(self->sec_layer, ip, port) != 0)
|
||||
{
|
||||
DEBUG(("out rdp_rdp_connect error rdp_sec_connect failed"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (rdp_rdp_send_login_info(self, flags) != 0)
|
||||
{
|
||||
DEBUG(("out rdp_rdp_connect error rdp_rdp_send_login_info failed"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
DEBUG(("out rdp_rdp_connect"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
int APP_CC
|
||||
rdp_rdp_send_input(struct rdp_rdp* self, struct stream* s,
|
||||
rdp_rdp_send_input(struct rdp_rdp *self, struct stream *s,
|
||||
int time, int message_type,
|
||||
int device_flags, int param1, int param2)
|
||||
{
|
||||
@@ -773,6 +817,7 @@ rdp_rdp_send_input(struct rdp_rdp* self, struct stream* s,
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
out_uint16_le(s, 1); /* number of events */
|
||||
out_uint16_le(s, 0);
|
||||
out_uint32_le(s, time);
|
||||
@@ -781,38 +826,43 @@ rdp_rdp_send_input(struct rdp_rdp* self, struct stream* s,
|
||||
out_uint16_le(s, param1);
|
||||
out_uint16_le(s, param2);
|
||||
s_mark_end(s);
|
||||
|
||||
if (rdp_rdp_send_data(self, s, RDP_DATA_PDU_INPUT) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
int APP_CC
|
||||
rdp_rdp_send_invalidate(struct rdp_rdp* self, struct stream* s,
|
||||
rdp_rdp_send_invalidate(struct rdp_rdp *self, struct stream *s,
|
||||
int left, int top, int width, int height)
|
||||
{
|
||||
if (rdp_rdp_init_data(self, s) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
out_uint32_le(s, 1);
|
||||
out_uint16_le(s, left);
|
||||
out_uint16_le(s, top);
|
||||
out_uint16_le(s, (left + width) - 1);
|
||||
out_uint16_le(s, (top + height) - 1);
|
||||
s_mark_end(s);
|
||||
|
||||
if (rdp_rdp_send_data(self, s, 33) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
int APP_CC
|
||||
rdp_rdp_recv(struct rdp_rdp* self, struct stream* s, int* type)
|
||||
rdp_rdp_recv(struct rdp_rdp *self, struct stream *s, int *type)
|
||||
{
|
||||
int len;
|
||||
int pdu_type;
|
||||
@@ -820,6 +870,7 @@ rdp_rdp_recv(struct rdp_rdp* self, struct stream* s, int* type)
|
||||
|
||||
chan = 0;
|
||||
DEBUG(("in rdp_rdp_recv"));
|
||||
|
||||
if (s->next_packet >= s->end || s->next_packet == 0)
|
||||
{
|
||||
if (rdp_sec_recv(self->sec_layer, s, &chan) != 0)
|
||||
@@ -827,6 +878,7 @@ rdp_rdp_recv(struct rdp_rdp* self, struct stream* s, int* type)
|
||||
DEBUG(("error in rdp_rdp_recv, rdp_sec_recv failed"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
s->next_packet = s->p;
|
||||
}
|
||||
else
|
||||
@@ -834,16 +886,19 @@ rdp_rdp_recv(struct rdp_rdp* self, struct stream* s, int* type)
|
||||
chan = MCS_GLOBAL_CHANNEL;
|
||||
s->p = s->next_packet;
|
||||
}
|
||||
|
||||
if (chan == MCS_GLOBAL_CHANNEL)
|
||||
{
|
||||
in_uint16_le(s, len);
|
||||
DEBUG(("rdp_rdp_recv got %d len", len));
|
||||
|
||||
if (len == 0x8000)
|
||||
{
|
||||
s->next_packet += 8;
|
||||
DEBUG(("out rdp_rdp_recv"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
in_uint16_le(s, pdu_type);
|
||||
in_uint8s(s, 2);
|
||||
*type = pdu_type & 0xf;
|
||||
@@ -855,6 +910,7 @@ rdp_rdp_recv(struct rdp_rdp* self, struct stream* s, int* type)
|
||||
DEBUG(("got channel data channel %d", chan));
|
||||
s->next_packet = s->end;
|
||||
}
|
||||
|
||||
DEBUG(("out rdp_rdp_recv"));
|
||||
return 0;
|
||||
}
|
||||
@@ -862,14 +918,14 @@ rdp_rdp_recv(struct rdp_rdp* self, struct stream* s, int* type)
|
||||
|
||||
/******************************************************************************/
|
||||
static int APP_CC
|
||||
rdp_rdp_process_disconnect_pdu(struct rdp_rdp* self, struct stream* s)
|
||||
rdp_rdp_process_disconnect_pdu(struct rdp_rdp *self, struct stream *s)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
int APP_CC
|
||||
rdp_rdp_process_data_pdu(struct rdp_rdp* self, struct stream* s)
|
||||
rdp_rdp_process_data_pdu(struct rdp_rdp *self, struct stream *s)
|
||||
{
|
||||
int data_pdu_type;
|
||||
int ctype;
|
||||
@@ -882,6 +938,7 @@ rdp_rdp_process_data_pdu(struct rdp_rdp* self, struct stream* s)
|
||||
in_uint8(s, data_pdu_type);
|
||||
in_uint8(s, ctype);
|
||||
in_uint8s(s, 2); /* clen */
|
||||
|
||||
switch (data_pdu_type)
|
||||
{
|
||||
case RDP_DATA_PDU_UPDATE:
|
||||
@@ -904,20 +961,21 @@ rdp_rdp_process_data_pdu(struct rdp_rdp* self, struct stream* s)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/* Process a bitmap capability set */
|
||||
static void APP_CC
|
||||
rdp_rdp_process_general_caps(struct rdp_rdp* self, struct stream* s)
|
||||
rdp_rdp_process_general_caps(struct rdp_rdp *self, struct stream *s)
|
||||
{
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/* Process a bitmap capability set */
|
||||
static void APP_CC
|
||||
rdp_rdp_process_bitmap_caps(struct rdp_rdp* self, struct stream* s)
|
||||
rdp_rdp_process_bitmap_caps(struct rdp_rdp *self, struct stream *s)
|
||||
{
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
@@ -935,27 +993,30 @@ rdp_rdp_process_bitmap_caps(struct rdp_rdp* self, struct stream* s)
|
||||
/* Process server capabilities */
|
||||
/* returns error */
|
||||
static int APP_CC
|
||||
rdp_rdp_process_server_caps(struct rdp_rdp* self, struct stream* s, int len)
|
||||
rdp_rdp_process_server_caps(struct rdp_rdp *self, struct stream *s, int len)
|
||||
{
|
||||
int n = 0;
|
||||
int ncapsets = 0;
|
||||
int capset_type = 0;
|
||||
int capset_length = 0;
|
||||
char* next = NULL;
|
||||
char* start = NULL;
|
||||
char *next = NULL;
|
||||
char *start = NULL;
|
||||
|
||||
start = s->p;
|
||||
in_uint16_le(s, ncapsets);
|
||||
in_uint8s(s, 2); /* pad */
|
||||
|
||||
for (n = 0; n < ncapsets; n++)
|
||||
{
|
||||
if (s->p > start + len)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
in_uint16_le(s, capset_type);
|
||||
in_uint16_le(s, capset_length);
|
||||
next = (s->p + capset_length) - 4;
|
||||
|
||||
switch (capset_type)
|
||||
{
|
||||
case RDP_CAPSET_GENERAL:
|
||||
@@ -967,8 +1028,10 @@ rdp_rdp_process_server_caps(struct rdp_rdp* self, struct stream* s, int len)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
s->p = next;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -976,20 +1039,23 @@ rdp_rdp_process_server_caps(struct rdp_rdp* self, struct stream* s, int len)
|
||||
/* Send a control PDU */
|
||||
/* returns error */
|
||||
static int APP_CC
|
||||
rdp_rdp_send_control(struct rdp_rdp* self, struct stream* s, int action)
|
||||
rdp_rdp_send_control(struct rdp_rdp *self, struct stream *s, int action)
|
||||
{
|
||||
if (rdp_rdp_init_data(self, s) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
out_uint16_le(s, action);
|
||||
out_uint16_le(s, 0); /* userid */
|
||||
out_uint32_le(s, 0); /* control id */
|
||||
s_mark_end(s);
|
||||
|
||||
if (rdp_rdp_send_data(self, s, RDP_DATA_PDU_CONTROL) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -997,47 +1063,53 @@ rdp_rdp_send_control(struct rdp_rdp* self, struct stream* s, int action)
|
||||
/* Send a synchronisation PDU */
|
||||
/* returns error */
|
||||
static int APP_CC
|
||||
rdp_rdp_send_synchronise(struct rdp_rdp* self, struct stream* s)
|
||||
rdp_rdp_send_synchronise(struct rdp_rdp *self, struct stream *s)
|
||||
{
|
||||
if (rdp_rdp_init_data(self, s) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
out_uint16_le(s, 1); /* type */
|
||||
out_uint16_le(s, 1002);
|
||||
s_mark_end(s);
|
||||
|
||||
if (rdp_rdp_send_data(self, s, RDP_DATA_PDU_SYNCHRONISE) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/* Send an (empty) font information PDU */
|
||||
static int APP_CC
|
||||
rdp_rdp_send_fonts(struct rdp_rdp* self, struct stream* s, int seq)
|
||||
rdp_rdp_send_fonts(struct rdp_rdp *self, struct stream *s, int seq)
|
||||
{
|
||||
if (rdp_rdp_init_data(self, s) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
out_uint16_le(s, 0); /* number of fonts */
|
||||
out_uint16_le(s, 0); /* pad? */
|
||||
out_uint16_le(s, seq); /* unknown */
|
||||
out_uint16_le(s, 0x32); /* entry size */
|
||||
s_mark_end(s);
|
||||
|
||||
if (rdp_rdp_send_data(self, s, RDP_DATA_PDU_FONT2) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/* Respond to a demand active PDU */
|
||||
int APP_CC
|
||||
rdp_rdp_process_demand_active(struct rdp_rdp* self, struct stream* s)
|
||||
rdp_rdp_process_demand_active(struct rdp_rdp *self, struct stream *s)
|
||||
{
|
||||
int type = 0;
|
||||
int len_src_descriptor = 0;
|
||||
@@ -1065,28 +1137,32 @@ rdp_rdp_process_demand_active(struct rdp_rdp* self, struct stream* s)
|
||||
|
||||
/******************************************************************************/
|
||||
int APP_CC
|
||||
rdp_rec_check_file(struct rdp_rdp* self)
|
||||
rdp_rec_check_file(struct rdp_rdp *self)
|
||||
{
|
||||
char file_name[256];
|
||||
int index = 0;
|
||||
int len = 0;
|
||||
struct stream* s = (struct stream *)NULL;
|
||||
struct stream *s = (struct stream *)NULL;
|
||||
|
||||
g_memset(file_name,0,sizeof(char) * 256);
|
||||
g_memset(file_name, 0, sizeof(char) * 256);
|
||||
|
||||
if (self->rec_fd == 0)
|
||||
{
|
||||
index = 1;
|
||||
g_sprintf(file_name, "rec%8.8d.rec", index);
|
||||
|
||||
while (g_file_exist(file_name))
|
||||
{
|
||||
index++;
|
||||
|
||||
if (index >= 9999)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
g_sprintf(file_name, "rec%8.8d.rec", index);
|
||||
}
|
||||
|
||||
self->rec_fd = g_file_open(file_name);
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
@@ -1097,12 +1173,13 @@ rdp_rec_check_file(struct rdp_rdp* self)
|
||||
g_file_write(self->rec_fd, s->data, len);
|
||||
free_stream(s);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
int APP_CC
|
||||
rdp_rec_write_item(struct rdp_rdp* self, struct stream* s)
|
||||
rdp_rec_write_item(struct rdp_rdp *self, struct stream *s)
|
||||
{
|
||||
int len = 0;
|
||||
int time = 0;
|
||||
@@ -1111,6 +1188,7 @@ rdp_rec_write_item(struct rdp_rdp* self, struct stream* s)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
time = g_time1();
|
||||
out_uint32_le(s, time);
|
||||
s_mark_end(s);
|
||||
|
||||
+127
-69
@@ -1,44 +1,46 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
|
||||
librdp secure layer
|
||||
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* librdp secure layer
|
||||
*/
|
||||
|
||||
#include "rdp.h"
|
||||
|
||||
static char g_pad_54[40] =
|
||||
{ 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54,
|
||||
{
|
||||
54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54,
|
||||
54, 54, 54, 54, 54, 54, 54, 54 };
|
||||
54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54,
|
||||
54, 54, 54, 54, 54, 54, 54, 54
|
||||
};
|
||||
|
||||
static char g_pad_92[48] =
|
||||
{ 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92,
|
||||
{
|
||||
92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92,
|
||||
92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92 };
|
||||
92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92,
|
||||
92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
struct rdp_sec* APP_CC
|
||||
rdp_sec_create(struct rdp_rdp* owner)
|
||||
struct rdp_sec *APP_CC
|
||||
rdp_sec_create(struct rdp_rdp *owner)
|
||||
{
|
||||
struct rdp_sec* self;
|
||||
struct rdp_sec *self;
|
||||
|
||||
self = (struct rdp_sec*)g_malloc(sizeof(struct rdp_sec), 1);
|
||||
self = (struct rdp_sec *)g_malloc(sizeof(struct rdp_sec), 1);
|
||||
self->rdp_layer = owner;
|
||||
make_stream(self->client_mcs_data);
|
||||
init_stream(self->client_mcs_data, 8192);
|
||||
@@ -46,15 +48,19 @@ rdp_sec_create(struct rdp_rdp* owner)
|
||||
init_stream(self->server_mcs_data, 8192);
|
||||
self->mcs_layer = rdp_mcs_create(self, self->client_mcs_data,
|
||||
self->server_mcs_data);
|
||||
if(self->decrypt_rc4_info!=NULL)
|
||||
|
||||
if (self->decrypt_rc4_info != NULL)
|
||||
{
|
||||
g_writeln("rdp_sec_create - decrypt_rc4_info already created !!!");
|
||||
}
|
||||
|
||||
self->decrypt_rc4_info = ssl_rc4_info_create();
|
||||
if(self->encrypt_rc4_info!=NULL)
|
||||
|
||||
if (self->encrypt_rc4_info != NULL)
|
||||
{
|
||||
g_writeln("rdp_sec_create - encrypt_rc4_info already created !!!");
|
||||
}
|
||||
|
||||
self->encrypt_rc4_info = ssl_rc4_info_create();
|
||||
self->lic_layer = rdp_lic_create(self);
|
||||
return self;
|
||||
@@ -62,12 +68,13 @@ rdp_sec_create(struct rdp_rdp* owner)
|
||||
|
||||
/*****************************************************************************/
|
||||
void APP_CC
|
||||
rdp_sec_delete(struct rdp_sec* self)
|
||||
rdp_sec_delete(struct rdp_sec *self)
|
||||
{
|
||||
if (self == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
rdp_lic_delete(self->lic_layer);
|
||||
rdp_mcs_delete(self->mcs_layer);
|
||||
free_stream(self->client_mcs_data);
|
||||
@@ -80,7 +87,7 @@ rdp_sec_delete(struct rdp_sec* self)
|
||||
/*****************************************************************************/
|
||||
/* Reduce key entropy from 64 to 40 bits */
|
||||
static void APP_CC
|
||||
rdp_sec_make_40bit(char* key)
|
||||
rdp_sec_make_40bit(char *key)
|
||||
{
|
||||
key[0] = 0xd1;
|
||||
key[1] = 0x26;
|
||||
@@ -91,12 +98,12 @@ rdp_sec_make_40bit(char* key)
|
||||
/* returns error */
|
||||
/* update an encryption key */
|
||||
static int APP_CC
|
||||
rdp_sec_update(char* key, char* update_key, int key_len)
|
||||
rdp_sec_update(char *key, char *update_key, int key_len)
|
||||
{
|
||||
char shasig[20];
|
||||
void* sha1_info;
|
||||
void* md5_info;
|
||||
void* rc4_info;
|
||||
void *sha1_info;
|
||||
void *md5_info;
|
||||
void *rc4_info;
|
||||
|
||||
sha1_info = ssl_sha1_info_create();
|
||||
md5_info = ssl_md5_info_create();
|
||||
@@ -113,10 +120,12 @@ rdp_sec_update(char* key, char* update_key, int key_len)
|
||||
ssl_md5_complete(md5_info, key);
|
||||
ssl_rc4_set_key(rc4_info, key, key_len);
|
||||
ssl_rc4_crypt(rc4_info, key, key_len);
|
||||
|
||||
if (key_len == 8)
|
||||
{
|
||||
rdp_sec_make_40bit(key);
|
||||
}
|
||||
|
||||
ssl_sha1_info_delete(sha1_info);
|
||||
ssl_md5_info_delete(md5_info);
|
||||
ssl_rc4_info_delete(rc4_info);
|
||||
@@ -125,7 +134,7 @@ rdp_sec_update(char* key, char* update_key, int key_len)
|
||||
|
||||
/*****************************************************************************/
|
||||
static void APP_CC
|
||||
rdp_sec_decrypt(struct rdp_sec* self, char* data, int len)
|
||||
rdp_sec_decrypt(struct rdp_sec *self, char *data, int len)
|
||||
{
|
||||
if (self->decrypt_use_count == 4096)
|
||||
{
|
||||
@@ -135,6 +144,7 @@ rdp_sec_decrypt(struct rdp_sec* self, char* data, int len)
|
||||
self->rc4_key_len);
|
||||
self->decrypt_use_count = 0;
|
||||
}
|
||||
|
||||
ssl_rc4_crypt(self->decrypt_rc4_info, data, len);
|
||||
self->decrypt_use_count++;
|
||||
}
|
||||
@@ -142,29 +152,34 @@ rdp_sec_decrypt(struct rdp_sec* self, char* data, int len)
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
int APP_CC
|
||||
rdp_sec_recv(struct rdp_sec* self, struct stream* s, int* chan)
|
||||
rdp_sec_recv(struct rdp_sec *self, struct stream *s, int *chan)
|
||||
{
|
||||
int flags;
|
||||
|
||||
DEBUG((" in rdp_sec_recv"));
|
||||
|
||||
if (rdp_mcs_recv(self->mcs_layer, s, chan) != 0)
|
||||
{
|
||||
DEBUG((" error in rdp_sec_recv, rdp_mcs_recv failed"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint32_le(s, flags);
|
||||
DEBUG((" rdp_sec_recv flags %8.8x", flags));
|
||||
|
||||
if (flags & SEC_ENCRYPT) /* 0x08 */
|
||||
{
|
||||
in_uint8s(s, 8); /* signature */
|
||||
rdp_sec_decrypt(self, s->p, s->end - s->p);
|
||||
}
|
||||
|
||||
if (flags & SEC_LICENCE_NEG) /* 0x80 */
|
||||
{
|
||||
DEBUG((" in rdp_sec_recv, got SEC_LICENCE_NEG"));
|
||||
rdp_lic_process(self->lic_layer, s);
|
||||
*chan = 0;
|
||||
}
|
||||
|
||||
DEBUG((" out rdp_sec_recv"));
|
||||
return 0;
|
||||
}
|
||||
@@ -172,9 +187,9 @@ rdp_sec_recv(struct rdp_sec* self, struct stream* s, int* chan)
|
||||
/*****************************************************************************/
|
||||
/* prepare client mcs data to send in mcs layer */
|
||||
static void APP_CC
|
||||
rdp_sec_out_mcs_data(struct rdp_sec* self)
|
||||
rdp_sec_out_mcs_data(struct rdp_sec *self)
|
||||
{
|
||||
struct stream* s;
|
||||
struct stream *s;
|
||||
int hostlen;
|
||||
int length;
|
||||
|
||||
@@ -239,22 +254,26 @@ rdp_sec_out_mcs_data(struct rdp_sec* self)
|
||||
/* Parse a public key structure */
|
||||
/* returns boolean */
|
||||
static int APP_CC
|
||||
rdp_sec_parse_public_key(struct rdp_sec* self, struct stream* s,
|
||||
char* modulus, char* exponent)
|
||||
rdp_sec_parse_public_key(struct rdp_sec *self, struct stream *s,
|
||||
char *modulus, char *exponent)
|
||||
{
|
||||
int magic;
|
||||
int modulus_len;
|
||||
|
||||
in_uint32_le(s, magic);
|
||||
|
||||
if (magic != SEC_RSA_MAGIC)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
in_uint32_le(s, modulus_len);
|
||||
|
||||
if (modulus_len != SEC_MODULUS_SIZE + SEC_PADDING_SIZE)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
in_uint8s(s, 8);
|
||||
in_uint8a(s, exponent, SEC_EXPONENT_SIZE);
|
||||
in_uint8a(s, modulus, SEC_MODULUS_SIZE);
|
||||
@@ -266,59 +285,71 @@ rdp_sec_parse_public_key(struct rdp_sec* self, struct stream* s,
|
||||
/* Parse a crypto information structure */
|
||||
/* returns boolean */
|
||||
static int APP_CC
|
||||
rdp_sec_parse_crypt_info(struct rdp_sec* self, struct stream* s,
|
||||
char* modulus, char* exponent)
|
||||
rdp_sec_parse_crypt_info(struct rdp_sec *self, struct stream *s,
|
||||
char *modulus, char *exponent)
|
||||
{
|
||||
int random_len;
|
||||
int rsa_info_len;
|
||||
int flags;
|
||||
int tag;
|
||||
int length;
|
||||
char* next_tag;
|
||||
char* end;
|
||||
char *next_tag;
|
||||
char *end;
|
||||
|
||||
in_uint32_le(s, self->rc4_key_size); /* 1 = 40-bit, 2 = 128-bit */
|
||||
in_uint32_le(s, self->crypt_level); /* 1 = low, 2 = medium, 3 = high */
|
||||
|
||||
if (self->crypt_level == 0) /* no encryption */
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
in_uint32_le(s, random_len);
|
||||
in_uint32_le(s, rsa_info_len);
|
||||
|
||||
if (random_len != SEC_RANDOM_SIZE)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
in_uint8a(s, self->server_random, random_len);
|
||||
/* RSA info */
|
||||
end = s->p + rsa_info_len;
|
||||
|
||||
if (end > s->end)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
in_uint32_le(s, flags); /* 1 = RDP4-style, 0x80000002 = X.509 */
|
||||
|
||||
if (flags & 1)
|
||||
{
|
||||
in_uint8s(s, 8); /* unknown */
|
||||
|
||||
while (s->p < end)
|
||||
{
|
||||
in_uint16_le(s, tag);
|
||||
in_uint16_le(s, length);
|
||||
next_tag = s->p + length;
|
||||
DEBUG((" rdp_sec_parse_crypt_info tag %d length %d", tag, length));
|
||||
|
||||
switch (tag)
|
||||
{
|
||||
case SEC_TAG_PUBKEY:
|
||||
|
||||
if (!rdp_sec_parse_public_key(self, s, modulus, exponent))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
break;
|
||||
case SEC_TAG_KEYSIG:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
s->p = next_tag;
|
||||
}
|
||||
}
|
||||
@@ -327,12 +358,13 @@ rdp_sec_parse_crypt_info(struct rdp_sec* self, struct stream* s,
|
||||
/* todo */
|
||||
return 0;
|
||||
}
|
||||
|
||||
return s_check_end(s);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
static void APP_CC
|
||||
rdp_sec_rsa_op(char* out, char* in, char* mod, char* exp)
|
||||
rdp_sec_rsa_op(char *out, char *in, char *mod, char *exp)
|
||||
{
|
||||
ssl_mod_exp(out, SEC_MODULUS_SIZE, /* 64 */
|
||||
in, SEC_RANDOM_SIZE, /* 32 */
|
||||
@@ -342,17 +374,18 @@ rdp_sec_rsa_op(char* out, char* in, char* mod, char* exp)
|
||||
|
||||
/*****************************************************************************/
|
||||
void APP_CC
|
||||
rdp_sec_hash_48(char* out, char* in, char* salt1, char* salt2, int salt)
|
||||
rdp_sec_hash_48(char *out, char *in, char *salt1, char *salt2, int salt)
|
||||
{
|
||||
int i;
|
||||
void* sha1_info;
|
||||
void* md5_info;
|
||||
void *sha1_info;
|
||||
void *md5_info;
|
||||
char pad[4];
|
||||
char sha1_sig[20];
|
||||
char md5_sig[16];
|
||||
|
||||
sha1_info = ssl_sha1_info_create();
|
||||
md5_info = ssl_md5_info_create();
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
g_memset(pad, salt + i, 4);
|
||||
@@ -368,15 +401,16 @@ rdp_sec_hash_48(char* out, char* in, char* salt1, char* salt2, int salt)
|
||||
ssl_md5_complete(md5_info, md5_sig);
|
||||
g_memcpy(out + i * 16, md5_sig, 16);
|
||||
}
|
||||
|
||||
ssl_sha1_info_delete(sha1_info);
|
||||
ssl_md5_info_delete(md5_info);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void APP_CC
|
||||
rdp_sec_hash_16(char* out, char* in, char* salt1, char* salt2)
|
||||
rdp_sec_hash_16(char *out, char *in, char *salt1, char *salt2)
|
||||
{
|
||||
void* md5_info;
|
||||
void *md5_info;
|
||||
|
||||
md5_info = ssl_md5_info_create();
|
||||
ssl_md5_clear(md5_info);
|
||||
@@ -389,7 +423,7 @@ rdp_sec_hash_16(char* out, char* in, char* salt1, char* salt2)
|
||||
|
||||
/*****************************************************************************/
|
||||
static int APP_CC
|
||||
rdp_sec_generate_keys(struct rdp_sec* self)
|
||||
rdp_sec_generate_keys(struct rdp_sec *self)
|
||||
{
|
||||
char session_key[48];
|
||||
char temp_hash[48];
|
||||
@@ -408,6 +442,7 @@ rdp_sec_generate_keys(struct rdp_sec* self)
|
||||
self->server_random);
|
||||
DEBUG((" rdp_sec_generate_keys, rc4_key_size is %d", self->rc4_key_size));
|
||||
DEBUG((" rdp_sec_generate_keys, crypt_level is %d", self->crypt_level));
|
||||
|
||||
if (self->rc4_key_size == 1)
|
||||
{
|
||||
rdp_sec_make_40bit(self->sign_key);
|
||||
@@ -419,6 +454,7 @@ rdp_sec_generate_keys(struct rdp_sec* self)
|
||||
{
|
||||
self->rc4_key_len = 16;
|
||||
}
|
||||
|
||||
g_memcpy(self->decrypt_update_key, self->decrypt_key, 16);
|
||||
g_memcpy(self->encrypt_update_key, self->encrypt_key, 16);
|
||||
ssl_rc4_set_key(self->decrypt_rc4_info, self->decrypt_key, self->rc4_key_len);
|
||||
@@ -429,18 +465,20 @@ rdp_sec_generate_keys(struct rdp_sec* self)
|
||||
/*****************************************************************************/
|
||||
/* Process crypto information blob */
|
||||
static void APP_CC
|
||||
rdp_sec_process_crypt_info(struct rdp_sec* self, struct stream* s)
|
||||
rdp_sec_process_crypt_info(struct rdp_sec *self, struct stream *s)
|
||||
{
|
||||
char modulus[64];
|
||||
char exponent[64];
|
||||
|
||||
g_memset(modulus, 0, sizeof(modulus));
|
||||
g_memset(exponent, 0, sizeof(exponent));
|
||||
|
||||
if (!rdp_sec_parse_crypt_info(self, s, modulus, exponent))
|
||||
{
|
||||
DEBUG((" error in rdp_sec_process_crypt_info"));
|
||||
return;
|
||||
}
|
||||
|
||||
/* Generate a client random, and determine encryption keys */
|
||||
g_random(self->client_random, 32);
|
||||
rdp_sec_rsa_op(self->client_crypt_random, self->client_random,
|
||||
@@ -451,32 +489,37 @@ rdp_sec_process_crypt_info(struct rdp_sec* self, struct stream* s)
|
||||
/*****************************************************************************/
|
||||
/* Process connect response data blob */
|
||||
static void APP_CC
|
||||
rdp_sec_process_mcs_data(struct rdp_sec* self)
|
||||
rdp_sec_process_mcs_data(struct rdp_sec *self)
|
||||
{
|
||||
int tag;
|
||||
int length;
|
||||
int len;
|
||||
char* next_tag;
|
||||
struct stream* s;
|
||||
char *next_tag;
|
||||
struct stream *s;
|
||||
|
||||
s = self->server_mcs_data;
|
||||
s->p = s->data;
|
||||
in_uint8s(s, 21); /* header (T.124 ConferenceCreateResponse) */
|
||||
in_uint8(s, len);
|
||||
|
||||
if (len & 0x80)
|
||||
{
|
||||
in_uint8(s, len);
|
||||
}
|
||||
|
||||
while (s->p < s->end)
|
||||
{
|
||||
in_uint16_le(s, tag);
|
||||
in_uint16_le(s, length);
|
||||
DEBUG((" rdp_sec_process_mcs_data tag %d length %d", tag, length));
|
||||
|
||||
if (length <= 4)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
next_tag = (s->p + length) - 4;
|
||||
|
||||
switch (tag)
|
||||
{
|
||||
case SEC_TAG_SRV_INFO:
|
||||
@@ -490,6 +533,7 @@ rdp_sec_process_mcs_data(struct rdp_sec* self)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
s->p = next_tag;
|
||||
}
|
||||
}
|
||||
@@ -498,31 +542,35 @@ rdp_sec_process_mcs_data(struct rdp_sec* self)
|
||||
/* Transfer the client random to the server */
|
||||
/* returns error */
|
||||
static int APP_CC
|
||||
rdp_sec_establish_key(struct rdp_sec* self)
|
||||
rdp_sec_establish_key(struct rdp_sec *self)
|
||||
{
|
||||
int length;
|
||||
int flags;
|
||||
struct stream* s;
|
||||
struct stream *s;
|
||||
|
||||
DEBUG((" sending client random"));
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
length = SEC_MODULUS_SIZE + SEC_PADDING_SIZE;
|
||||
flags = SEC_CLIENT_RANDOM;
|
||||
|
||||
if (rdp_sec_init(self, s, flags) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
out_uint32_le(s, length);
|
||||
out_uint8p(s, self->client_crypt_random, SEC_MODULUS_SIZE);
|
||||
out_uint8s(s, SEC_PADDING_SIZE);
|
||||
s_mark_end(s);
|
||||
|
||||
if (rdp_sec_send(self, s, flags) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
return 0;
|
||||
}
|
||||
@@ -530,21 +578,25 @@ rdp_sec_establish_key(struct rdp_sec* self)
|
||||
/*****************************************************************************/
|
||||
/* Establish a secure connection */
|
||||
int APP_CC
|
||||
rdp_sec_connect(struct rdp_sec* self, char* ip, char* port)
|
||||
rdp_sec_connect(struct rdp_sec *self, char *ip, char *port)
|
||||
{
|
||||
DEBUG((" in rdp_sec_connect"));
|
||||
rdp_sec_out_mcs_data(self);
|
||||
|
||||
if (rdp_mcs_connect(self->mcs_layer, ip, port) != 0)
|
||||
{
|
||||
DEBUG((" out rdp_sec_connect error rdp_mcs_connect failed"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
rdp_sec_process_mcs_data(self);
|
||||
|
||||
if (rdp_sec_establish_key(self) != 0)
|
||||
{
|
||||
DEBUG((" out rdp_sec_connect error rdp_sec_establish_key failed"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
DEBUG((" out rdp_sec_connect"));
|
||||
return 0;
|
||||
}
|
||||
@@ -552,12 +604,13 @@ rdp_sec_connect(struct rdp_sec* self, char* ip, char* port)
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
int APP_CC
|
||||
rdp_sec_init(struct rdp_sec* self, struct stream* s, int flags)
|
||||
rdp_sec_init(struct rdp_sec *self, struct stream *s, int flags)
|
||||
{
|
||||
if (rdp_mcs_init(self->mcs_layer, s) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (flags & SEC_ENCRYPT)
|
||||
{
|
||||
s_push_layer(s, sec_hdr, 12);
|
||||
@@ -566,13 +619,14 @@ rdp_sec_init(struct rdp_sec* self, struct stream* s, int flags)
|
||||
{
|
||||
s_push_layer(s, sec_hdr, 4);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Output a uint32 into a buffer (little-endian) */
|
||||
void APP_CC
|
||||
rdp_sec_buf_out_uint32(char* buffer, int value)
|
||||
rdp_sec_buf_out_uint32(char *buffer, int value)
|
||||
{
|
||||
buffer[0] = value & 0xff;
|
||||
buffer[1] = (value >> 8) & 0xff;
|
||||
@@ -583,14 +637,14 @@ rdp_sec_buf_out_uint32(char* buffer, int value)
|
||||
/*****************************************************************************/
|
||||
/* Generate a MAC hash (5.2.3.1), using a combination of SHA1 and MD5 */
|
||||
void APP_CC
|
||||
rdp_sec_sign(char* signature, int siglen, char* session_key, int keylen,
|
||||
char* data, int datalen)
|
||||
rdp_sec_sign(char *signature, int siglen, char *session_key, int keylen,
|
||||
char *data, int datalen)
|
||||
{
|
||||
char shasig[20];
|
||||
char md5sig[16];
|
||||
char lenhdr[4];
|
||||
void* sha1_context;
|
||||
void* md5_context;
|
||||
void *sha1_context;
|
||||
void *md5_context;
|
||||
|
||||
rdp_sec_buf_out_uint32(lenhdr, datalen);
|
||||
sha1_context = ssl_sha1_info_create();
|
||||
@@ -614,7 +668,7 @@ rdp_sec_sign(char* signature, int siglen, char* session_key, int keylen,
|
||||
/*****************************************************************************/
|
||||
/* Encrypt data using RC4 */
|
||||
static void APP_CC
|
||||
rdp_sec_encrypt(struct rdp_sec* self, char* data, int length)
|
||||
rdp_sec_encrypt(struct rdp_sec *self, char *data, int length)
|
||||
{
|
||||
if (self->encrypt_use_count == 4096)
|
||||
{
|
||||
@@ -624,6 +678,7 @@ rdp_sec_encrypt(struct rdp_sec* self, char* data, int length)
|
||||
self->rc4_key_len);
|
||||
self->encrypt_use_count = 0;
|
||||
}
|
||||
|
||||
ssl_rc4_crypt(self->encrypt_rc4_info, data, length);
|
||||
self->encrypt_use_count++;
|
||||
}
|
||||
@@ -631,13 +686,14 @@ rdp_sec_encrypt(struct rdp_sec* self, char* data, int length)
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
int APP_CC
|
||||
rdp_sec_send(struct rdp_sec* self, struct stream* s, int flags)
|
||||
rdp_sec_send(struct rdp_sec *self, struct stream *s, int flags)
|
||||
{
|
||||
int datalen;
|
||||
|
||||
DEBUG((" in rdp_sec_send flags %8.8x", flags));
|
||||
s_pop_layer(s, sec_hdr);
|
||||
out_uint32_le(s, flags);
|
||||
|
||||
if (flags & SEC_ENCRYPT)
|
||||
{
|
||||
datalen = (s->end - s->p) - 8;
|
||||
@@ -645,11 +701,13 @@ rdp_sec_send(struct rdp_sec* self, struct stream* s, int flags)
|
||||
datalen);
|
||||
rdp_sec_encrypt(self, s->p + 8, datalen);
|
||||
}
|
||||
|
||||
if (rdp_mcs_send(self->mcs_layer, s) != 0)
|
||||
{
|
||||
DEBUG((" out rdp_sec_send, rdp_mcs_send failed"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
DEBUG((" out rdp_sec_send"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
+41
-31
@@ -1,41 +1,39 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
|
||||
librdp tcp layer
|
||||
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* librdp tcp layer
|
||||
*/
|
||||
|
||||
#include "rdp.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
struct rdp_tcp* APP_CC
|
||||
rdp_tcp_create(struct rdp_iso* owner)
|
||||
struct rdp_tcp *APP_CC
|
||||
rdp_tcp_create(struct rdp_iso *owner)
|
||||
{
|
||||
struct rdp_tcp* self;
|
||||
struct rdp_tcp *self;
|
||||
|
||||
self = (struct rdp_tcp*)g_malloc(sizeof(struct rdp_tcp), 1);
|
||||
self = (struct rdp_tcp *)g_malloc(sizeof(struct rdp_tcp), 1);
|
||||
self->iso_layer = owner;
|
||||
return self;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void APP_CC
|
||||
rdp_tcp_delete(struct rdp_tcp* self)
|
||||
rdp_tcp_delete(struct rdp_tcp *self)
|
||||
{
|
||||
g_free(self);
|
||||
}
|
||||
@@ -44,7 +42,7 @@ rdp_tcp_delete(struct rdp_tcp* self)
|
||||
/* get out stream ready for data */
|
||||
/* returns error */
|
||||
int APP_CC
|
||||
rdp_tcp_init(struct rdp_tcp* self, struct stream* s)
|
||||
rdp_tcp_init(struct rdp_tcp *self, struct stream *s)
|
||||
{
|
||||
init_stream(s, 8192);
|
||||
return 0;
|
||||
@@ -53,21 +51,25 @@ rdp_tcp_init(struct rdp_tcp* self, struct stream* s)
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
int APP_CC
|
||||
rdp_tcp_recv(struct rdp_tcp* self, struct stream* s, int len)
|
||||
rdp_tcp_recv(struct rdp_tcp *self, struct stream *s, int len)
|
||||
{
|
||||
int rcvd;
|
||||
|
||||
DEBUG((" in rdp_tcp_recv gota get %d bytes on sck %d",
|
||||
len, self->sck));
|
||||
|
||||
if (self->sck_closed)
|
||||
{
|
||||
DEBUG((" out rdp_tcp_recv error sck closed"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
init_stream(s, len);
|
||||
|
||||
while (len > 0)
|
||||
{
|
||||
rcvd = g_tcp_recv(self->sck, s->end, len, 0);
|
||||
|
||||
if (rcvd == -1)
|
||||
{
|
||||
if (g_tcp_last_error_would_block(self->sck))
|
||||
@@ -93,13 +95,14 @@ rdp_tcp_recv(struct rdp_tcp* self, struct stream* s, int len)
|
||||
len -= rcvd;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
int APP_CC
|
||||
rdp_tcp_send(struct rdp_tcp* self, struct stream* s)
|
||||
rdp_tcp_send(struct rdp_tcp *self, struct stream *s)
|
||||
{
|
||||
int len;
|
||||
int total;
|
||||
@@ -110,13 +113,16 @@ rdp_tcp_send(struct rdp_tcp* self, struct stream* s)
|
||||
DEBUG((" out rdp_tcp_send error sck closed"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
len = s->end - s->data;
|
||||
DEBUG((" in rdp_tcp_send gota send %d bytes on sck %d", len,
|
||||
self->sck));
|
||||
total = 0;
|
||||
|
||||
while (total < len)
|
||||
{
|
||||
sent = g_tcp_send(self->sck, s->data + total, len - total, 0);
|
||||
|
||||
if (sent == -1)
|
||||
{
|
||||
if (g_tcp_last_error_would_block(self->sck))
|
||||
@@ -141,16 +147,18 @@ rdp_tcp_send(struct rdp_tcp* self, struct stream* s)
|
||||
total = total + sent;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
int APP_CC
|
||||
rdp_tcp_connect(struct rdp_tcp* self, char* ip, char* port)
|
||||
rdp_tcp_connect(struct rdp_tcp *self, char *ip, char *port)
|
||||
{
|
||||
DEBUG((" in rdp_tcp_connect ip %s port %s", ip, port));
|
||||
self->sck = g_tcp_socket();
|
||||
|
||||
if (g_tcp_connect(self->sck, ip, port) == 0)
|
||||
{
|
||||
g_tcp_set_non_blocking(self->sck);
|
||||
@@ -160,6 +168,7 @@ rdp_tcp_connect(struct rdp_tcp* self, char* ip, char* port)
|
||||
DEBUG((" out rdp_tcp_connect error g_tcp_connect failed"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
DEBUG((" out rdp_tcp_connect"));
|
||||
return 0;
|
||||
}
|
||||
@@ -167,12 +176,13 @@ rdp_tcp_connect(struct rdp_tcp* self, char* ip, char* port)
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
int APP_CC
|
||||
rdp_tcp_disconnect(struct rdp_tcp* self)
|
||||
rdp_tcp_disconnect(struct rdp_tcp *self)
|
||||
{
|
||||
if (self->sck != 0)
|
||||
{
|
||||
g_tcp_close(self->sck);
|
||||
}
|
||||
|
||||
self->sck = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
+1
-1
@@ -35,4 +35,4 @@ make install
|
||||
|
||||
see file-loc.txt to see what files are installed where
|
||||
|
||||
Jay
|
||||
Jay Sorg
|
||||
|
||||
+21
-22
@@ -1,21 +1,20 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -27,11 +26,11 @@
|
||||
|
||||
#include "sesman.h"
|
||||
|
||||
extern struct config_sesman* g_cfg; /* in sesman.c */
|
||||
extern struct config_sesman *g_cfg; /* in sesman.c */
|
||||
|
||||
/******************************************************************************/
|
||||
int DEFAULT_CC
|
||||
access_login_allowed(char* user)
|
||||
access_login_allowed(char *user)
|
||||
{
|
||||
int gid;
|
||||
int ok;
|
||||
@@ -80,7 +79,7 @@ access_login_allowed(char* user)
|
||||
|
||||
/******************************************************************************/
|
||||
int DEFAULT_CC
|
||||
access_login_mng_allowed(char* user)
|
||||
access_login_mng_allowed(char *user)
|
||||
{
|
||||
int gid;
|
||||
int ok;
|
||||
@@ -95,7 +94,7 @@ access_login_mng_allowed(char* user)
|
||||
if (0 == g_cfg->sec.ts_admins_enable)
|
||||
{
|
||||
LOG_DBG("[MNG] Terminal Server Admin group is disabled,"
|
||||
"allowing authentication",1);
|
||||
"allowing authentication", 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
+17
-18
@@ -1,21 +1,20 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
+17
-18
@@ -1,21 +1,20 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
+158
-50
@@ -32,10 +32,10 @@
|
||||
#include "rail.h"
|
||||
#include "xcommon.h"
|
||||
|
||||
static struct trans* g_lis_trans = 0;
|
||||
static struct trans* g_con_trans = 0;
|
||||
static struct trans* g_api_lis_trans = 0;
|
||||
static struct trans* g_api_con_trans = 0;
|
||||
static struct trans *g_lis_trans = 0;
|
||||
static struct trans *g_con_trans = 0;
|
||||
static struct trans *g_api_lis_trans = 0;
|
||||
static struct trans *g_api_con_trans = 0;
|
||||
static struct chan_item g_chan_items[32];
|
||||
static int g_num_chan_items = 0;
|
||||
static int g_cliprdr_index = -1;
|
||||
@@ -54,7 +54,7 @@ int g_rdpsnd_chan_id = -1; /* rdpsnd */
|
||||
int g_rdpdr_chan_id = -1; /* rdpdr */
|
||||
int g_rail_chan_id = -1; /* rail */
|
||||
|
||||
char* g_exec_name;
|
||||
char *g_exec_name;
|
||||
tbus g_exec_event;
|
||||
tbus g_exec_mutex;
|
||||
tbus g_exec_sem;
|
||||
@@ -72,17 +72,18 @@ struct xrdp_api_data
|
||||
/* add data to chan_item, on its way to the client */
|
||||
/* returns error */
|
||||
static int APP_CC
|
||||
add_data_to_chan_item(struct chan_item* chan_item, char* data, int size)
|
||||
add_data_to_chan_item(struct chan_item *chan_item, char *data, int size)
|
||||
{
|
||||
struct stream* s;
|
||||
struct chan_out_data* cod;
|
||||
struct stream *s;
|
||||
struct chan_out_data *cod;
|
||||
|
||||
make_stream(s);
|
||||
init_stream(s, size);
|
||||
g_memcpy(s->data, data, size);
|
||||
s->end = s->data + size;
|
||||
cod = (struct chan_out_data*)g_malloc(sizeof(struct chan_out_data), 1);
|
||||
cod = (struct chan_out_data *)g_malloc(sizeof(struct chan_out_data), 1);
|
||||
cod->s = s;
|
||||
|
||||
if (chan_item->tail == 0)
|
||||
{
|
||||
chan_item->tail = cod;
|
||||
@@ -93,16 +94,17 @@ add_data_to_chan_item(struct chan_item* chan_item, char* data, int size)
|
||||
chan_item->tail->next = cod;
|
||||
chan_item->tail = cod;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
static int APP_CC
|
||||
send_data_from_chan_item(struct chan_item* chan_item)
|
||||
send_data_from_chan_item(struct chan_item *chan_item)
|
||||
{
|
||||
struct stream* s;
|
||||
struct chan_out_data* cod;
|
||||
struct stream *s;
|
||||
struct chan_out_data *cod;
|
||||
int bytes_left;
|
||||
int size;
|
||||
int chan_flags;
|
||||
@@ -112,18 +114,22 @@ send_data_from_chan_item(struct chan_item* chan_item)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
cod = chan_item->head;
|
||||
bytes_left = (int)(cod->s->end - cod->s->p);
|
||||
size = MIN(1600, bytes_left);
|
||||
chan_flags = 0;
|
||||
|
||||
if (cod->s->p == cod->s->data)
|
||||
{
|
||||
chan_flags |= 1; /* first */
|
||||
}
|
||||
|
||||
if (cod->s->p + size >= cod->s->end)
|
||||
{
|
||||
chan_flags |= 2; /* last */
|
||||
}
|
||||
|
||||
s = trans_get_out_s(g_con_trans, 8192);
|
||||
out_uint32_le(s, 0); /* version */
|
||||
out_uint32_le(s, 8 + 8 + 2 + 2 + 2 + 4 + size); /* size */
|
||||
@@ -138,21 +144,27 @@ send_data_from_chan_item(struct chan_item* chan_item)
|
||||
LOGM((LOG_LEVEL_DEBUG, "chansrv::send_channel_data: -- "
|
||||
"size %d chan_flags 0x%8.8x", size, chan_flags));
|
||||
error = trans_force_write(g_con_trans);
|
||||
|
||||
if (error != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
cod->s->p += size;
|
||||
|
||||
if (cod->s->p >= cod->s->end)
|
||||
{
|
||||
free_stream(cod->s);
|
||||
chan_item->head = chan_item->head->next;
|
||||
|
||||
if (chan_item->head == 0)
|
||||
{
|
||||
chan_item->tail = 0;
|
||||
}
|
||||
|
||||
g_free(cod);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -170,21 +182,24 @@ check_chan_items(void)
|
||||
send_data_from_chan_item(g_chan_items + index);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
int APP_CC
|
||||
send_channel_data(int chan_id, char* data, int size)
|
||||
send_channel_data(int chan_id, char *data, int size)
|
||||
{
|
||||
int index;
|
||||
|
||||
LOGM((LOG_LEVEL_DEBUG, "chansrv::send_channel_data: size %d", size));
|
||||
|
||||
if (chan_id == -1)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (index = 0; index < g_num_chan_items; index++)
|
||||
{
|
||||
if (g_chan_items[index].id == chan_id)
|
||||
@@ -194,6 +209,7 @@ send_channel_data(int chan_id, char* data, int size)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -202,14 +218,16 @@ send_channel_data(int chan_id, char* data, int size)
|
||||
static int APP_CC
|
||||
send_init_response_message(void)
|
||||
{
|
||||
struct stream * s = (struct stream *)NULL;
|
||||
struct stream *s = (struct stream *)NULL;
|
||||
|
||||
LOGM((LOG_LEVEL_INFO, "send_init_response_message:"));
|
||||
s = trans_get_out_s(g_con_trans, 8192);
|
||||
|
||||
if (s == 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
out_uint32_le(s, 0); /* version */
|
||||
out_uint32_le(s, 8 + 8); /* size */
|
||||
out_uint32_le(s, 2); /* msg id */
|
||||
@@ -223,14 +241,16 @@ send_init_response_message(void)
|
||||
static int APP_CC
|
||||
send_channel_setup_response_message(void)
|
||||
{
|
||||
struct stream * s = (struct stream *)NULL;
|
||||
struct stream *s = (struct stream *)NULL;
|
||||
|
||||
LOGM((LOG_LEVEL_DEBUG, "send_channel_setup_response_message:"));
|
||||
s = trans_get_out_s(g_con_trans, 8192);
|
||||
|
||||
if (s == 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
out_uint32_le(s, 0); /* version */
|
||||
out_uint32_le(s, 8 + 8); /* size */
|
||||
out_uint32_le(s, 4); /* msg id */
|
||||
@@ -244,14 +264,16 @@ send_channel_setup_response_message(void)
|
||||
static int APP_CC
|
||||
send_channel_data_response_message(void)
|
||||
{
|
||||
struct stream * s = (struct stream *)NULL;
|
||||
struct stream *s = (struct stream *)NULL;
|
||||
|
||||
LOGM((LOG_LEVEL_DEBUG, "send_channel_data_response_message:"));
|
||||
s = trans_get_out_s(g_con_trans, 8192);
|
||||
|
||||
if (s == 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
out_uint32_le(s, 0); /* version */
|
||||
out_uint32_le(s, 8 + 8); /* size */
|
||||
out_uint32_le(s, 6); /* msg id */
|
||||
@@ -263,7 +285,7 @@ send_channel_data_response_message(void)
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
static int APP_CC
|
||||
process_message_init(struct stream* s)
|
||||
process_message_init(struct stream *s)
|
||||
{
|
||||
LOGM((LOG_LEVEL_DEBUG, "process_message_init:"));
|
||||
return send_init_response_message();
|
||||
@@ -272,12 +294,12 @@ process_message_init(struct stream* s)
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
static int APP_CC
|
||||
process_message_channel_setup(struct stream* s)
|
||||
process_message_channel_setup(struct stream *s)
|
||||
{
|
||||
int num_chans;
|
||||
int index;
|
||||
int rv;
|
||||
struct chan_item* ci;
|
||||
struct chan_item *ci;
|
||||
|
||||
g_num_chan_items = 0;
|
||||
g_cliprdr_index = -1;
|
||||
@@ -292,6 +314,7 @@ process_message_channel_setup(struct stream* s)
|
||||
in_uint16_le(s, num_chans);
|
||||
LOGM((LOG_LEVEL_DEBUG, "process_message_channel_setup: num_chans %d",
|
||||
num_chans));
|
||||
|
||||
for (index = 0; index < num_chans; index++)
|
||||
{
|
||||
ci = &(g_chan_items[g_num_chan_items]);
|
||||
@@ -301,6 +324,7 @@ process_message_channel_setup(struct stream* s)
|
||||
in_uint16_le(s, ci->flags);
|
||||
LOGM((LOG_LEVEL_DEBUG, "process_message_channel_setup: chan name '%s' "
|
||||
"id %d flags %8.8x", ci->name, ci->id, ci->flags));
|
||||
|
||||
if (g_strcasecmp(ci->name, "cliprdr") == 0)
|
||||
{
|
||||
g_cliprdr_index = g_num_chan_items;
|
||||
@@ -325,48 +349,56 @@ process_message_channel_setup(struct stream* s)
|
||||
{
|
||||
LOG(10, ("other %s", ci->name));
|
||||
}
|
||||
|
||||
g_num_chan_items++;
|
||||
}
|
||||
|
||||
rv = send_channel_setup_response_message();
|
||||
|
||||
if (g_cliprdr_index >= 0)
|
||||
{
|
||||
clipboard_init();
|
||||
}
|
||||
|
||||
if (g_rdpsnd_index >= 0)
|
||||
{
|
||||
sound_init();
|
||||
}
|
||||
|
||||
if (g_rdpdr_index >= 0)
|
||||
{
|
||||
dev_redir_init();
|
||||
}
|
||||
|
||||
if (g_rail_index >= 0)
|
||||
{
|
||||
rail_init();
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
static int APP_CC
|
||||
process_message_channel_data(struct stream* s)
|
||||
process_message_channel_data(struct stream *s)
|
||||
{
|
||||
int chan_id = 0;
|
||||
int chan_flags = 0;
|
||||
int rv = 0;
|
||||
int length = 0;
|
||||
int total_length = 0;
|
||||
struct stream* ls;
|
||||
struct stream *ls;
|
||||
|
||||
in_uint16_le(s, chan_id);
|
||||
in_uint16_le(s, chan_flags);
|
||||
in_uint16_le(s, length);
|
||||
in_uint32_le(s, total_length);
|
||||
LOGM((LOG_LEVEL_DEBUG,"process_message_channel_data: chan_id %d "
|
||||
LOGM((LOG_LEVEL_DEBUG, "process_message_channel_data: chan_id %d "
|
||||
"chan_flags %d", chan_id, chan_flags));
|
||||
LOG(10, ("process_message_channel_data"));
|
||||
rv = send_channel_data_response_message();
|
||||
|
||||
if (rv == 0)
|
||||
{
|
||||
if (chan_id == g_cliprdr_chan_id)
|
||||
@@ -385,17 +417,20 @@ process_message_channel_data(struct stream* s)
|
||||
{
|
||||
rv = rail_data_in(s, chan_id, chan_flags, length, total_length);
|
||||
}
|
||||
else if (chan_id == ((struct xrdp_api_data*)
|
||||
else if (chan_id == ((struct xrdp_api_data *)
|
||||
(g_api_con_trans->callback_data))->chan_id)
|
||||
{
|
||||
LOG(10, ("process_message_channel_data length %d total_length %d "
|
||||
"chan_flags 0x%8.8x", length, total_length, chan_flags));
|
||||
ls = g_api_con_trans->out_s;
|
||||
|
||||
if (chan_flags & 1) /* first */
|
||||
{
|
||||
init_stream(ls, total_length);
|
||||
}
|
||||
|
||||
out_uint8a(ls, s->p, length);
|
||||
|
||||
if (chan_flags & 2) /* last */
|
||||
{
|
||||
s_mark_end(ls);
|
||||
@@ -403,13 +438,14 @@ process_message_channel_data(struct stream* s)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
static int APP_CC
|
||||
process_message_channel_data_response(struct stream* s)
|
||||
process_message_channel_data_response(struct stream *s)
|
||||
{
|
||||
LOG(10, ("process_message_channel_data_response:"));
|
||||
check_chan_items();
|
||||
@@ -421,28 +457,33 @@ process_message_channel_data_response(struct stream* s)
|
||||
static int APP_CC
|
||||
process_message(void)
|
||||
{
|
||||
struct stream * s = (struct stream *)NULL;
|
||||
struct stream *s = (struct stream *)NULL;
|
||||
int size = 0;
|
||||
int id = 0;
|
||||
int rv = 0;
|
||||
char* next_msg = (char *)NULL;
|
||||
char *next_msg = (char *)NULL;
|
||||
|
||||
if (g_con_trans == 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
s = trans_get_in_s(g_con_trans);
|
||||
|
||||
if (s == 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
rv = 0;
|
||||
|
||||
while (s_check_rem(s, 8))
|
||||
{
|
||||
next_msg = s->p;
|
||||
in_uint32_le(s, id);
|
||||
in_uint32_le(s, size);
|
||||
next_msg += size;
|
||||
|
||||
switch (id)
|
||||
{
|
||||
case 1: /* init */
|
||||
@@ -462,21 +503,24 @@ process_message(void)
|
||||
"unknown msg %d", id));
|
||||
break;
|
||||
}
|
||||
|
||||
if (rv != 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
s->p = next_msg;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
int DEFAULT_CC
|
||||
my_trans_data_in(struct trans* trans)
|
||||
my_trans_data_in(struct trans *trans)
|
||||
{
|
||||
struct stream * s = (struct stream *)NULL;
|
||||
struct stream *s = (struct stream *)NULL;
|
||||
int id = 0;
|
||||
int size = 0;
|
||||
int error = 0;
|
||||
@@ -485,48 +529,57 @@ my_trans_data_in(struct trans* trans)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (trans != g_con_trans)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
LOGM((LOG_LEVEL_DEBUG, "my_trans_data_in:"));
|
||||
s = trans_get_in_s(trans);
|
||||
in_uint32_le(s, id);
|
||||
in_uint32_le(s, size);
|
||||
error = trans_force_read(trans, size - 8);
|
||||
|
||||
if (error == 0)
|
||||
{
|
||||
/* here, the entire message block is read in, process it */
|
||||
error = process_message();
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
int DEFAULT_CC
|
||||
my_api_trans_data_in(struct trans* trans)
|
||||
my_api_trans_data_in(struct trans *trans)
|
||||
{
|
||||
struct stream* s;
|
||||
struct stream *s;
|
||||
int error;
|
||||
struct xrdp_api_data* ad;
|
||||
struct xrdp_api_data *ad;
|
||||
|
||||
LOG(10, ("my_api_trans_data_in:"));
|
||||
|
||||
if (trans == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (trans != g_api_con_trans)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
LOGM((LOG_LEVEL_DEBUG, "my_api_trans_data_in:"));
|
||||
s = trans_get_in_s(trans);
|
||||
error = g_tcp_recv(trans->sck, s->data, 8192, 0);
|
||||
|
||||
if (error > 0)
|
||||
{
|
||||
LOG(10, ("my_api_trans_data_in: got data %d", error));
|
||||
ad = (struct xrdp_api_data*)(trans->callback_data);
|
||||
ad = (struct xrdp_api_data *)(trans->callback_data);
|
||||
|
||||
if (send_channel_data(ad->chan_id, s->data, error) != 0)
|
||||
{
|
||||
LOG(0, ("my_api_trans_data_in: send_channel_data failed"));
|
||||
@@ -537,29 +590,34 @@ my_api_trans_data_in(struct trans* trans)
|
||||
LOG(10, ("my_api_trans_data_in: g_tcp_recv failed, or disconnected"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
int DEFAULT_CC
|
||||
my_trans_conn_in(struct trans* trans, struct trans* new_trans)
|
||||
my_trans_conn_in(struct trans *trans, struct trans *new_trans)
|
||||
{
|
||||
if (trans == 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (trans != g_lis_trans)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (g_con_trans != 0) /* if already set, error */
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (new_trans == 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
LOGM((LOG_LEVEL_DEBUG, "my_trans_conn_in:"));
|
||||
g_con_trans = new_trans;
|
||||
g_con_trans->trans_data_in = my_trans_data_in;
|
||||
@@ -572,26 +630,29 @@ my_trans_conn_in(struct trans* trans, struct trans* new_trans)
|
||||
|
||||
/*****************************************************************************/
|
||||
int DEFAULT_CC
|
||||
my_api_trans_conn_in(struct trans* trans, struct trans* new_trans)
|
||||
my_api_trans_conn_in(struct trans *trans, struct trans *new_trans)
|
||||
{
|
||||
struct xrdp_api_data* ad;
|
||||
struct xrdp_api_data *ad;
|
||||
int error;
|
||||
int index;
|
||||
int found;
|
||||
struct stream* s;
|
||||
struct stream *s;
|
||||
|
||||
if (trans == 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (trans != g_api_lis_trans)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (new_trans == 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
LOGM((LOG_LEVEL_DEBUG, "my_api_trans_conn_in:"));
|
||||
|
||||
LOG(10, ("my_api_trans_conn_in: got incoming"));
|
||||
@@ -599,20 +660,23 @@ my_api_trans_conn_in(struct trans* trans, struct trans* new_trans)
|
||||
s = trans_get_in_s(new_trans);
|
||||
s->end = s->data;
|
||||
error = trans_force_read(new_trans, 64);
|
||||
|
||||
if (error != 0)
|
||||
{
|
||||
LOG(0, ("my_api_trans_conn_in: trans_force_read failed"));
|
||||
trans_delete(new_trans);
|
||||
}
|
||||
|
||||
s->end = s->data;
|
||||
|
||||
ad = (struct xrdp_api_data*)g_malloc(sizeof(struct xrdp_api_data), 1);
|
||||
ad = (struct xrdp_api_data *)g_malloc(sizeof(struct xrdp_api_data), 1);
|
||||
|
||||
g_memcpy(ad->header, s->data, 64);
|
||||
|
||||
ad->flags = GGET_UINT32(ad->header, 16);
|
||||
|
||||
found = 0;
|
||||
|
||||
if (ad->flags | 1) /* WTS_CHANNEL_OPTION_DYNAMIC */
|
||||
{
|
||||
/* TODO */
|
||||
@@ -623,6 +687,7 @@ my_api_trans_conn_in(struct trans* trans, struct trans* new_trans)
|
||||
for (index = 0; index < g_num_chan_items; index++)
|
||||
{
|
||||
LOG(10, (" %s %s", ad->header, g_chan_items[index].name));
|
||||
|
||||
if (g_strcasecmp(ad->header, g_chan_items[index].name) == 0)
|
||||
{
|
||||
LOG(10, ("my_api_trans_conn_in: found it at %d", index));
|
||||
@@ -632,7 +697,9 @@ my_api_trans_conn_in(struct trans* trans, struct trans* new_trans)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LOG(10, ("my_api_trans_conn_in: found %d", found));
|
||||
|
||||
if (!found)
|
||||
{
|
||||
ad->chan_id = -1;
|
||||
@@ -659,6 +726,7 @@ setup_listen(void)
|
||||
{
|
||||
trans_delete(g_lis_trans);
|
||||
}
|
||||
|
||||
if (g_use_unix_socket)
|
||||
{
|
||||
g_lis_trans = trans_create(2, 8192, 8192);
|
||||
@@ -670,14 +738,17 @@ setup_listen(void)
|
||||
g_lis_trans = trans_create(1, 8192, 8192);
|
||||
g_snprintf(port, 255, "%d", 7200 + g_display_num);
|
||||
}
|
||||
|
||||
g_lis_trans->trans_conn_in = my_trans_conn_in;
|
||||
error = trans_listen(g_lis_trans, port);
|
||||
|
||||
if (error != 0)
|
||||
{
|
||||
LOGM((LOG_LEVEL_ERROR, "setup_listen: trans_listen failed for port %s",
|
||||
port));
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -692,18 +763,20 @@ setup_api_listen(void)
|
||||
g_snprintf(port, 255, "/tmp/.xrdp/xrdpapi_%d", g_display_num);
|
||||
g_api_lis_trans->trans_conn_in = my_api_trans_conn_in;
|
||||
error = trans_listen(g_api_lis_trans, port);
|
||||
|
||||
if (error != 0)
|
||||
{
|
||||
LOGM((LOG_LEVEL_ERROR, "setup_api_listen: trans_listen failed for port %s",
|
||||
port));
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
THREAD_RV THREAD_CC
|
||||
channel_thread_loop(void* in_val)
|
||||
channel_thread_loop(void *in_val)
|
||||
{
|
||||
tbus objs[32];
|
||||
int num_objs;
|
||||
@@ -715,6 +788,7 @@ channel_thread_loop(void* in_val)
|
||||
rv = 0;
|
||||
setup_api_listen();
|
||||
error = setup_listen();
|
||||
|
||||
if (error == 0)
|
||||
{
|
||||
timeout = -1;
|
||||
@@ -723,6 +797,7 @@ channel_thread_loop(void* in_val)
|
||||
num_objs++;
|
||||
trans_get_wait_objs(g_lis_trans, objs, &num_objs);
|
||||
trans_get_wait_objs(g_api_lis_trans, objs, &num_objs);
|
||||
|
||||
while (g_obj_wait(objs, num_objs, 0, 0, timeout) == 0)
|
||||
{
|
||||
if (g_is_wait_obj_set(g_term_event))
|
||||
@@ -734,6 +809,7 @@ channel_thread_loop(void* in_val)
|
||||
rail_deinit();
|
||||
break;
|
||||
}
|
||||
|
||||
if (g_lis_trans != 0)
|
||||
{
|
||||
if (trans_check_wait_objs(g_lis_trans) != 0)
|
||||
@@ -742,6 +818,7 @@ channel_thread_loop(void* in_val)
|
||||
"trans_check_wait_objs error"));
|
||||
}
|
||||
}
|
||||
|
||||
if (g_con_trans != 0)
|
||||
{
|
||||
if (trans_check_wait_objs(g_con_trans) != 0)
|
||||
@@ -757,12 +834,14 @@ channel_thread_loop(void* in_val)
|
||||
g_con_trans = 0;
|
||||
/* create new listener */
|
||||
error = setup_listen();
|
||||
|
||||
if (error != 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (g_api_lis_trans != 0)
|
||||
{
|
||||
if (trans_check_wait_objs(g_api_lis_trans) != 0)
|
||||
@@ -772,9 +851,11 @@ channel_thread_loop(void* in_val)
|
||||
}
|
||||
|
||||
LOG(10, ("0 %p", g_api_con_trans));
|
||||
|
||||
if (g_api_con_trans != 0)
|
||||
{
|
||||
LOG(10, ("1 %p %d", g_api_con_trans, g_tcp_can_recv(g_api_con_trans->sck, 0)));
|
||||
|
||||
if (trans_check_wait_objs(g_api_con_trans) != 0)
|
||||
{
|
||||
LOG(10, ("channel_thread_loop: trans_check_wait_objs failed, "
|
||||
@@ -801,6 +882,7 @@ channel_thread_loop(void* in_val)
|
||||
dev_redir_get_wait_objs(objs, &num_objs, &timeout);
|
||||
}
|
||||
}
|
||||
|
||||
trans_delete(g_lis_trans);
|
||||
g_lis_trans = 0;
|
||||
trans_delete(g_con_trans);
|
||||
@@ -836,21 +918,25 @@ child_signal_handler(int sig)
|
||||
int i1;
|
||||
|
||||
LOG(10, ("child_signal_handler:"));
|
||||
|
||||
do
|
||||
{
|
||||
i1 = g_waitchild();
|
||||
|
||||
if (i1 == g_exec_pid)
|
||||
{
|
||||
LOG(0, ("child_signal_handler: found pid %d", i1));
|
||||
//shutdownx();
|
||||
}
|
||||
|
||||
LOG(10, (" %d", i1));
|
||||
} while (i1 >= 0);
|
||||
}
|
||||
while (i1 >= 0);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
static int APP_CC
|
||||
get_display_num_from_display(char* display_text)
|
||||
get_display_num_from_display(char *display_text)
|
||||
{
|
||||
int index;
|
||||
int mode;
|
||||
@@ -870,6 +956,7 @@ get_display_num_from_display(char* display_text)
|
||||
disp_index = 0;
|
||||
scre_index = 0;
|
||||
mode = 0;
|
||||
|
||||
while (display_text[index] != 0)
|
||||
{
|
||||
if (display_text[index] == ':')
|
||||
@@ -895,8 +982,10 @@ get_display_num_from_display(char* display_text)
|
||||
scre[scre_index] = display_text[index];
|
||||
scre_index++;
|
||||
}
|
||||
|
||||
index++;
|
||||
}
|
||||
|
||||
host[host_index] = 0;
|
||||
disp[disp_index] = 0;
|
||||
scre[scre_index] = 0;
|
||||
@@ -921,25 +1010,27 @@ static int APP_CC
|
||||
read_ini(void)
|
||||
{
|
||||
char filename[256];
|
||||
struct list* names;
|
||||
struct list* values;
|
||||
char* name;
|
||||
char* value;
|
||||
struct list *names;
|
||||
struct list *values;
|
||||
char *name;
|
||||
char *value;
|
||||
int index;
|
||||
|
||||
g_memset(filename,0,(sizeof(char) * 256));
|
||||
g_memset(filename, 0, (sizeof(char) * 256));
|
||||
names = list_create();
|
||||
names->auto_free = 1;
|
||||
values = list_create();
|
||||
values->auto_free = 1;
|
||||
g_use_unix_socket = 0;
|
||||
g_snprintf(filename, 255, "%s/sesman.ini", XRDP_CFG_PATH);
|
||||
|
||||
if (file_by_name_read_section(filename, "Globals", names, values) == 0)
|
||||
{
|
||||
for (index = 0; index < names->count; index++)
|
||||
{
|
||||
name = (char*)list_get_item(names, index);
|
||||
value = (char*)list_get_item(values, index);
|
||||
name = (char *)list_get_item(names, index);
|
||||
value = (char *)list_get_item(values, index);
|
||||
|
||||
if (g_strcasecmp(name, "ListenAddress") == 0)
|
||||
{
|
||||
if (g_strcasecmp(value, "127.0.0.1") == 0)
|
||||
@@ -949,6 +1040,7 @@ read_ini(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
list_delete(names);
|
||||
list_delete(values);
|
||||
return 0;
|
||||
@@ -962,6 +1054,7 @@ run_exec(void)
|
||||
|
||||
LOG(10, ("run_exec:"));
|
||||
pid = g_fork();
|
||||
|
||||
if (pid == 0)
|
||||
{
|
||||
trans_delete(g_con_trans);
|
||||
@@ -973,6 +1066,7 @@ run_exec(void)
|
||||
g_execlp3(g_exec_name, g_exec_name, 0);
|
||||
g_exit(0);
|
||||
}
|
||||
|
||||
g_exec_pid = pid;
|
||||
tc_sem_inc(g_exec_sem);
|
||||
|
||||
@@ -981,13 +1075,13 @@ run_exec(void)
|
||||
|
||||
/*****************************************************************************/
|
||||
int DEFAULT_CC
|
||||
main(int argc, char** argv)
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
tbus waiters[4];
|
||||
int pid = 0;
|
||||
char text[256];
|
||||
char* home_text;
|
||||
char* display_text;
|
||||
char *home_text;
|
||||
char *display_text;
|
||||
char log_file[256];
|
||||
enum logReturns error;
|
||||
struct log_config logconfig;
|
||||
@@ -995,6 +1089,7 @@ main(int argc, char** argv)
|
||||
g_init("xrdp-chansrv"); /* os_calls */
|
||||
|
||||
home_text = g_getenv("HOME");
|
||||
|
||||
if (home_text == 0)
|
||||
{
|
||||
g_writeln("error reading HOME environment variable");
|
||||
@@ -1010,16 +1105,19 @@ main(int argc, char** argv)
|
||||
logconfig.program_name = "XRDP-Chansrv";
|
||||
g_snprintf(log_file, 255, "%s/xrdp-chansrv.log", home_text);
|
||||
g_writeln("chansrv::main: using log file [%s]", log_file);
|
||||
|
||||
if (g_file_exist(log_file))
|
||||
{
|
||||
g_file_delete(log_file);
|
||||
}
|
||||
|
||||
logconfig.log_file = log_file;
|
||||
logconfig.fd = -1;
|
||||
logconfig.log_level = LOG_LEVEL_ERROR;
|
||||
logconfig.enable_syslog = 0;
|
||||
logconfig.syslog_level = 0;
|
||||
error = log_start_from_param(&logconfig);
|
||||
|
||||
if (error != LOG_STARTUP_OK)
|
||||
{
|
||||
switch (error)
|
||||
@@ -1035,9 +1133,11 @@ main(int argc, char** argv)
|
||||
g_writeln("log_start error");
|
||||
break;
|
||||
}
|
||||
|
||||
g_deinit();
|
||||
return 1;
|
||||
}
|
||||
|
||||
LOGM((LOG_LEVEL_ALWAYS, "main: app started pid %d(0x%8.8x)", pid, pid));
|
||||
/* set up signal handler */
|
||||
g_signal_kill(term_signal_handler); /* SIGKILL */
|
||||
@@ -1048,12 +1148,14 @@ main(int argc, char** argv)
|
||||
display_text = g_getenv("DISPLAY");
|
||||
LOGM((LOG_LEVEL_INFO, "main: DISPLAY env var set to %s", display_text));
|
||||
get_display_num_from_display(display_text);
|
||||
|
||||
if (g_display_num == 0)
|
||||
{
|
||||
LOGM((LOG_LEVEL_ERROR, "main: error, display is zero"));
|
||||
g_deinit();
|
||||
return 1;
|
||||
}
|
||||
|
||||
LOGM((LOG_LEVEL_INFO, "main: using DISPLAY %d", g_display_num));
|
||||
g_snprintf(text, 255, "xrdp_chansrv_%8.8x_main_term", pid);
|
||||
g_term_event = g_create_wait_obj(text);
|
||||
@@ -1064,25 +1166,30 @@ main(int argc, char** argv)
|
||||
g_exec_mutex = tc_mutex_create();
|
||||
g_exec_sem = tc_sem_create(0);
|
||||
tc_thread_create(channel_thread_loop, 0);
|
||||
|
||||
while (g_term_event > 0 && !g_is_wait_obj_set(g_term_event))
|
||||
{
|
||||
waiters[0] = g_term_event;
|
||||
waiters[1] = g_exec_event;
|
||||
|
||||
if (g_obj_wait(waiters, 2, 0, 0, 0) != 0)
|
||||
{
|
||||
LOGM((LOG_LEVEL_ERROR, "main: error, g_obj_wait failed"));
|
||||
break;
|
||||
}
|
||||
|
||||
if (g_is_wait_obj_set(g_term_event))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (g_is_wait_obj_set(g_exec_event))
|
||||
{
|
||||
g_reset_wait_obj(g_exec_event);
|
||||
run_exec();
|
||||
}
|
||||
}
|
||||
|
||||
while (g_thread_done_event > 0 && !g_is_wait_obj_set(g_thread_done_event))
|
||||
{
|
||||
/* wait for thread to exit */
|
||||
@@ -1092,6 +1199,7 @@ main(int argc, char** argv)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* cleanup */
|
||||
main_cleanup();
|
||||
LOGM((LOG_LEVEL_INFO, "main: app exiting pid %d(0x%8.8x)", pid, pid));
|
||||
|
||||
+194
-75
File diff suppressed because it is too large
Load Diff
@@ -38,7 +38,7 @@ dev_redir_deinit(void)
|
||||
|
||||
/*****************************************************************************/
|
||||
int APP_CC
|
||||
dev_redir_data_in(struct stream* s, int chan_id, int chan_flags, int length,
|
||||
dev_redir_data_in(struct stream *s, int chan_id, int chan_flags, int length,
|
||||
int total_length)
|
||||
{
|
||||
return 0;
|
||||
@@ -46,7 +46,7 @@ dev_redir_data_in(struct stream* s, int chan_id, int chan_flags, int length,
|
||||
|
||||
/*****************************************************************************/
|
||||
int APP_CC
|
||||
dev_redir_get_wait_objs(tbus* objs, int* count, int* timeout)
|
||||
dev_redir_get_wait_objs(tbus *objs, int *count, int *timeout)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
+59
-35
@@ -31,13 +31,13 @@
|
||||
|
||||
extern int g_rail_chan_id; /* in chansrv.c */
|
||||
extern int g_display_num; /* in chansrv.c */
|
||||
extern char* g_exec_name; /* in chansrv.c */
|
||||
extern char *g_exec_name; /* in chansrv.c */
|
||||
extern tbus g_exec_event; /* in chansrv.c */
|
||||
extern tbus g_exec_mutex; /* in chansrv.c */
|
||||
extern tbus g_exec_sem; /* in chansrv.c */
|
||||
|
||||
extern Display* g_display; /* in xcommon.c */
|
||||
extern Screen* g_screen; /* in xcommon.c */
|
||||
extern Display *g_display; /* in xcommon.c */
|
||||
extern Screen *g_screen; /* in xcommon.c */
|
||||
extern Window g_root_window; /* in xcommon.c */
|
||||
extern Atom g_wm_delete_window_atom; /* in xcommon.c */
|
||||
extern Atom g_wm_protocols_atom; /* in xcommon.c */
|
||||
@@ -110,10 +110,11 @@ is_window_valid_child_of_root(unsigned int window_id)
|
||||
unsigned int nchild;
|
||||
Window r;
|
||||
Window p;
|
||||
Window* children;
|
||||
Window *children;
|
||||
|
||||
found = 0;
|
||||
XQueryTree(g_display, g_root_window, &r, &p, &children, &nchild);
|
||||
|
||||
for (i = 0; i < nchild; i++)
|
||||
{
|
||||
if (window_id == children[i])
|
||||
@@ -122,6 +123,7 @@ is_window_valid_child_of_root(unsigned int window_id)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
XFree(children);
|
||||
return found;
|
||||
}
|
||||
@@ -130,9 +132,9 @@ is_window_valid_child_of_root(unsigned int window_id)
|
||||
static int APP_CC
|
||||
rail_send_init(void)
|
||||
{
|
||||
struct stream* s;
|
||||
struct stream *s;
|
||||
int bytes;
|
||||
char* size_ptr;
|
||||
char *size_ptr;
|
||||
|
||||
LOG(10, ("chansrv::rail_send_init:"));
|
||||
make_stream(s);
|
||||
@@ -153,7 +155,7 @@ rail_send_init(void)
|
||||
|
||||
/******************************************************************************/
|
||||
static int DEFAULT_CC
|
||||
anotherWMRunning(Display* display, XErrorEvent* xe)
|
||||
anotherWMRunning(Display *display, XErrorEvent *xe)
|
||||
{
|
||||
g_rail_running = 0;
|
||||
return -1;
|
||||
@@ -175,10 +177,12 @@ rail_is_another_wm_running(void)
|
||||
XSync(g_display, 0);
|
||||
XSetErrorHandler((XErrorHandler)old);
|
||||
g_rail_up = g_rail_running;
|
||||
|
||||
if (!g_rail_up)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -188,11 +192,13 @@ rail_init(void)
|
||||
{
|
||||
LOG(10, ("chansrv::rail_init:"));
|
||||
xcommon_init();
|
||||
|
||||
if (rail_is_another_wm_running())
|
||||
{
|
||||
log_message(LOG_LEVEL_ERROR, "rail_init: another window manager "
|
||||
"is running");
|
||||
}
|
||||
|
||||
rail_send_init();
|
||||
g_rail_up = 1;
|
||||
return 0;
|
||||
@@ -208,52 +214,58 @@ rail_deinit(void)
|
||||
XSelectInput(g_display, g_root_window, 0);
|
||||
g_rail_up = 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
static char* APP_CC
|
||||
read_uni(struct stream* s, int num_chars)
|
||||
static char *APP_CC
|
||||
read_uni(struct stream *s, int num_chars)
|
||||
{
|
||||
twchar* rchrs;
|
||||
char* rv;
|
||||
twchar *rchrs;
|
||||
char *rv;
|
||||
int index;
|
||||
int lchars;
|
||||
|
||||
rchrs = 0;
|
||||
rv = 0;
|
||||
|
||||
if (num_chars > 0)
|
||||
{
|
||||
rchrs = (twchar*)g_malloc((num_chars + 1) * sizeof(twchar), 0);
|
||||
rchrs = (twchar *)g_malloc((num_chars + 1) * sizeof(twchar), 0);
|
||||
|
||||
for (index = 0; index < num_chars; index++)
|
||||
{
|
||||
in_uint16_le(s, rchrs[index]);
|
||||
}
|
||||
|
||||
rchrs[num_chars] = 0;
|
||||
lchars = g_wcstombs(0, rchrs, 0);
|
||||
|
||||
if (lchars > 0)
|
||||
{
|
||||
rv = (char*)g_malloc((lchars + 1) * 4, 0);
|
||||
rv = (char *)g_malloc((lchars + 1) * 4, 0);
|
||||
g_wcstombs(rv, rchrs, lchars);
|
||||
rv[lchars] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
g_free(rchrs);
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
static int APP_CC
|
||||
rail_process_exec(struct stream* s, int size)
|
||||
rail_process_exec(struct stream *s, int size)
|
||||
{
|
||||
int pid;
|
||||
int flags;
|
||||
int ExeOrFileLength;
|
||||
int WorkingDirLength;
|
||||
int ArgumentsLen;
|
||||
char* ExeOrFile;
|
||||
char* WorkingDir;
|
||||
char* Arguments;
|
||||
char *ExeOrFile;
|
||||
char *WorkingDir;
|
||||
char *Arguments;
|
||||
|
||||
LOG(0, ("chansrv::rail_process_exec:"));
|
||||
in_uint16_le(s, flags);
|
||||
@@ -267,6 +279,7 @@ rail_process_exec(struct stream* s, int size)
|
||||
"ArgumentsLen %d ExeOrFile [%s] WorkingDir [%s] "
|
||||
"Arguments [%s]", flags, ExeOrFileLength, WorkingDirLength,
|
||||
ArgumentsLen, ExeOrFile, WorkingDir, Arguments));
|
||||
|
||||
if (g_strlen(ExeOrFile) > 0)
|
||||
{
|
||||
LOG(10, ("rail_process_exec: pre"));
|
||||
@@ -278,6 +291,7 @@ rail_process_exec(struct stream* s, int size)
|
||||
tc_mutex_unlock(g_exec_mutex);
|
||||
LOG(10, ("rail_process_exec: post"));
|
||||
}
|
||||
|
||||
g_free(ExeOrFile);
|
||||
g_free(WorkingDir);
|
||||
g_free(Arguments);
|
||||
@@ -286,7 +300,7 @@ rail_process_exec(struct stream* s, int size)
|
||||
|
||||
/*****************************************************************************/
|
||||
static int APP_CC
|
||||
rail_process_activate(struct stream* s, int size)
|
||||
rail_process_activate(struct stream *s, int size)
|
||||
{
|
||||
int window_id;
|
||||
int enabled;
|
||||
@@ -295,6 +309,7 @@ rail_process_activate(struct stream* s, int size)
|
||||
in_uint32_le(s, window_id);
|
||||
in_uint8(s, enabled);
|
||||
LOG(10, (" window_id 0x%8.8x enabled %d", window_id, enabled));
|
||||
|
||||
if (enabled)
|
||||
{
|
||||
LOG(10, ("chansrv::rail_process_activate: calling XRaiseWindow 0x%8.8x", window_id));
|
||||
@@ -302,12 +317,13 @@ rail_process_activate(struct stream* s, int size)
|
||||
LOG(10, ("chansrv::rail_process_activate: calling XSetInputFocus 0x%8.8x", window_id));
|
||||
XSetInputFocus(g_display, window_id, RevertToParent, CurrentTime);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
static int APP_CC
|
||||
rail_process_system_param(struct stream* s, int size)
|
||||
rail_process_system_param(struct stream *s, int size)
|
||||
{
|
||||
int system_param;
|
||||
|
||||
@@ -338,7 +354,7 @@ rail_close_window(int window_id)
|
||||
|
||||
/*****************************************************************************/
|
||||
static int APP_CC
|
||||
rail_process_system_command(struct stream* s, int size)
|
||||
rail_process_system_command(struct stream *s, int size)
|
||||
{
|
||||
int window_id;
|
||||
int command;
|
||||
@@ -346,6 +362,7 @@ rail_process_system_command(struct stream* s, int size)
|
||||
LOG(10, ("chansrv::rail_process_system_command:"));
|
||||
in_uint32_le(s, window_id);
|
||||
in_uint16_le(s, command);
|
||||
|
||||
switch (command)
|
||||
{
|
||||
case SC_SIZE:
|
||||
@@ -378,12 +395,13 @@ rail_process_system_command(struct stream* s, int size)
|
||||
window_id, command));
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
static int APP_CC
|
||||
rail_process_handshake(struct stream* s, int size)
|
||||
rail_process_handshake(struct stream *s, int size)
|
||||
{
|
||||
int build_number;
|
||||
|
||||
@@ -395,7 +413,7 @@ rail_process_handshake(struct stream* s, int size)
|
||||
|
||||
/*****************************************************************************/
|
||||
static int APP_CC
|
||||
rail_process_notify_event(struct stream* s, int size)
|
||||
rail_process_notify_event(struct stream *s, int size)
|
||||
{
|
||||
int window_id;
|
||||
int notify_id;
|
||||
@@ -412,7 +430,7 @@ rail_process_notify_event(struct stream* s, int size)
|
||||
|
||||
/*****************************************************************************/
|
||||
static int APP_CC
|
||||
rail_process_window_move(struct stream* s, int size)
|
||||
rail_process_window_move(struct stream *s, int size)
|
||||
{
|
||||
int window_id;
|
||||
int left;
|
||||
@@ -434,7 +452,7 @@ rail_process_window_move(struct stream* s, int size)
|
||||
|
||||
/*****************************************************************************/
|
||||
static int APP_CC
|
||||
rail_process_local_move_size(struct stream* s, int size)
|
||||
rail_process_local_move_size(struct stream *s, int size)
|
||||
{
|
||||
int window_id;
|
||||
int is_move_size_start;
|
||||
@@ -457,7 +475,7 @@ rail_process_local_move_size(struct stream* s, int size)
|
||||
/*****************************************************************************/
|
||||
/* server to client only */
|
||||
static int APP_CC
|
||||
rail_process_min_max_info(struct stream* s, int size)
|
||||
rail_process_min_max_info(struct stream *s, int size)
|
||||
{
|
||||
LOG(10, ("chansrv::rail_process_min_max_info:"));
|
||||
return 0;
|
||||
@@ -465,7 +483,7 @@ rail_process_min_max_info(struct stream* s, int size)
|
||||
|
||||
/*****************************************************************************/
|
||||
static int APP_CC
|
||||
rail_process_client_status(struct stream* s, int size)
|
||||
rail_process_client_status(struct stream *s, int size)
|
||||
{
|
||||
int flags;
|
||||
|
||||
@@ -477,7 +495,7 @@ rail_process_client_status(struct stream* s, int size)
|
||||
|
||||
/*****************************************************************************/
|
||||
static int APP_CC
|
||||
rail_process_sys_menu(struct stream* s, int size)
|
||||
rail_process_sys_menu(struct stream *s, int size)
|
||||
{
|
||||
int window_id;
|
||||
int left;
|
||||
@@ -493,7 +511,7 @@ rail_process_sys_menu(struct stream* s, int size)
|
||||
|
||||
/*****************************************************************************/
|
||||
static int APP_CC
|
||||
rail_process_lang_bar_info(struct stream* s, int size)
|
||||
rail_process_lang_bar_info(struct stream *s, int size)
|
||||
{
|
||||
int language_bar_status;
|
||||
|
||||
@@ -505,7 +523,7 @@ rail_process_lang_bar_info(struct stream* s, int size)
|
||||
|
||||
/*****************************************************************************/
|
||||
static int APP_CC
|
||||
rail_process_appid_req(struct stream* s, int size)
|
||||
rail_process_appid_req(struct stream *s, int size)
|
||||
{
|
||||
LOG(10, ("chansrv::rail_process_appid_req:"));
|
||||
return 0;
|
||||
@@ -513,7 +531,7 @@ rail_process_appid_req(struct stream* s, int size)
|
||||
|
||||
/*****************************************************************************/
|
||||
static int APP_CC
|
||||
rail_process_appid_resp(struct stream* s, int size)
|
||||
rail_process_appid_resp(struct stream *s, int size)
|
||||
{
|
||||
LOG(10, ("chansrv::rail_process_appid_resp:"));
|
||||
return 0;
|
||||
@@ -522,7 +540,7 @@ rail_process_appid_resp(struct stream* s, int size)
|
||||
/*****************************************************************************/
|
||||
/* server to client only */
|
||||
static int APP_CC
|
||||
rail_process_exec_result(struct stream* s, int size)
|
||||
rail_process_exec_result(struct stream *s, int size)
|
||||
{
|
||||
LOG(10, ("chansrv::rail_process_exec_result:"));
|
||||
return 0;
|
||||
@@ -531,7 +549,7 @@ rail_process_exec_result(struct stream* s, int size)
|
||||
/*****************************************************************************/
|
||||
/* data in from client ( client -> xrdp -> chansrv ) */
|
||||
int APP_CC
|
||||
rail_data_in(struct stream* s, int chan_id, int chan_flags, int length,
|
||||
rail_data_in(struct stream *s, int chan_id, int chan_flags, int length,
|
||||
int total_length)
|
||||
{
|
||||
int code;
|
||||
@@ -541,6 +559,7 @@ rail_data_in(struct stream* s, int chan_id, int chan_flags, int length,
|
||||
in_uint8(s, code);
|
||||
in_uint8s(s, 1);
|
||||
in_uint16_le(s, size);
|
||||
|
||||
switch (code)
|
||||
{
|
||||
case TS_RAIL_ORDER_EXEC: /* 1 */
|
||||
@@ -592,6 +611,7 @@ rail_data_in(struct stream* s, int chan_id, int chan_flags, int length,
|
||||
LOG(10, ("rail_data_in: unknown code %d size %d", code, size));
|
||||
break;
|
||||
}
|
||||
|
||||
XFlush(g_display);
|
||||
return 0;
|
||||
}
|
||||
@@ -599,9 +619,9 @@ rail_data_in(struct stream* s, int chan_id, int chan_flags, int length,
|
||||
/*****************************************************************************/
|
||||
/* returns 0, event handled, 1 unhandled */
|
||||
int APP_CC
|
||||
rail_xevent(void* xevent)
|
||||
rail_xevent(void *xevent)
|
||||
{
|
||||
XEvent* lxevent;
|
||||
XEvent *lxevent;
|
||||
XWindowChanges xwc;
|
||||
int rv;
|
||||
int nchildren_return = 0;
|
||||
@@ -613,12 +633,15 @@ rail_xevent(void* xevent)
|
||||
XWindowAttributes wnd_attributes;
|
||||
|
||||
LOG(10, ("chansrv::rail_xevent:"));
|
||||
|
||||
if (!g_rail_up)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
rv = 1;
|
||||
lxevent = (XEvent*)xevent;
|
||||
lxevent = (XEvent *)xevent;
|
||||
|
||||
switch (lxevent->type)
|
||||
{
|
||||
case ConfigureRequest:
|
||||
@@ -673,5 +696,6 @@ rail_xevent(void* xevent)
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
+53
-23
@@ -28,17 +28,17 @@ static int g_training_sent_time = 0;
|
||||
static int g_cBlockNo = 0;
|
||||
|
||||
#if defined(XRDP_SIMPLESOUND)
|
||||
static void* DEFAULT_CC
|
||||
read_raw_audio_data(void* arg);
|
||||
static void *DEFAULT_CC
|
||||
read_raw_audio_data(void *arg);
|
||||
#endif
|
||||
|
||||
/*****************************************************************************/
|
||||
static int APP_CC
|
||||
sound_send_server_formats(void)
|
||||
{
|
||||
struct stream* s;
|
||||
struct stream *s;
|
||||
int bytes;
|
||||
char* size_ptr;
|
||||
char *size_ptr;
|
||||
|
||||
print_got_here();
|
||||
|
||||
@@ -97,10 +97,10 @@ sound_send_server_formats(void)
|
||||
static int
|
||||
sound_send_training(void)
|
||||
{
|
||||
struct stream* s;
|
||||
struct stream *s;
|
||||
int bytes;
|
||||
int time;
|
||||
char* size_ptr;
|
||||
char *size_ptr;
|
||||
|
||||
print_got_here();
|
||||
|
||||
@@ -132,34 +132,38 @@ sound_send_training(void)
|
||||
*/
|
||||
|
||||
static int APP_CC
|
||||
sound_process_formats(struct stream* s, int size)
|
||||
sound_process_formats(struct stream *s, int size)
|
||||
{
|
||||
int num_formats;
|
||||
|
||||
print_got_here();
|
||||
|
||||
LOG(0, ("sound_process_formats:"));
|
||||
|
||||
if (size < 16)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint8s(s, 14);
|
||||
in_uint16_le(s, num_formats);
|
||||
|
||||
if (num_formats > 0)
|
||||
{
|
||||
sound_send_training();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
static int
|
||||
sound_send_wave_data(char* data, int data_bytes)
|
||||
sound_send_wave_data(char *data, int data_bytes)
|
||||
{
|
||||
struct stream* s;
|
||||
struct stream *s;
|
||||
int bytes;
|
||||
int time;
|
||||
char* size_ptr;
|
||||
char *size_ptr;
|
||||
|
||||
print_got_here();
|
||||
|
||||
@@ -210,7 +214,7 @@ sound_send_wave_data(char* data, int data_bytes)
|
||||
|
||||
/*****************************************************************************/
|
||||
static int APP_CC
|
||||
sound_process_training(struct stream* s, int size)
|
||||
sound_process_training(struct stream *s, int size)
|
||||
{
|
||||
int time_diff;
|
||||
|
||||
@@ -223,7 +227,7 @@ sound_process_training(struct stream* s, int size)
|
||||
|
||||
/*****************************************************************************/
|
||||
static int APP_CC
|
||||
sound_process_wave_confirm(struct stream* s, int size)
|
||||
sound_process_wave_confirm(struct stream *s, int size)
|
||||
{
|
||||
int wTimeStamp;
|
||||
int cConfirmedBlockNo;
|
||||
@@ -241,7 +245,7 @@ sound_process_wave_confirm(struct stream* s, int size)
|
||||
|
||||
/*****************************************************************************/
|
||||
static int APP_CC
|
||||
process_pcm_message(int id, int size, struct stream* s)
|
||||
process_pcm_message(int id, int size, struct stream *s)
|
||||
{
|
||||
print_got_here();
|
||||
|
||||
@@ -252,7 +256,7 @@ process_pcm_message(int id, int size, struct stream* s)
|
||||
/*****************************************************************************/
|
||||
/* data coming in from audio source, eg pulse, alsa */
|
||||
static int DEFAULT_CC
|
||||
sound_trans_audio_data_in(struct trans* trans)
|
||||
sound_trans_audio_data_in(struct trans *trans)
|
||||
{
|
||||
struct stream *s;
|
||||
int id;
|
||||
@@ -263,24 +267,30 @@ sound_trans_audio_data_in(struct trans* trans)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (trans != g_audio_c_trans)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
s = trans_get_in_s(trans);
|
||||
in_uint32_le(s, id);
|
||||
in_uint32_le(s, size);
|
||||
|
||||
if ((id != 0) || (size > 32 * 1024 + 8) || (size < 1))
|
||||
{
|
||||
LOG(0, ("sound_trans_audio_data_in: bad message id %d size %d", id, size));
|
||||
return 1;
|
||||
}
|
||||
|
||||
error = trans_force_read(trans, size - 8);
|
||||
|
||||
if (error == 0)
|
||||
{
|
||||
/* here, the entire message block is read in, process it */
|
||||
error = process_pcm_message(id, size - 8, s);
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -294,18 +304,22 @@ sound_trans_audio_conn_in(struct trans *trans, struct trans *new_trans)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (trans != g_audio_l_trans)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (g_audio_c_trans != 0) /* if already set, error */
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (new_trans == 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
g_audio_c_trans = new_trans;
|
||||
g_audio_c_trans->trans_data_in = sound_trans_audio_data_in;
|
||||
g_audio_c_trans->header_size = 8;
|
||||
@@ -329,6 +343,7 @@ sound_init(void)
|
||||
g_snprintf(port, 255, "/tmp/xrdp_chansrv_audio_socket_%d", g_display_num);
|
||||
g_audio_l_trans->trans_conn_in = sound_trans_audio_conn_in;
|
||||
error = trans_listen(g_audio_l_trans, port);
|
||||
|
||||
if (error != 0)
|
||||
{
|
||||
LOG(0, ("sound_init: trans_listen failed"));
|
||||
@@ -355,6 +370,7 @@ sound_deinit(void)
|
||||
trans_delete(g_audio_l_trans);
|
||||
g_audio_l_trans = 0;
|
||||
}
|
||||
|
||||
if (g_audio_c_trans != 0)
|
||||
{
|
||||
trans_delete(g_audio_c_trans);
|
||||
@@ -367,7 +383,7 @@ sound_deinit(void)
|
||||
/*****************************************************************************/
|
||||
/* data in from client ( clinet -> xrdp -> chansrv ) */
|
||||
int APP_CC
|
||||
sound_data_in(struct stream* s, int chan_id, int chan_flags, int length,
|
||||
sound_data_in(struct stream *s, int chan_id, int chan_flags, int length,
|
||||
int total_length)
|
||||
{
|
||||
int code;
|
||||
@@ -378,6 +394,7 @@ sound_data_in(struct stream* s, int chan_id, int chan_flags, int length,
|
||||
in_uint8(s, code);
|
||||
in_uint8s(s, 1);
|
||||
in_uint16_le(s, size);
|
||||
|
||||
switch (code)
|
||||
{
|
||||
case SNDC_WAVECONFIRM:
|
||||
@@ -396,26 +413,30 @@ sound_data_in(struct stream* s, int chan_id, int chan_flags, int length,
|
||||
LOG(0, ("sound_data_in: unknown code %d size %d", code, size));
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
int APP_CC
|
||||
sound_get_wait_objs(tbus* objs, int* count, int* timeout)
|
||||
sound_get_wait_objs(tbus *objs, int *count, int *timeout)
|
||||
{
|
||||
int lcount;
|
||||
|
||||
lcount = *count;
|
||||
|
||||
if (g_audio_l_trans != 0)
|
||||
{
|
||||
objs[lcount] = g_audio_l_trans->sck;
|
||||
lcount++;
|
||||
}
|
||||
|
||||
if (g_audio_c_trans != 0)
|
||||
{
|
||||
objs[lcount] = g_audio_c_trans->sck;
|
||||
lcount++;
|
||||
}
|
||||
|
||||
*count = lcount;
|
||||
return 0;
|
||||
}
|
||||
@@ -440,7 +461,7 @@ sound_check_wait_objs(void)
|
||||
#if defined(XRDP_SIMPLESOUND)
|
||||
|
||||
static int DEFAULT_CC
|
||||
sttrans_data_in(struct trans* self)
|
||||
sttrans_data_in(struct trans *self)
|
||||
{
|
||||
LOG(0, ("sttrans_data_in:\n"));
|
||||
return 0;
|
||||
@@ -451,27 +472,30 @@ sttrans_data_in(struct trans* self)
|
||||
* to a unix domain socket on which trans server is listening
|
||||
*/
|
||||
|
||||
static void* DEFAULT_CC
|
||||
read_raw_audio_data(void* arg)
|
||||
static void *DEFAULT_CC
|
||||
read_raw_audio_data(void *arg)
|
||||
{
|
||||
pa_sample_spec samp_spec;
|
||||
pa_simple* simple = NULL;
|
||||
pa_simple *simple = NULL;
|
||||
uint32_t bytes_read;
|
||||
char* cptr;
|
||||
char *cptr;
|
||||
int i;
|
||||
int error;
|
||||
struct trans* strans;
|
||||
struct trans *strans;
|
||||
char path[256];
|
||||
struct stream* outs;
|
||||
struct stream *outs;
|
||||
|
||||
strans = trans_create(TRANS_MODE_UNIX, 8192, 8192);
|
||||
|
||||
if (strans == 0)
|
||||
{
|
||||
LOG(0, ("read_raw_audio_data: trans_create failed\n"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
strans->trans_data_in = sttrans_data_in;
|
||||
g_snprintf(path, 255, "/tmp/xrdp_chansrv_audio_socket_%d", g_display_num);
|
||||
|
||||
if (trans_connect(strans, "", path, 100) != 0)
|
||||
{
|
||||
LOG(0, ("read_raw_audio_data: trans_connect failed\n"));
|
||||
@@ -493,12 +517,14 @@ read_raw_audio_data(void* arg)
|
||||
{
|
||||
simple = pa_simple_new(NULL, "xrdp", PA_STREAM_RECORD, NULL,
|
||||
"record", &samp_spec, NULL, NULL, &error);
|
||||
|
||||
if (simple)
|
||||
{
|
||||
/* connected to pulseaudio server */
|
||||
LOG(0, ("read_raw_audio_data: connected to pulseaudio server\n"));
|
||||
break;
|
||||
}
|
||||
|
||||
LOG(0, ("read_raw_audio_data: ERROR creating PulseAudio async interface\n"));
|
||||
LOG(0, ("read_raw_audio_data: %s\n", pa_strerror(error)));
|
||||
g_sleep(1000);
|
||||
@@ -524,12 +550,14 @@ read_raw_audio_data(void* arg)
|
||||
/* read a block of raw audio data... */
|
||||
g_memset(cptr, 0, 4);
|
||||
bytes_read = pa_simple_read(simple, cptr, AUDIO_BUF_SIZE, &error);
|
||||
|
||||
if (bytes_read < 0)
|
||||
{
|
||||
LOG(0, ("read_raw_audio_data: ERROR reading from pulseaudio stream\n"));
|
||||
LOG(0, ("read_raw_audio_data: %s\n", pa_strerror(error)));
|
||||
break;
|
||||
}
|
||||
|
||||
/* bug workaround:
|
||||
even when there is no audio data, pulseaudio is returning without
|
||||
errors but the data itself is zero; we use this zero data to
|
||||
@@ -539,12 +567,14 @@ read_raw_audio_data(void* arg)
|
||||
g_sleep(10);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (trans_force_write_s(strans, outs) != 0)
|
||||
{
|
||||
LOG(0, ("read_raw_audio_data: ERROR writing audio data to server\n"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
pa_simple_free(simple);
|
||||
trans_delete(strans);
|
||||
return NULL;
|
||||
|
||||
@@ -31,10 +31,10 @@ extern int g_waiting_for_data_response_time; /* in clipboard.c */
|
||||
|
||||
extern int g_rail_up; /* in rail.c */
|
||||
|
||||
Display* g_display = 0;
|
||||
Display *g_display = 0;
|
||||
int g_x_socket = 0;
|
||||
tbus g_x_wait_obj = 0;
|
||||
Screen* g_screen = 0;
|
||||
Screen *g_screen = 0;
|
||||
int g_screen_num = 0;
|
||||
Window g_root_window = 0;
|
||||
Atom g_wm_delete_window_atom = 0;
|
||||
@@ -42,7 +42,7 @@ Atom g_wm_protocols_atom = 0;
|
||||
|
||||
/*****************************************************************************/
|
||||
static int DEFAULT_CC
|
||||
xcommon_error_handler(Display* dis, XErrorEvent* xer)
|
||||
xcommon_error_handler(Display *dis, XErrorEvent *xer)
|
||||
{
|
||||
char text[256];
|
||||
|
||||
@@ -58,7 +58,7 @@ xcommon_error_handler(Display* dis, XErrorEvent* xer)
|
||||
Do any cleanup that needs to be done on exit, like removing temporary files.
|
||||
Don't worry about memory leaks */
|
||||
static int DEFAULT_CC
|
||||
xcommon_fatal_handler(Display* dis)
|
||||
xcommon_fatal_handler(Display *dis)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -84,7 +84,9 @@ xcommon_init(void)
|
||||
LOG(10, ("xcommon_init: xcommon_init already called"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
g_display = XOpenDisplay(0);
|
||||
|
||||
if (g_display == 0)
|
||||
{
|
||||
LOGM((LOG_LEVEL_ERROR, "xcommon_init: error, XOpenDisplay failed"));
|
||||
@@ -99,6 +101,7 @@ xcommon_init(void)
|
||||
//XSetIOErrorHandler(xcommon_fatal_handler);
|
||||
|
||||
g_x_socket = XConnectionNumber(g_display);
|
||||
|
||||
if (g_x_socket == 0)
|
||||
{
|
||||
LOGM((LOG_LEVEL_ERROR, "xcommon_init: XConnectionNumber failed"));
|
||||
@@ -122,7 +125,7 @@ xcommon_init(void)
|
||||
this is called to get any wait objects for the main loop
|
||||
timeout can be nil */
|
||||
int APP_CC
|
||||
xcommon_get_wait_objs(tbus* objs, int* count, int* timeout)
|
||||
xcommon_get_wait_objs(tbus *objs, int *count, int *timeout)
|
||||
{
|
||||
int lcount;
|
||||
|
||||
@@ -131,6 +134,7 @@ xcommon_get_wait_objs(tbus* objs, int* count, int* timeout)
|
||||
LOG(10, ("xcommon_get_wait_objs: nothing to do"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
lcount = *count;
|
||||
objs[lcount] = g_x_wait_obj;
|
||||
lcount++;
|
||||
@@ -152,6 +156,7 @@ xcommon_check_wait_objs(void)
|
||||
LOG(10, ("xcommon_check_wait_objs: nothing to do"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (g_is_wait_obj_set(g_x_wait_obj))
|
||||
{
|
||||
if (XPending(g_display) < 1)
|
||||
@@ -160,16 +165,19 @@ xcommon_check_wait_objs(void)
|
||||
LOGM((LOG_LEVEL_ERROR, "xcommon_check_wait_objs: sck closed"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (g_waiting_for_data_response)
|
||||
{
|
||||
time_diff = xcommon_get_local_time() -
|
||||
g_waiting_for_data_response_time;
|
||||
|
||||
if (time_diff > 10000)
|
||||
{
|
||||
LOGM((LOG_LEVEL_ERROR, "xcommon_check_wait_objs: warning, "
|
||||
"waiting for data response too long"));
|
||||
}
|
||||
}
|
||||
|
||||
while (XPending(g_display) > 0)
|
||||
{
|
||||
g_memset(&xevent, 0, sizeof(xevent));
|
||||
@@ -177,11 +185,13 @@ xcommon_check_wait_objs(void)
|
||||
|
||||
clip_rv = clipboard_xevent(&xevent);
|
||||
rail_rv = rail_xevent(&xevent);
|
||||
|
||||
if ((clip_rv == 1) && (rail_rv == 1))
|
||||
{
|
||||
LOG(10, ("xcommon_check_wait_objs unknown xevent type %d", xevent.type));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
+91
-69
@@ -1,21 +1,20 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -31,22 +30,23 @@
|
||||
#include "sesman.h"
|
||||
#include "log.h"
|
||||
|
||||
extern struct config_sesman* g_cfg; /* in sesman.c */
|
||||
extern struct config_sesman *g_cfg; /* in sesman.c */
|
||||
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
int DEFAULT_CC
|
||||
config_read(struct config_sesman* cfg)
|
||||
config_read(struct config_sesman *cfg)
|
||||
{
|
||||
int fd;
|
||||
struct list* sec;
|
||||
struct list* param_n;
|
||||
struct list* param_v;
|
||||
struct list *sec;
|
||||
struct list *param_n;
|
||||
struct list *param_v;
|
||||
char cfg_file[256];
|
||||
|
||||
g_snprintf(cfg_file, 255, "%s/sesman.ini", XRDP_CFG_PATH);
|
||||
fd = g_file_open(cfg_file);
|
||||
|
||||
if (-1 == fd)
|
||||
{
|
||||
//if (g_cfg->log.fd >= 0)
|
||||
@@ -61,6 +61,7 @@ config_read(struct config_sesman* cfg)
|
||||
//}
|
||||
return 1;
|
||||
}
|
||||
|
||||
g_memset(cfg, 0, sizeof(struct config_sesman));
|
||||
sec = list_create();
|
||||
sec->auto_free = 1;
|
||||
@@ -96,11 +97,11 @@ config_read(struct config_sesman* cfg)
|
||||
|
||||
/******************************************************************************/
|
||||
int DEFAULT_CC
|
||||
config_read_globals(int file, struct config_sesman* cf, struct list* param_n,
|
||||
struct list* param_v)
|
||||
config_read_globals(int file, struct config_sesman *cf, struct list *param_n,
|
||||
struct list *param_v)
|
||||
{
|
||||
int i;
|
||||
char* buf;
|
||||
char *buf;
|
||||
|
||||
list_clear(param_v);
|
||||
list_clear(param_n);
|
||||
@@ -114,32 +115,34 @@ config_read_globals(int file, struct config_sesman* cf, struct list* param_n,
|
||||
cf->auth_file_path = 0;
|
||||
|
||||
file_read_section(file, SESMAN_CFG_GLOBALS, param_n, param_v);
|
||||
|
||||
for (i = 0; i < param_n->count; i++)
|
||||
{
|
||||
buf = (char*)list_get_item(param_n, i);
|
||||
buf = (char *)list_get_item(param_n, i);
|
||||
|
||||
if (0 == g_strcasecmp(buf, SESMAN_CFG_DEFWM))
|
||||
{
|
||||
g_strncpy(cf->default_wm, (char*)list_get_item(param_v, i), 31);
|
||||
g_strncpy(cf->default_wm, (char *)list_get_item(param_v, i), 31);
|
||||
}
|
||||
else if (0 == g_strcasecmp(buf, SESMAN_CFG_USERWM))
|
||||
{
|
||||
g_strncpy(cf->user_wm, (char*)list_get_item(param_v, i), 31);
|
||||
g_strncpy(cf->user_wm, (char *)list_get_item(param_v, i), 31);
|
||||
}
|
||||
else if (0 == g_strcasecmp(buf, SESMAN_CFG_ENABLE_USERWM))
|
||||
{
|
||||
cf->enable_user_wm = text2bool((char*)list_get_item(param_v, i));
|
||||
cf->enable_user_wm = text2bool((char *)list_get_item(param_v, i));
|
||||
}
|
||||
else if (0 == g_strcasecmp(buf, SESMAN_CFG_PORT))
|
||||
{
|
||||
g_strncpy(cf->listen_port, (char*)list_get_item(param_v, i), 15);
|
||||
g_strncpy(cf->listen_port, (char *)list_get_item(param_v, i), 15);
|
||||
}
|
||||
else if (0 == g_strcasecmp(buf, SESMAN_CFG_ADDRESS))
|
||||
{
|
||||
g_strncpy(cf->listen_address, (char*)list_get_item(param_v, i), 31);
|
||||
g_strncpy(cf->listen_address, (char *)list_get_item(param_v, i), 31);
|
||||
}
|
||||
else if (0 == g_strcasecmp(buf, SESMAN_CFG_AUTH_FILE_PATH))
|
||||
{
|
||||
cf->auth_file_path = g_strdup((char*)list_get_item(param_v, i));
|
||||
cf->auth_file_path = g_strdup((char *)list_get_item(param_v, i));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,14 +151,17 @@ config_read_globals(int file, struct config_sesman* cf, struct list* param_n,
|
||||
{
|
||||
g_strncpy(cf->listen_address, "0.0.0.0", 8);
|
||||
}
|
||||
|
||||
if ('\0' == cf->listen_port[0])
|
||||
{
|
||||
g_strncpy(cf->listen_port, "3350", 5);
|
||||
}
|
||||
|
||||
if ('\0' == cf->user_wm[0])
|
||||
{
|
||||
cf->enable_user_wm = 0;
|
||||
}
|
||||
|
||||
if ('\0' == cf->default_wm[0])
|
||||
{
|
||||
g_strncpy(cf->default_wm, "startwm.sh", 11);
|
||||
@@ -230,13 +236,13 @@ config_read_logging(int file, struct log_config* lc, struct list* param_n,
|
||||
*/
|
||||
/******************************************************************************/
|
||||
int DEFAULT_CC
|
||||
config_read_security(int file, struct config_security* sc,
|
||||
struct list* param_n,
|
||||
struct list* param_v)
|
||||
config_read_security(int file, struct config_security *sc,
|
||||
struct list *param_n,
|
||||
struct list *param_v)
|
||||
{
|
||||
int i;
|
||||
int gid;
|
||||
char* buf;
|
||||
char *buf;
|
||||
|
||||
list_clear(param_v);
|
||||
list_clear(param_n);
|
||||
@@ -248,28 +254,33 @@ config_read_security(int file, struct config_security* sc,
|
||||
sc->ts_admins_enable = 0;
|
||||
|
||||
file_read_section(file, SESMAN_CFG_SECURITY, param_n, param_v);
|
||||
|
||||
for (i = 0; i < param_n->count; i++)
|
||||
{
|
||||
buf = (char*)list_get_item(param_n, i);
|
||||
buf = (char *)list_get_item(param_n, i);
|
||||
|
||||
if (0 == g_strcasecmp(buf, SESMAN_CFG_SEC_ALLOW_ROOT))
|
||||
{
|
||||
sc->allow_root = text2bool((char*)list_get_item(param_v, i));
|
||||
sc->allow_root = text2bool((char *)list_get_item(param_v, i));
|
||||
}
|
||||
|
||||
if (0 == g_strcasecmp(buf, SESMAN_CFG_SEC_LOGIN_RETRY))
|
||||
{
|
||||
sc->login_retry = g_atoi((char*)list_get_item(param_v, i));
|
||||
sc->login_retry = g_atoi((char *)list_get_item(param_v, i));
|
||||
}
|
||||
|
||||
if (0 == g_strcasecmp(buf, SESMAN_CFG_SEC_USR_GROUP))
|
||||
{
|
||||
if (g_getgroup_info((char*)list_get_item(param_v, i), &gid) == 0)
|
||||
if (g_getgroup_info((char *)list_get_item(param_v, i), &gid) == 0)
|
||||
{
|
||||
sc->ts_users_enable = 1;
|
||||
sc->ts_users = gid;
|
||||
}
|
||||
}
|
||||
|
||||
if (0 == g_strcasecmp(buf, SESMAN_CFG_SEC_ADM_GROUP))
|
||||
{
|
||||
if (g_getgroup_info((char*)list_get_item(param_v, i), &gid) == 0)
|
||||
if (g_getgroup_info((char *)list_get_item(param_v, i), &gid) == 0)
|
||||
{
|
||||
sc->ts_admins_enable = 1;
|
||||
sc->ts_admins = gid;
|
||||
@@ -279,8 +290,9 @@ config_read_security(int file, struct config_security* sc,
|
||||
|
||||
/* printing security config */
|
||||
g_printf("security configuration:\r\n");
|
||||
g_printf("\tAllowRootLogin: %i\r\n",sc->allow_root);
|
||||
g_printf("\tMaxLoginRetry: %i\r\n",sc->login_retry);
|
||||
g_printf("\tAllowRootLogin: %i\r\n", sc->allow_root);
|
||||
g_printf("\tMaxLoginRetry: %i\r\n", sc->login_retry);
|
||||
|
||||
if (sc->ts_users_enable)
|
||||
{
|
||||
g_printf("\tTSUsersGroup: %i\r\n", sc->ts_users);
|
||||
@@ -289,6 +301,7 @@ config_read_security(int file, struct config_security* sc,
|
||||
{
|
||||
g_printf("\tNo TSUsersGroup defined\r\n");
|
||||
}
|
||||
|
||||
if (sc->ts_admins_enable)
|
||||
{
|
||||
g_printf("\tTSAdminsGroup: %i\r\n", sc->ts_admins);
|
||||
@@ -303,45 +316,51 @@ config_read_security(int file, struct config_security* sc,
|
||||
|
||||
/******************************************************************************/
|
||||
int DEFAULT_CC
|
||||
config_read_sessions(int file, struct config_sessions* se, struct list* param_n,
|
||||
struct list* param_v)
|
||||
config_read_sessions(int file, struct config_sessions *se, struct list *param_n,
|
||||
struct list *param_v)
|
||||
{
|
||||
int i;
|
||||
char* buf;
|
||||
char *buf;
|
||||
|
||||
list_clear(param_v);
|
||||
list_clear(param_n);
|
||||
|
||||
/* setting defaults */
|
||||
se->x11_display_offset=10;
|
||||
se->max_sessions=0;
|
||||
se->max_idle_time=0;
|
||||
se->max_disc_time=0;
|
||||
se->kill_disconnected=0;
|
||||
se->x11_display_offset = 10;
|
||||
se->max_sessions = 0;
|
||||
se->max_idle_time = 0;
|
||||
se->max_disc_time = 0;
|
||||
se->kill_disconnected = 0;
|
||||
|
||||
file_read_section(file, SESMAN_CFG_SESSIONS, param_n, param_v);
|
||||
|
||||
for (i = 0; i < param_n->count; i++)
|
||||
{
|
||||
buf = (char*)list_get_item(param_n, i);
|
||||
buf = (char *)list_get_item(param_n, i);
|
||||
|
||||
if (0 == g_strcasecmp(buf, SESMAN_CFG_X11DISPLAYOFFSET))
|
||||
{
|
||||
se->x11_display_offset = g_atoi((char*)list_get_item(param_v, i));
|
||||
se->x11_display_offset = g_atoi((char *)list_get_item(param_v, i));
|
||||
}
|
||||
|
||||
if (0 == g_strcasecmp(buf, SESMAN_CFG_SESS_MAX))
|
||||
{
|
||||
se->max_sessions = g_atoi((char*)list_get_item(param_v, i));
|
||||
se->max_sessions = g_atoi((char *)list_get_item(param_v, i));
|
||||
}
|
||||
|
||||
if (0 == g_strcasecmp(buf, SESMAN_CFG_SESS_KILL_DISC))
|
||||
{
|
||||
se->kill_disconnected = text2bool((char*)list_get_item(param_v, i));
|
||||
se->kill_disconnected = text2bool((char *)list_get_item(param_v, i));
|
||||
}
|
||||
|
||||
if (0 == g_strcasecmp(buf, SESMAN_CFG_SESS_IDLE_LIMIT))
|
||||
{
|
||||
se->max_idle_time=g_atoi((char*)list_get_item(param_v, i));
|
||||
se->max_idle_time = g_atoi((char *)list_get_item(param_v, i));
|
||||
}
|
||||
|
||||
if (0 == g_strcasecmp(buf, SESMAN_CFG_SESS_DISC_LIMIT))
|
||||
{
|
||||
se->max_disc_time=g_atoi((char*)list_get_item(param_v, i));
|
||||
se->max_disc_time = g_atoi((char *)list_get_item(param_v, i));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -358,27 +377,29 @@ config_read_sessions(int file, struct config_sessions* se, struct list* param_n,
|
||||
|
||||
/******************************************************************************/
|
||||
int DEFAULT_CC
|
||||
config_read_rdp_params(int file, struct config_sesman* cs, struct list* param_n,
|
||||
struct list* param_v)
|
||||
config_read_rdp_params(int file, struct config_sesman *cs, struct list *param_n,
|
||||
struct list *param_v)
|
||||
{
|
||||
int i;
|
||||
|
||||
list_clear(param_v);
|
||||
list_clear(param_n);
|
||||
|
||||
cs->rdp_params=list_create();
|
||||
cs->rdp_params = list_create();
|
||||
|
||||
file_read_section(file, SESMAN_CFG_RDP_PARAMS, param_n, param_v);
|
||||
|
||||
for (i = 0; i < param_n->count; i++)
|
||||
{
|
||||
list_add_item(cs->rdp_params, (long)g_strdup((char*)list_get_item(param_v, i)));
|
||||
list_add_item(cs->rdp_params, (long)g_strdup((char *)list_get_item(param_v, i)));
|
||||
}
|
||||
|
||||
/* printing security config */
|
||||
g_printf("X11rdp parameters:\r\n");
|
||||
|
||||
for (i = 0; i < cs->rdp_params->count; i++)
|
||||
{
|
||||
g_printf("\tParameter %02d %s\r\n", i, (char*)list_get_item(cs->rdp_params, i));
|
||||
g_printf("\tParameter %02d %s\r\n", i, (char *)list_get_item(cs->rdp_params, i));
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -386,29 +407,30 @@ config_read_rdp_params(int file, struct config_sesman* cs, struct list* param_n,
|
||||
|
||||
/******************************************************************************/
|
||||
int DEFAULT_CC
|
||||
config_read_vnc_params(int file, struct config_sesman* cs, struct list* param_n,
|
||||
struct list* param_v)
|
||||
config_read_vnc_params(int file, struct config_sesman *cs, struct list *param_n,
|
||||
struct list *param_v)
|
||||
{
|
||||
int i;
|
||||
|
||||
list_clear(param_v);
|
||||
list_clear(param_n);
|
||||
|
||||
cs->vnc_params=list_create();
|
||||
cs->vnc_params = list_create();
|
||||
|
||||
file_read_section(file, SESMAN_CFG_VNC_PARAMS, param_n, param_v);
|
||||
|
||||
for (i = 0; i < param_n->count; i++)
|
||||
{
|
||||
list_add_item(cs->vnc_params, (long)g_strdup((char*)list_get_item(param_v, i)));
|
||||
list_add_item(cs->vnc_params, (long)g_strdup((char *)list_get_item(param_v, i)));
|
||||
}
|
||||
|
||||
/* printing security config */
|
||||
g_printf("Xvnc parameters:\r\n");
|
||||
|
||||
for (i = 0; i < cs->vnc_params->count; i++)
|
||||
{
|
||||
g_printf("\tParameter %02d %s\r\n", i, (char*)list_get_item(cs->vnc_params, i));
|
||||
g_printf("\tParameter %02d %s\r\n", i, (char *)list_get_item(cs->vnc_params, i));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
+17
-19
@@ -1,21 +1,20 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -296,4 +295,3 @@ config_read_vnc_params(int file, struct config_sesman* cs, struct list* param_n,
|
||||
struct list* param_v);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
+31
-22
@@ -1,21 +1,20 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -31,11 +30,11 @@
|
||||
#include "grp.h"
|
||||
|
||||
extern unsigned char g_fixedkey[8]; /* in sesman.c */
|
||||
extern struct config_sesman* g_cfg; /* in sesman.c */
|
||||
extern struct config_sesman *g_cfg; /* in sesman.c */
|
||||
|
||||
/******************************************************************************/
|
||||
int DEFAULT_CC
|
||||
env_check_password_file(char* filename, char* password)
|
||||
env_check_password_file(char *filename, char *password)
|
||||
{
|
||||
char encryptedPasswd[16];
|
||||
int fd;
|
||||
@@ -43,8 +42,9 @@ env_check_password_file(char* filename, char* password)
|
||||
g_memset(encryptedPasswd, 0, 16);
|
||||
g_strncpy(encryptedPasswd, password, 8);
|
||||
rfbDesKey(g_fixedkey, 0);
|
||||
rfbDes((unsigned char*)encryptedPasswd, (unsigned char*)encryptedPasswd);
|
||||
rfbDes((unsigned char *)encryptedPasswd, (unsigned char *)encryptedPasswd);
|
||||
fd = g_file_open(filename);
|
||||
|
||||
if (fd == -1)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING,
|
||||
@@ -52,6 +52,7 @@ env_check_password_file(char* filename, char* password)
|
||||
filename);
|
||||
return 1;
|
||||
}
|
||||
|
||||
g_file_write(fd, encryptedPasswd, 8);
|
||||
g_file_close(fd);
|
||||
return 0;
|
||||
@@ -59,7 +60,7 @@ env_check_password_file(char* filename, char* password)
|
||||
|
||||
/******************************************************************************/
|
||||
int DEFAULT_CC
|
||||
env_set_user(char* username, char* passwd_file, int display)
|
||||
env_set_user(char *username, char *passwd_file, int display)
|
||||
{
|
||||
int error;
|
||||
int pw_uid;
|
||||
@@ -72,20 +73,25 @@ env_set_user(char* username, char* passwd_file, int display)
|
||||
|
||||
error = g_getuser_info(username, &pw_gid, &pw_uid, pw_shell, pw_dir,
|
||||
pw_gecos);
|
||||
|
||||
if (error == 0)
|
||||
{
|
||||
g_rm_temp_dir();
|
||||
error = g_setgid(pw_gid);
|
||||
|
||||
if (error == 0)
|
||||
{
|
||||
error = g_initgroups(username, pw_gid);
|
||||
}
|
||||
|
||||
if (error == 0)
|
||||
{
|
||||
uid = pw_uid;
|
||||
error = g_setuid(uid);
|
||||
}
|
||||
|
||||
g_mk_temp_dir(0);
|
||||
|
||||
if (error == 0)
|
||||
{
|
||||
g_clearenv();
|
||||
@@ -98,6 +104,7 @@ env_set_user(char* username, char* passwd_file, int display)
|
||||
g_set_current_dir(pw_dir);
|
||||
g_sprintf(text, ":%d.0", display);
|
||||
g_setenv("DISPLAY", text, 1);
|
||||
|
||||
if (passwd_file != 0)
|
||||
{
|
||||
if (0 == g_cfg->auth_file_path)
|
||||
@@ -112,6 +119,7 @@ env_set_user(char* username, char* passwd_file, int display)
|
||||
/* we use auth_file_path as requested */
|
||||
g_sprintf(passwd_file, g_cfg->auth_file_path, username);
|
||||
}
|
||||
|
||||
LOG_DBG("pass file: %s", passwd_file);
|
||||
}
|
||||
}
|
||||
@@ -121,5 +129,6 @@ env_set_user(char* username, char* passwd_file, int display)
|
||||
log_message(LOG_LEVEL_ERROR,
|
||||
"error getting user info for user %s", username);
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
+17
-19
@@ -1,21 +1,20 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -52,4 +51,3 @@ int DEFAULT_CC
|
||||
env_set_user(char* username, char* passwd_file, int display);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
+17
-18
@@ -1,21 +1,20 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@@ -1,21 +1,20 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@@ -1,21 +1,20 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@@ -1,21 +1,20 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -29,10 +28,10 @@
|
||||
|
||||
//extern struct log_config* s_log;
|
||||
|
||||
struct SCP_CONNECTION*
|
||||
struct SCP_CONNECTION *
|
||||
scp_connection_create(int sck)
|
||||
{
|
||||
struct SCP_CONNECTION* conn;
|
||||
struct SCP_CONNECTION *conn;
|
||||
|
||||
conn = g_malloc(sizeof(struct SCP_CONNECTION), 0);
|
||||
|
||||
@@ -42,7 +41,7 @@ scp_connection_create(int sck)
|
||||
return 0;
|
||||
}
|
||||
|
||||
conn->in_sck=sck;
|
||||
conn->in_sck = sck;
|
||||
make_stream(conn->in_s);
|
||||
init_stream(conn->in_s, 8196);
|
||||
make_stream(conn->out_s);
|
||||
@@ -52,7 +51,7 @@ scp_connection_create(int sck)
|
||||
}
|
||||
|
||||
void
|
||||
scp_connection_destroy(struct SCP_CONNECTION* c)
|
||||
scp_connection_destroy(struct SCP_CONNECTION *c)
|
||||
{
|
||||
free_stream(c->in_s);
|
||||
free_stream(c->out_s);
|
||||
|
||||
@@ -1,21 +1,20 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -51,4 +50,3 @@ void
|
||||
scp_connection_destroy(struct SCP_CONNECTION* c);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
+19
-21
@@ -1,21 +1,20 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -33,12 +32,12 @@
|
||||
int DEFAULT_CC
|
||||
scp_init()
|
||||
{
|
||||
/*
|
||||
/*
|
||||
if (0 == log)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
*/
|
||||
*/
|
||||
|
||||
//s_log = log;
|
||||
|
||||
@@ -48,4 +47,3 @@ scp_init()
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
+17
-19
@@ -1,21 +1,20 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -45,4 +44,3 @@ int DEFAULT_CC
|
||||
scp_init();
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
+31
-29
@@ -1,25 +1,23 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
|
||||
session manager
|
||||
linux only
|
||||
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* session manager
|
||||
* linux only
|
||||
*/
|
||||
|
||||
#include "libscp_lock.h"
|
||||
|
||||
@@ -45,9 +43,9 @@ scp_lock_init(void)
|
||||
|
||||
/* here we don't use locking because lock_init() should be called BEFORE */
|
||||
/* any thread is created */
|
||||
lock_fork_blockers_count=0;
|
||||
lock_fork_waiting_count=0;
|
||||
lock_fork_forkers_count=0;
|
||||
lock_fork_blockers_count = 0;
|
||||
lock_fork_waiting_count = 0;
|
||||
lock_fork_forkers_count = 0;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
@@ -56,11 +54,13 @@ scp_lock_fork_request(void)
|
||||
{
|
||||
/* lock mutex */
|
||||
pthread_mutex_lock(&lock_fork);
|
||||
|
||||
if (lock_fork_blockers_count == 0)
|
||||
{
|
||||
/* if noone is blocking fork(), then we're allowed to fork */
|
||||
sem_post(&lock_fork_req);
|
||||
}
|
||||
|
||||
lock_fork_forkers_count++;
|
||||
pthread_mutex_unlock(&lock_fork);
|
||||
|
||||
@@ -81,11 +81,12 @@ scp_lock_fork_release(void)
|
||||
sem_post(&lock_fork_req);
|
||||
}
|
||||
|
||||
for (;lock_fork_waiting_count > 0; lock_fork_waiting_count--)
|
||||
for (; lock_fork_waiting_count > 0; lock_fork_waiting_count--)
|
||||
{
|
||||
/* waking up the other processes */
|
||||
sem_post(&lock_fork_wait);
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&lock_fork);
|
||||
}
|
||||
|
||||
@@ -104,10 +105,11 @@ scp_lock_fork_critical_section_end(int blocking)
|
||||
|
||||
/* if there's someone who wants to fork and we're the last blocking */
|
||||
/* then we let him go */
|
||||
if ((lock_fork_blockers_count == 0) && (lock_fork_forkers_count>0))
|
||||
if ((lock_fork_blockers_count == 0) && (lock_fork_forkers_count > 0))
|
||||
{
|
||||
sem_post(&lock_fork_req);
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&lock_fork);
|
||||
}
|
||||
|
||||
@@ -138,9 +140,9 @@ scp_lock_fork_critical_section_start(void)
|
||||
|
||||
return LIBSCP_LOCK_FORK_BLOCKER;
|
||||
}
|
||||
} while (1);
|
||||
}
|
||||
while (1);
|
||||
|
||||
/* we'll never get here */
|
||||
return LIBSCP_LOCK_FORK_WAITING;
|
||||
}
|
||||
|
||||
|
||||
+17
-19
@@ -1,21 +1,20 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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 LIBSCP_LOCK_H
|
||||
#define LIBSCP_LOCK_H
|
||||
@@ -72,4 +71,3 @@ void DEFAULT_CC
|
||||
scp_lock_fork_critical_section_end(int blocking);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,21 +1,20 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -34,23 +33,25 @@
|
||||
//extern struct log_config* s_log;
|
||||
|
||||
/*******************************************************************/
|
||||
struct SCP_SESSION*
|
||||
struct SCP_SESSION *
|
||||
scp_session_create()
|
||||
{
|
||||
struct SCP_SESSION* s;
|
||||
struct SCP_SESSION *s;
|
||||
|
||||
s = (struct SCP_SESSION *)g_malloc(sizeof(struct SCP_SESSION), 1);
|
||||
|
||||
s = (struct SCP_SESSION*)g_malloc(sizeof(struct SCP_SESSION), 1);
|
||||
if (0 == s)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[session:%d] session create: malloc error", __LINE__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
/*******************************************************************/
|
||||
int
|
||||
scp_session_set_type(struct SCP_SESSION* s, tui8 type)
|
||||
scp_session_set_type(struct SCP_SESSION *s, tui8 type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
@@ -65,23 +66,26 @@ scp_session_set_type(struct SCP_SESSION* s, tui8 type)
|
||||
break;
|
||||
case SCP_SESSION_TYPE_MANAGE:
|
||||
s->type = SCP_SESSION_TYPE_MANAGE;
|
||||
s->mng = (struct SCP_MNG_DATA*)g_malloc(sizeof(struct SCP_MNG_DATA), 1);
|
||||
s->mng = (struct SCP_MNG_DATA *)g_malloc(sizeof(struct SCP_MNG_DATA), 1);
|
||||
|
||||
if (NULL == s->mng)
|
||||
{
|
||||
log_message(LOG_LEVEL_ERROR, "[session:%d] set_type: internal error", __LINE__);
|
||||
return 1;
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
log_message(LOG_LEVEL_WARNING, "[session:%d] set_type: unknown type", __LINE__);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*******************************************************************/
|
||||
int
|
||||
scp_session_set_version(struct SCP_SESSION* s, tui32 version)
|
||||
scp_session_set_version(struct SCP_SESSION *s, tui32 version)
|
||||
{
|
||||
switch (version)
|
||||
{
|
||||
@@ -95,12 +99,13 @@ scp_session_set_version(struct SCP_SESSION* s, tui32 version)
|
||||
log_message(LOG_LEVEL_WARNING, "[session:%d] set_version: unknown version", __LINE__);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*******************************************************************/
|
||||
int
|
||||
scp_session_set_height(struct SCP_SESSION* s, tui16 h)
|
||||
scp_session_set_height(struct SCP_SESSION *s, tui16 h)
|
||||
{
|
||||
s->height = h;
|
||||
return 0;
|
||||
@@ -108,7 +113,7 @@ scp_session_set_height(struct SCP_SESSION* s, tui16 h)
|
||||
|
||||
/*******************************************************************/
|
||||
int
|
||||
scp_session_set_width(struct SCP_SESSION* s, tui16 w)
|
||||
scp_session_set_width(struct SCP_SESSION *s, tui16 w)
|
||||
{
|
||||
s->width = w;
|
||||
return 0;
|
||||
@@ -116,7 +121,7 @@ scp_session_set_width(struct SCP_SESSION* s, tui16 w)
|
||||
|
||||
/*******************************************************************/
|
||||
int
|
||||
scp_session_set_bpp(struct SCP_SESSION* s, tui8 bpp)
|
||||
scp_session_set_bpp(struct SCP_SESSION *s, tui8 bpp)
|
||||
{
|
||||
switch (bpp)
|
||||
{
|
||||
@@ -128,12 +133,13 @@ scp_session_set_bpp(struct SCP_SESSION* s, tui8 bpp)
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*******************************************************************/
|
||||
int
|
||||
scp_session_set_rsr(struct SCP_SESSION* s, tui8 rsr)
|
||||
scp_session_set_rsr(struct SCP_SESSION *s, tui8 rsr)
|
||||
{
|
||||
if (s->rsr)
|
||||
{
|
||||
@@ -143,203 +149,237 @@ scp_session_set_rsr(struct SCP_SESSION* s, tui8 rsr)
|
||||
{
|
||||
s->rsr = 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*******************************************************************/
|
||||
int
|
||||
scp_session_set_locale(struct SCP_SESSION* s, char* str)
|
||||
scp_session_set_locale(struct SCP_SESSION *s, char *str)
|
||||
{
|
||||
if (0 == str)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[session:%d] set_locale: null locale", __LINE__);
|
||||
s->locale[0]='\0';
|
||||
s->locale[0] = '\0';
|
||||
return 1;
|
||||
}
|
||||
|
||||
g_strncpy(s->locale, str, 17);
|
||||
s->locale[17]='\0';
|
||||
s->locale[17] = '\0';
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*******************************************************************/
|
||||
int
|
||||
scp_session_set_username(struct SCP_SESSION* s, char* str)
|
||||
scp_session_set_username(struct SCP_SESSION *s, char *str)
|
||||
{
|
||||
if (0 == str)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[session:%d] set_username: null username", __LINE__);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (0 != s->username)
|
||||
{
|
||||
g_free(s->username);
|
||||
}
|
||||
|
||||
s->username = g_strdup(str);
|
||||
|
||||
if (0 == s->username)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[session:%d] set_username: strdup error", __LINE__);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*******************************************************************/
|
||||
int
|
||||
scp_session_set_password(struct SCP_SESSION* s, char* str)
|
||||
scp_session_set_password(struct SCP_SESSION *s, char *str)
|
||||
{
|
||||
if (0 == str)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[session:%d] set_password: null password", __LINE__);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (0 != s->password)
|
||||
{
|
||||
g_free(s->password);
|
||||
}
|
||||
|
||||
s->password = g_strdup(str);
|
||||
|
||||
if (0 == s->password)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[session:%d] set_password: strdup error", __LINE__);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*******************************************************************/
|
||||
int
|
||||
scp_session_set_domain(struct SCP_SESSION* s, char* str)
|
||||
scp_session_set_domain(struct SCP_SESSION *s, char *str)
|
||||
{
|
||||
if (0 == str)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[session:%d] set_domain: null domain", __LINE__);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (0 != s->domain)
|
||||
{
|
||||
g_free(s->domain);
|
||||
}
|
||||
|
||||
s->domain = g_strdup(str);
|
||||
|
||||
if (0 == s->domain)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[session:%d] set_domain: strdup error", __LINE__);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*******************************************************************/
|
||||
int
|
||||
scp_session_set_program(struct SCP_SESSION* s, char* str)
|
||||
scp_session_set_program(struct SCP_SESSION *s, char *str)
|
||||
{
|
||||
if (0 == str)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[session:%d] set_program: null program", __LINE__);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (0 != s->program)
|
||||
{
|
||||
g_free(s->program);
|
||||
}
|
||||
|
||||
s->program = g_strdup(str);
|
||||
|
||||
if (0 == s->program)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[session:%d] set_program: strdup error", __LINE__);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*******************************************************************/
|
||||
int
|
||||
scp_session_set_directory(struct SCP_SESSION* s, char* str)
|
||||
scp_session_set_directory(struct SCP_SESSION *s, char *str)
|
||||
{
|
||||
if (0 == str)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[session:%d] set_directory: null directory", __LINE__);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (0 != s->directory)
|
||||
{
|
||||
g_free(s->directory);
|
||||
}
|
||||
|
||||
s->directory = g_strdup(str);
|
||||
|
||||
if (0 == s->directory)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[session:%d] set_directory: strdup error", __LINE__);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*******************************************************************/
|
||||
int
|
||||
scp_session_set_client_ip(struct SCP_SESSION* s, char* str)
|
||||
scp_session_set_client_ip(struct SCP_SESSION *s, char *str)
|
||||
{
|
||||
if (0 == str)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[session:%d] set_client_ip: null ip", __LINE__);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (0 != s->client_ip)
|
||||
{
|
||||
g_free(s->client_ip);
|
||||
}
|
||||
|
||||
s->client_ip = g_strdup(str);
|
||||
|
||||
if (0 == s->client_ip)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[session:%d] set_client_ip: strdup error", __LINE__);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*******************************************************************/
|
||||
int
|
||||
scp_session_set_hostname(struct SCP_SESSION* s, char* str)
|
||||
scp_session_set_hostname(struct SCP_SESSION *s, char *str)
|
||||
{
|
||||
if (0 == str)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[session:%d] set_hostname: null hostname", __LINE__);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (0 != s->hostname)
|
||||
{
|
||||
g_free(s->hostname);
|
||||
}
|
||||
|
||||
s->hostname = g_strdup(str);
|
||||
|
||||
if (0 == s->hostname)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[session:%d] set_hostname: strdup error", __LINE__);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*******************************************************************/
|
||||
int
|
||||
scp_session_set_errstr(struct SCP_SESSION* s, char* str)
|
||||
scp_session_set_errstr(struct SCP_SESSION *s, char *str)
|
||||
{
|
||||
if (0 == str)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[session:%d] set_errstr: null string", __LINE__);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (0 != s->errstr)
|
||||
{
|
||||
g_free(s->errstr);
|
||||
}
|
||||
|
||||
s->errstr = g_strdup(str);
|
||||
|
||||
if (0 == s->errstr)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[session:%d] set_errstr: strdup error", __LINE__);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*******************************************************************/
|
||||
int
|
||||
scp_session_set_display(struct SCP_SESSION* s, SCP_DISPLAY display)
|
||||
scp_session_set_display(struct SCP_SESSION *s, SCP_DISPLAY display)
|
||||
{
|
||||
s->display = display;
|
||||
return 0;
|
||||
@@ -347,7 +387,7 @@ scp_session_set_display(struct SCP_SESSION* s, SCP_DISPLAY display)
|
||||
|
||||
/*******************************************************************/
|
||||
int
|
||||
scp_session_set_addr(struct SCP_SESSION* s, int type, void* addr)
|
||||
scp_session_set_addr(struct SCP_SESSION *s, int type, void *addr)
|
||||
{
|
||||
struct in_addr ip4;
|
||||
#ifdef IN6ADDR_ANY_INIT
|
||||
@@ -360,6 +400,7 @@ scp_session_set_addr(struct SCP_SESSION* s, int type, void* addr)
|
||||
case SCP_ADDRESS_TYPE_IPV4:
|
||||
/* convert from char to 32bit*/
|
||||
ret = inet_pton(AF_INET, addr, &ip4);
|
||||
|
||||
if (ret == 0)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[session:%d] set_addr: invalid address", __LINE__);
|
||||
@@ -367,6 +408,7 @@ scp_session_set_addr(struct SCP_SESSION* s, int type, void* addr)
|
||||
g_memcpy(&(s->ipv4addr), &(ip4.s_addr), 4);
|
||||
return 1;
|
||||
}
|
||||
|
||||
g_memcpy(&(s->ipv4addr), &(ip4.s_addr), 4);
|
||||
break;
|
||||
case SCP_ADDRESS_TYPE_IPV4_BIN:
|
||||
@@ -376,6 +418,7 @@ scp_session_set_addr(struct SCP_SESSION* s, int type, void* addr)
|
||||
case SCP_ADDRESS_TYPE_IPV6:
|
||||
/* convert from char to 128bit*/
|
||||
ret = inet_pton(AF_INET6, addr, &ip6);
|
||||
|
||||
if (ret == 0)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[session:%d] set_addr: invalid address", __LINE__);
|
||||
@@ -383,6 +426,7 @@ scp_session_set_addr(struct SCP_SESSION* s, int type, void* addr)
|
||||
g_memcpy(s->ipv6addr, &(ip6.s6_addr), 16);
|
||||
return 1;
|
||||
}
|
||||
|
||||
g_memcpy(s->ipv6addr, &(ip6.s6_addr), 16);
|
||||
break;
|
||||
case SCP_ADDRESS_TYPE_IPV6_BIN:
|
||||
@@ -392,12 +436,13 @@ scp_session_set_addr(struct SCP_SESSION* s, int type, void* addr)
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*******************************************************************/
|
||||
void
|
||||
scp_session_destroy(struct SCP_SESSION* s)
|
||||
scp_session_destroy(struct SCP_SESSION *s)
|
||||
{
|
||||
g_free(s->username);
|
||||
g_free(s->password);
|
||||
|
||||
@@ -1,21 +1,20 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
+24
-24
@@ -1,21 +1,20 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -33,11 +32,11 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
extern struct log_config* s_log;
|
||||
extern struct log_config *s_log;
|
||||
|
||||
/*****************************************************************************/
|
||||
int DEFAULT_CC
|
||||
scp_tcp_force_recv(int sck, char* data, int len)
|
||||
scp_tcp_force_recv(int sck, char *data, int len)
|
||||
{
|
||||
int rcvd;
|
||||
int block;
|
||||
@@ -48,6 +47,7 @@ scp_tcp_force_recv(int sck, char* data, int len)
|
||||
while (len > 0)
|
||||
{
|
||||
rcvd = g_tcp_recv(sck, data, len, 0);
|
||||
|
||||
if (rcvd == -1)
|
||||
{
|
||||
if (g_tcp_last_error_would_block(sck))
|
||||
@@ -79,7 +79,7 @@ scp_tcp_force_recv(int sck, char* data, int len)
|
||||
|
||||
/*****************************************************************************/
|
||||
int DEFAULT_CC
|
||||
scp_tcp_force_send(int sck, char* data, int len)
|
||||
scp_tcp_force_send(int sck, char *data, int len)
|
||||
{
|
||||
int sent;
|
||||
int block;
|
||||
@@ -90,6 +90,7 @@ scp_tcp_force_send(int sck, char* data, int len)
|
||||
while (len > 0)
|
||||
{
|
||||
sent = g_tcp_send(sck, data, len, 0);
|
||||
|
||||
if (sent == -1)
|
||||
{
|
||||
if (g_tcp_last_error_would_block(sck))
|
||||
@@ -121,7 +122,7 @@ scp_tcp_force_send(int sck, char* data, int len)
|
||||
|
||||
/*****************************************************************************/
|
||||
int DEFAULT_CC
|
||||
scp_tcp_bind(int sck, char* addr, char* port)
|
||||
scp_tcp_bind(int sck, char *addr, char *port)
|
||||
{
|
||||
struct sockaddr_in s;
|
||||
|
||||
@@ -129,6 +130,5 @@ scp_tcp_bind(int sck, char* addr, char* port)
|
||||
s.sin_family = AF_INET;
|
||||
s.sin_port = htons(atoi(port));
|
||||
s.sin_addr.s_addr = inet_addr(addr);
|
||||
return bind(sck, (struct sockaddr*)&s, sizeof(struct sockaddr_in));
|
||||
return bind(sck, (struct sockaddr *)&s, sizeof(struct sockaddr_in));
|
||||
}
|
||||
|
||||
|
||||
+17
-18
@@ -1,21 +1,20 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@@ -1,21 +1,20 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@@ -1,21 +1,20 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
+57
-33
@@ -1,21 +1,20 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -29,12 +28,12 @@
|
||||
|
||||
#include "os_calls.h"
|
||||
|
||||
extern struct log_config* s_log;
|
||||
extern struct log_config *s_log;
|
||||
|
||||
/* client API */
|
||||
/******************************************************************************/
|
||||
enum SCP_CLIENT_STATES_E
|
||||
scp_v0c_connect(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
scp_v0c_connect(struct SCP_CONNECTION *c, struct SCP_SESSION *s)
|
||||
{
|
||||
tui32 version;
|
||||
tui32 size;
|
||||
@@ -62,12 +61,13 @@ scp_v0c_connect(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__);
|
||||
return SCP_CLIENT_STATE_INTERNAL_ERR;
|
||||
}
|
||||
|
||||
sz = g_strlen(s->username);
|
||||
out_uint16_be(c->out_s, sz);
|
||||
out_uint8a(c->out_s, s->username, sz);
|
||||
|
||||
sz = g_strlen(s->password);
|
||||
out_uint16_be(c->out_s,sz);
|
||||
out_uint16_be(c->out_s, sz);
|
||||
out_uint8a(c->out_s, s->password, sz);
|
||||
out_uint16_be(c->out_s, s->width);
|
||||
out_uint16_be(c->out_s, s->height);
|
||||
@@ -81,19 +81,20 @@ scp_v0c_connect(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
/* size */
|
||||
out_uint32_be(c->out_s, c->out_s->end - c->out_s->data);
|
||||
|
||||
if (0!=scp_tcp_force_send(c->in_sck, c->out_s->data, c->out_s->end - c->out_s->data))
|
||||
if (0 != scp_tcp_force_send(c->in_sck, c->out_s->data, c->out_s->end - c->out_s->data))
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__);
|
||||
return SCP_CLIENT_STATE_NETWORK_ERR;
|
||||
}
|
||||
|
||||
if (0!=scp_tcp_force_recv(c->in_sck, c->in_s->data, 8))
|
||||
if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, 8))
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__);
|
||||
return SCP_CLIENT_STATE_NETWORK_ERR;
|
||||
}
|
||||
|
||||
in_uint32_be(c->in_s, version);
|
||||
|
||||
if (0 != version)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: version error", __LINE__);
|
||||
@@ -101,6 +102,7 @@ scp_v0c_connect(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
}
|
||||
|
||||
in_uint32_be(c->in_s, size);
|
||||
|
||||
if (size < 14)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: packet size error", __LINE__);
|
||||
@@ -109,7 +111,8 @@ scp_v0c_connect(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
|
||||
/* getting payload */
|
||||
init_stream(c->in_s, c->in_s->size);
|
||||
if (0!=scp_tcp_force_recv(c->in_sck, c->in_s->data, size - 8))
|
||||
|
||||
if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, size - 8))
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__);
|
||||
return SCP_CLIENT_STATE_NETWORK_ERR;
|
||||
@@ -117,6 +120,7 @@ scp_v0c_connect(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
|
||||
/* check code */
|
||||
in_uint16_be(c->in_s, sz);
|
||||
|
||||
if (3 != sz)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: sequence error", __LINE__);
|
||||
@@ -125,6 +129,7 @@ scp_v0c_connect(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
|
||||
/* message payload */
|
||||
in_uint16_be(c->in_s, sz);
|
||||
|
||||
if (1 != sz)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: connection denied", __LINE__);
|
||||
@@ -141,11 +146,11 @@ scp_v0c_connect(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
/* server API */
|
||||
/******************************************************************************/
|
||||
enum SCP_SERVER_STATES_E
|
||||
scp_v0s_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s, int skipVchk)
|
||||
scp_v0s_accept(struct SCP_CONNECTION *c, struct SCP_SESSION **s, int skipVchk)
|
||||
{
|
||||
tui32 version = 0;
|
||||
tui32 size;
|
||||
struct SCP_SESSION* session = 0;
|
||||
struct SCP_SESSION *session = 0;
|
||||
tui16 sz;
|
||||
tui32 code = 0;
|
||||
char buf[257];
|
||||
@@ -153,10 +158,12 @@ scp_v0s_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s, int skipVchk)
|
||||
if (!skipVchk)
|
||||
{
|
||||
LOG_DBG("[v0:%d] starting connection", __LINE__);
|
||||
|
||||
if (0 == scp_tcp_force_recv(c->in_sck, c->in_s->data, 8))
|
||||
{
|
||||
c->in_s->end = c->in_s->data + 8;
|
||||
in_uint32_be(c->in_s, version);
|
||||
|
||||
if (version != 0)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: version error", __LINE__);
|
||||
@@ -173,11 +180,13 @@ scp_v0s_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s, int skipVchk)
|
||||
in_uint32_be(c->in_s, size);
|
||||
|
||||
init_stream(c->in_s, 8196);
|
||||
|
||||
if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, size - 8))
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__);
|
||||
return SCP_SERVER_STATE_NETWORK_ERR;
|
||||
}
|
||||
|
||||
c->in_s->end = c->in_s->data + (size - 8);
|
||||
|
||||
in_uint16_be(c->in_s, code);
|
||||
@@ -185,6 +194,7 @@ scp_v0s_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s, int skipVchk)
|
||||
if (code == 0 || code == 10)
|
||||
{
|
||||
session = scp_session_create();
|
||||
|
||||
if (0 == session)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__);
|
||||
@@ -192,6 +202,7 @@ scp_v0s_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s, int skipVchk)
|
||||
}
|
||||
|
||||
scp_session_set_version(session, version);
|
||||
|
||||
if (code == 0)
|
||||
{
|
||||
scp_session_set_type(session, SCP_SESSION_TYPE_XVNC);
|
||||
@@ -203,8 +214,9 @@ scp_v0s_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s, int skipVchk)
|
||||
|
||||
/* reading username */
|
||||
in_uint16_be(c->in_s, sz);
|
||||
buf[sz]='\0';
|
||||
buf[sz] = '\0';
|
||||
in_uint8a(c->in_s, buf, sz);
|
||||
|
||||
if (0 != scp_session_set_username(session, buf))
|
||||
{
|
||||
scp_session_destroy(session);
|
||||
@@ -214,8 +226,9 @@ scp_v0s_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s, int skipVchk)
|
||||
|
||||
/* reading password */
|
||||
in_uint16_be(c->in_s, sz);
|
||||
buf[sz]='\0';
|
||||
buf[sz] = '\0';
|
||||
in_uint8a(c->in_s, buf, sz);
|
||||
|
||||
if (0 != scp_session_set_password(session, buf))
|
||||
{
|
||||
scp_session_destroy(session);
|
||||
@@ -232,10 +245,12 @@ scp_v0s_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s, int skipVchk)
|
||||
/* bpp */
|
||||
in_uint16_be(c->in_s, sz);
|
||||
scp_session_set_bpp(session, (tui8)sz);
|
||||
|
||||
if (s_check_rem(c->in_s, 2))
|
||||
{
|
||||
/* reading domain */
|
||||
in_uint16_be(c->in_s, sz);
|
||||
|
||||
if (sz > 0)
|
||||
{
|
||||
in_uint8a(c->in_s, buf, sz);
|
||||
@@ -243,10 +258,12 @@ scp_v0s_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s, int skipVchk)
|
||||
scp_session_set_domain(session, buf);
|
||||
}
|
||||
}
|
||||
|
||||
if (s_check_rem(c->in_s, 2))
|
||||
{
|
||||
/* reading program */
|
||||
in_uint16_be(c->in_s, sz);
|
||||
|
||||
if (sz > 0)
|
||||
{
|
||||
in_uint8a(c->in_s, buf, sz);
|
||||
@@ -254,10 +271,12 @@ scp_v0s_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s, int skipVchk)
|
||||
scp_session_set_program(session, buf);
|
||||
}
|
||||
}
|
||||
|
||||
if (s_check_rem(c->in_s, 2))
|
||||
{
|
||||
/* reading directory */
|
||||
in_uint16_be(c->in_s, sz);
|
||||
|
||||
if (sz > 0)
|
||||
{
|
||||
in_uint8a(c->in_s, buf, sz);
|
||||
@@ -265,10 +284,12 @@ scp_v0s_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s, int skipVchk)
|
||||
scp_session_set_directory(session, buf);
|
||||
}
|
||||
}
|
||||
|
||||
if (s_check_rem(c->in_s, 2))
|
||||
{
|
||||
/* reading client IP address */
|
||||
in_uint16_be(c->in_s, sz);
|
||||
|
||||
if (sz > 0)
|
||||
{
|
||||
in_uint8a(c->in_s, buf, sz);
|
||||
@@ -281,6 +302,7 @@ scp_v0s_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s, int skipVchk)
|
||||
{
|
||||
/* g_writeln("Command is SCP_GW_AUTHENTICATION"); */
|
||||
session = scp_session_create();
|
||||
|
||||
if (0 == session)
|
||||
{
|
||||
/* until syslog merge log_message(s_log, LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__);*/
|
||||
@@ -291,8 +313,9 @@ scp_v0s_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s, int skipVchk)
|
||||
scp_session_set_type(session, SCP_GW_AUTHENTICATION);
|
||||
/* reading username */
|
||||
in_uint16_be(c->in_s, sz);
|
||||
buf[sz]='\0';
|
||||
buf[sz] = '\0';
|
||||
in_uint8a(c->in_s, buf, sz);
|
||||
|
||||
/* g_writeln("Received user name: %s",buf); */
|
||||
if (0 != scp_session_set_username(session, buf))
|
||||
{
|
||||
@@ -305,6 +328,7 @@ scp_v0s_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s, int skipVchk)
|
||||
in_uint16_be(c->in_s, sz);
|
||||
buf[sz] = '\0';
|
||||
in_uint8a(c->in_s, buf, sz);
|
||||
|
||||
/* g_writeln("Received password: %s",buf); */
|
||||
if (0 != scp_session_set_password(session, buf))
|
||||
{
|
||||
@@ -319,13 +343,13 @@ scp_v0s_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s, int skipVchk)
|
||||
return SCP_SERVER_STATE_SEQUENCE_ERR;
|
||||
}
|
||||
|
||||
(*s)=session;
|
||||
(*s) = session;
|
||||
return SCP_SERVER_STATE_OK;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
enum SCP_SERVER_STATES_E
|
||||
scp_v0s_allow_connection(struct SCP_CONNECTION* c, SCP_DISPLAY d)
|
||||
scp_v0s_allow_connection(struct SCP_CONNECTION *c, SCP_DISPLAY d)
|
||||
{
|
||||
out_uint32_be(c->out_s, 0); /* version */
|
||||
out_uint32_be(c->out_s, 14); /* size */
|
||||
@@ -346,7 +370,7 @@ scp_v0s_allow_connection(struct SCP_CONNECTION* c, SCP_DISPLAY d)
|
||||
|
||||
/******************************************************************************/
|
||||
enum SCP_SERVER_STATES_E
|
||||
scp_v0s_deny_connection(struct SCP_CONNECTION* c)
|
||||
scp_v0s_deny_connection(struct SCP_CONNECTION *c)
|
||||
{
|
||||
out_uint32_be(c->out_s, 0); /* version */
|
||||
out_uint32_be(c->out_s, 14); /* size */
|
||||
@@ -367,7 +391,7 @@ scp_v0s_deny_connection(struct SCP_CONNECTION* c)
|
||||
|
||||
/******************************************************************************/
|
||||
enum SCP_SERVER_STATES_E
|
||||
scp_v0s_replyauthentication(struct SCP_CONNECTION* c, unsigned short int value)
|
||||
scp_v0s_replyauthentication(struct SCP_CONNECTION *c, unsigned short int value)
|
||||
{
|
||||
out_uint32_be(c->out_s, 0); /* version */
|
||||
out_uint32_be(c->out_s, 14); /* size */
|
||||
|
||||
+17
-19
@@ -1,21 +1,20 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -83,4 +82,3 @@ enum SCP_SERVER_STATES_E
|
||||
scp_v0s_replyauthentication(struct SCP_CONNECTION* c, unsigned short int value);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
+62
-29
@@ -1,21 +1,20 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -31,12 +30,12 @@
|
||||
#include <stdio.h>
|
||||
|
||||
static enum SCP_CLIENT_STATES_E
|
||||
_scp_v1c_check_response(struct SCP_CONNECTION* c, struct SCP_SESSION* s);
|
||||
_scp_v1c_check_response(struct SCP_CONNECTION *c, struct SCP_SESSION *s);
|
||||
|
||||
/* client API */
|
||||
/* 001 */
|
||||
enum SCP_CLIENT_STATES_E
|
||||
scp_v1c_connect(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
scp_v1c_connect(struct SCP_CONNECTION *c, struct SCP_SESSION *s)
|
||||
{
|
||||
tui8 sz;
|
||||
tui32 size;
|
||||
@@ -46,6 +45,7 @@ scp_v1c_connect(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
|
||||
size = 19 + 17 + 4 + g_strlen(s->hostname) + g_strlen(s->username) +
|
||||
g_strlen(s->password);
|
||||
|
||||
if (s->addr_type == SCP_ADDRESS_TYPE_IPV4)
|
||||
{
|
||||
size = size + 4;
|
||||
@@ -102,7 +102,7 @@ scp_v1c_connect(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
|
||||
/* 004 */
|
||||
enum SCP_CLIENT_STATES_E
|
||||
scp_v1c_resend_credentials(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
scp_v1c_resend_credentials(struct SCP_CONNECTION *c, struct SCP_SESSION *s)
|
||||
{
|
||||
tui8 sz;
|
||||
tui32 size;
|
||||
@@ -138,15 +138,15 @@ scp_v1c_resend_credentials(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
|
||||
/* 021 */
|
||||
enum SCP_CLIENT_STATES_E
|
||||
scp_v1c_pwd_change(struct SCP_CONNECTION* c, char* newpass);
|
||||
scp_v1c_pwd_change(struct SCP_CONNECTION *c, char *newpass);
|
||||
/* 022 */
|
||||
enum SCP_CLIENT_STATES_E
|
||||
scp_v1c_pwd_change_cancel(struct SCP_CONNECTION* c);
|
||||
scp_v1c_pwd_change_cancel(struct SCP_CONNECTION *c);
|
||||
|
||||
/* 041 */
|
||||
enum SCP_CLIENT_STATES_E
|
||||
scp_v1c_get_session_list(struct SCP_CONNECTION* c, int* scount,
|
||||
struct SCP_DISCONNECTED_SESSION** s)
|
||||
scp_v1c_get_session_list(struct SCP_CONNECTION *c, int *scount,
|
||||
struct SCP_DISCONNECTED_SESSION **s)
|
||||
{
|
||||
tui32 version = 1;
|
||||
tui32 size = 12;
|
||||
@@ -158,7 +158,7 @@ scp_v1c_get_session_list(struct SCP_CONNECTION* c, int* scount,
|
||||
tui8 continued = 0; /* continue flag */
|
||||
int firstpkt = 1; /* "first packet" flag */
|
||||
int idx;
|
||||
struct SCP_DISCONNECTED_SESSION* ds = 0;
|
||||
struct SCP_DISCONNECTED_SESSION *ds = 0;
|
||||
|
||||
init_stream(c->out_s, c->out_s->size);
|
||||
|
||||
@@ -177,36 +177,42 @@ scp_v1c_get_session_list(struct SCP_CONNECTION* c, int* scount,
|
||||
{
|
||||
/* then we wait for server response */
|
||||
init_stream(c->in_s, c->in_s->size);
|
||||
|
||||
if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, 8))
|
||||
{
|
||||
return SCP_CLIENT_STATE_NETWORK_ERR;
|
||||
}
|
||||
|
||||
in_uint32_be(c->in_s, version);
|
||||
|
||||
if (version != 1)
|
||||
{
|
||||
return SCP_CLIENT_STATE_VERSION_ERR;
|
||||
}
|
||||
|
||||
in_uint32_be(c->in_s, size);
|
||||
|
||||
if (size < 12)
|
||||
{
|
||||
return SCP_CLIENT_STATE_SIZE_ERR;
|
||||
}
|
||||
|
||||
init_stream(c->in_s, c->in_s->size);
|
||||
|
||||
if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, size - 8))
|
||||
{
|
||||
return SCP_CLIENT_STATE_NETWORK_ERR;
|
||||
}
|
||||
|
||||
in_uint16_be(c->in_s, cmd);
|
||||
|
||||
if (cmd != SCP_COMMAND_SET_DEFAULT)
|
||||
{
|
||||
return SCP_CLIENT_STATE_SEQUENCE_ERR;
|
||||
}
|
||||
|
||||
in_uint16_be(c->in_s, cmd);
|
||||
|
||||
if (cmd != 42)
|
||||
{
|
||||
return SCP_CLIENT_STATE_SEQUENCE_ERR;
|
||||
@@ -219,6 +225,7 @@ scp_v1c_get_session_list(struct SCP_CONNECTION* c, int* scount,
|
||||
sestmp = sescnt;
|
||||
|
||||
ds = g_malloc(sizeof(struct SCP_DISCONNECTED_SESSION) * sescnt, 0);
|
||||
|
||||
if (ds == 0)
|
||||
{
|
||||
return SCP_CLIENT_STATE_INTERNAL_ERR;
|
||||
@@ -228,6 +235,7 @@ scp_v1c_get_session_list(struct SCP_CONNECTION* c, int* scount,
|
||||
{
|
||||
in_uint32_be(c->in_s, sestmp);
|
||||
}
|
||||
|
||||
in_uint8(c->in_s, continued);
|
||||
in_uint8(c->in_s, pktcnt);
|
||||
|
||||
@@ -248,6 +256,7 @@ scp_v1c_get_session_list(struct SCP_CONNECTION* c, int* scount,
|
||||
in_uint8(c->in_s, (ds[totalcnt]).conn_hour);
|
||||
in_uint8(c->in_s, (ds[totalcnt]).conn_minute);
|
||||
in_uint8(c->in_s, (ds[totalcnt]).addr_type);
|
||||
|
||||
if ((ds[totalcnt]).addr_type == SCP_ADDRESS_TYPE_IPV4)
|
||||
{
|
||||
in_uint32_be(c->in_s, (ds[totalcnt]).ipv4addr);
|
||||
@@ -256,6 +265,7 @@ scp_v1c_get_session_list(struct SCP_CONNECTION* c, int* scount,
|
||||
{
|
||||
in_uint8a(c->in_s, (ds[totalcnt]).ipv6addr, 16);
|
||||
}
|
||||
|
||||
totalcnt++;
|
||||
}
|
||||
}
|
||||
@@ -271,7 +281,7 @@ scp_v1c_get_session_list(struct SCP_CONNECTION* c, int* scount,
|
||||
|
||||
/* 043 */
|
||||
enum SCP_CLIENT_STATES_E
|
||||
scp_v1c_select_session(struct SCP_CONNECTION* c, struct SCP_SESSION* s,
|
||||
scp_v1c_select_session(struct SCP_CONNECTION *c, struct SCP_SESSION *s,
|
||||
SCP_SID sid)
|
||||
{
|
||||
tui32 version = 1;
|
||||
@@ -295,24 +305,28 @@ scp_v1c_select_session(struct SCP_CONNECTION* c, struct SCP_SESSION* s,
|
||||
|
||||
/* waiting for response.... */
|
||||
init_stream(c->in_s, c->in_s->size);
|
||||
|
||||
if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, 8))
|
||||
{
|
||||
return SCP_CLIENT_STATE_NETWORK_ERR;
|
||||
}
|
||||
|
||||
in_uint32_be(c->in_s, version);
|
||||
|
||||
if (version != 1)
|
||||
{
|
||||
return SCP_CLIENT_STATE_VERSION_ERR;
|
||||
}
|
||||
|
||||
in_uint32_be(c->in_s, size);
|
||||
|
||||
if (size < 12)
|
||||
{
|
||||
return SCP_CLIENT_STATE_SIZE_ERR;
|
||||
}
|
||||
|
||||
init_stream(c->in_s, c->in_s->size);
|
||||
|
||||
/* read the rest of the packet */
|
||||
if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, size - 8))
|
||||
{
|
||||
@@ -320,12 +334,14 @@ scp_v1c_select_session(struct SCP_CONNECTION* c, struct SCP_SESSION* s,
|
||||
}
|
||||
|
||||
in_uint16_be(c->in_s, cmd);
|
||||
|
||||
if (cmd != SCP_COMMAND_SET_DEFAULT)
|
||||
{
|
||||
return SCP_CLIENT_STATE_SEQUENCE_ERR;
|
||||
}
|
||||
|
||||
in_uint16_be(c->in_s, cmd);
|
||||
|
||||
if (cmd != 46)
|
||||
{
|
||||
return SCP_CLIENT_STATE_SEQUENCE_ERR;
|
||||
@@ -341,7 +357,7 @@ scp_v1c_select_session(struct SCP_CONNECTION* c, struct SCP_SESSION* s,
|
||||
|
||||
/* 044 */
|
||||
enum SCP_CLIENT_STATES_E
|
||||
scp_v1c_select_session_cancel(struct SCP_CONNECTION* c)
|
||||
scp_v1c_select_session_cancel(struct SCP_CONNECTION *c)
|
||||
{
|
||||
tui32 version = 1;
|
||||
tui32 size = 12;
|
||||
@@ -364,7 +380,7 @@ scp_v1c_select_session_cancel(struct SCP_CONNECTION* c)
|
||||
}
|
||||
|
||||
static enum SCP_CLIENT_STATES_E
|
||||
_scp_v1c_check_response(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
_scp_v1c_check_response(struct SCP_CONNECTION *c, struct SCP_SESSION *s)
|
||||
{
|
||||
tui32 version;
|
||||
tui32 size;
|
||||
@@ -372,12 +388,14 @@ _scp_v1c_check_response(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
tui16 dim;
|
||||
|
||||
init_stream(c->in_s, c->in_s->size);
|
||||
|
||||
if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, 8))
|
||||
{
|
||||
return SCP_CLIENT_STATE_NETWORK_ERR;
|
||||
}
|
||||
|
||||
in_uint32_be(c->in_s, version);
|
||||
|
||||
if (version != 1)
|
||||
{
|
||||
return SCP_CLIENT_STATE_VERSION_ERR;
|
||||
@@ -386,6 +404,7 @@ _scp_v1c_check_response(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
in_uint32_be(c->in_s, size);
|
||||
|
||||
init_stream(c->in_s, c->in_s->size);
|
||||
|
||||
/* read the rest of the packet */
|
||||
if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, size - 8))
|
||||
{
|
||||
@@ -393,24 +412,30 @@ _scp_v1c_check_response(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
}
|
||||
|
||||
in_uint16_be(c->in_s, cmd);
|
||||
|
||||
if (cmd != SCP_COMMAND_SET_DEFAULT)
|
||||
{
|
||||
return SCP_CLIENT_STATE_SEQUENCE_ERR;
|
||||
}
|
||||
|
||||
in_uint16_be(c->in_s, cmd);
|
||||
|
||||
if (cmd == 2) /* connection denied */
|
||||
{
|
||||
in_uint16_be(c->in_s, dim);
|
||||
|
||||
if (s->errstr != 0)
|
||||
{
|
||||
g_free(s->errstr);
|
||||
}
|
||||
|
||||
s->errstr = g_malloc(dim + 1, 0);
|
||||
|
||||
if (s->errstr == 0)
|
||||
{
|
||||
return SCP_CLIENT_STATE_INTERNAL_ERR;
|
||||
}
|
||||
|
||||
in_uint8a(c->in_s, s->errstr, dim);
|
||||
(s->errstr)[dim] = '\0';
|
||||
|
||||
@@ -419,15 +444,19 @@ _scp_v1c_check_response(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
else if (cmd == 3) /* resend usr/pwd */
|
||||
{
|
||||
in_uint16_be(c->in_s, dim);
|
||||
|
||||
if (s->errstr != 0)
|
||||
{
|
||||
g_free(s->errstr);
|
||||
}
|
||||
|
||||
s->errstr = g_malloc(dim + 1, 0);
|
||||
|
||||
if (s->errstr == 0)
|
||||
{
|
||||
return SCP_CLIENT_STATE_INTERNAL_ERR;
|
||||
}
|
||||
|
||||
in_uint8a(c->in_s, s->errstr, dim);
|
||||
(s->errstr)[dim] = '\0';
|
||||
|
||||
@@ -436,15 +465,19 @@ _scp_v1c_check_response(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
else if (cmd == 20) /* password change */
|
||||
{
|
||||
in_uint16_be(c->in_s, dim);
|
||||
|
||||
if (s->errstr != 0)
|
||||
{
|
||||
g_free(s->errstr);
|
||||
}
|
||||
|
||||
s->errstr = g_malloc(dim + 1, 0);
|
||||
|
||||
if (s->errstr == 0)
|
||||
{
|
||||
return SCP_CLIENT_STATE_INTERNAL_ERR;
|
||||
}
|
||||
|
||||
in_uint8a(c->in_s, s->errstr, dim);
|
||||
(s->errstr)[dim] = '\0';
|
||||
|
||||
|
||||
+17
-18
@@ -1,21 +1,20 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@@ -1,21 +1,20 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -33,12 +32,12 @@
|
||||
//extern struct log_config* s_log;
|
||||
|
||||
static enum SCP_CLIENT_STATES_E
|
||||
_scp_v1c_mng_check_response(struct SCP_CONNECTION* c, struct SCP_SESSION* s);
|
||||
_scp_v1c_mng_check_response(struct SCP_CONNECTION *c, struct SCP_SESSION *s);
|
||||
|
||||
/* client API */
|
||||
/* 001 */
|
||||
enum SCP_CLIENT_STATES_E
|
||||
scp_v1c_mng_connect(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
scp_v1c_mng_connect(struct SCP_CONNECTION *c, struct SCP_SESSION *s)
|
||||
{
|
||||
tui8 sz;
|
||||
tui32 size;
|
||||
@@ -48,6 +47,7 @@ scp_v1c_mng_connect(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
|
||||
size = 12 + 4 + g_strlen(s->hostname) + g_strlen(s->username) +
|
||||
g_strlen(s->password);
|
||||
|
||||
if (s->addr_type == SCP_ADDRESS_TYPE_IPV4)
|
||||
{
|
||||
size = size + 4;
|
||||
@@ -75,6 +75,7 @@ scp_v1c_mng_connect(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
|
||||
/* address */
|
||||
out_uint8(c->out_s, s->addr_type);
|
||||
|
||||
if (s->addr_type == SCP_ADDRESS_TYPE_IPV4)
|
||||
{
|
||||
out_uint32_be(c->out_s, s->ipv4addr);
|
||||
@@ -101,8 +102,8 @@ scp_v1c_mng_connect(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
|
||||
/* 004 */
|
||||
enum SCP_CLIENT_STATES_E
|
||||
scp_v1c_mng_get_session_list(struct SCP_CONNECTION* c, int* scount,
|
||||
struct SCP_DISCONNECTED_SESSION** s)
|
||||
scp_v1c_mng_get_session_list(struct SCP_CONNECTION *c, int *scount,
|
||||
struct SCP_DISCONNECTED_SESSION **s)
|
||||
{
|
||||
tui32 version = 1;
|
||||
tui32 size = 12;
|
||||
@@ -114,8 +115,8 @@ scp_v1c_mng_get_session_list(struct SCP_CONNECTION* c, int* scount,
|
||||
tui8 continued = 0; /* continue flag */
|
||||
int firstpkt = 1; /* "first packet" flag */
|
||||
int idx;
|
||||
struct SCP_DISCONNECTED_SESSION* ds = 0;
|
||||
// tui8 addr[16];
|
||||
struct SCP_DISCONNECTED_SESSION *ds = 0;
|
||||
// tui8 addr[16];
|
||||
|
||||
init_stream(c->out_s, c->out_s->size);
|
||||
|
||||
@@ -135,6 +136,7 @@ scp_v1c_mng_get_session_list(struct SCP_CONNECTION* c, int* scount,
|
||||
{
|
||||
/* then we wait for server response */
|
||||
init_stream(c->in_s, c->in_s->size);
|
||||
|
||||
if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, 8))
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: network error", __LINE__);
|
||||
@@ -142,6 +144,7 @@ scp_v1c_mng_get_session_list(struct SCP_CONNECTION* c, int* scount,
|
||||
}
|
||||
|
||||
in_uint32_be(c->in_s, version);
|
||||
|
||||
if (version != 1)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: version error", __LINE__);
|
||||
@@ -149,6 +152,7 @@ scp_v1c_mng_get_session_list(struct SCP_CONNECTION* c, int* scount,
|
||||
}
|
||||
|
||||
in_uint32_be(c->in_s, size);
|
||||
|
||||
if (size < 12)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: size error", __LINE__);
|
||||
@@ -156,6 +160,7 @@ scp_v1c_mng_get_session_list(struct SCP_CONNECTION* c, int* scount,
|
||||
}
|
||||
|
||||
init_stream(c->in_s, c->in_s->size);
|
||||
|
||||
if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, size - 8))
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: network error", __LINE__);
|
||||
@@ -163,6 +168,7 @@ scp_v1c_mng_get_session_list(struct SCP_CONNECTION* c, int* scount,
|
||||
}
|
||||
|
||||
in_uint16_be(c->in_s, cmd);
|
||||
|
||||
if (cmd != SCP_COMMAND_SET_MANAGE)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: sequence error", __LINE__);
|
||||
@@ -170,6 +176,7 @@ scp_v1c_mng_get_session_list(struct SCP_CONNECTION* c, int* scount,
|
||||
}
|
||||
|
||||
in_uint16_be(c->in_s, cmd);
|
||||
|
||||
if (cmd != SCP_CMD_MNG_LIST) /* session list */
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: sequence error", __LINE__);
|
||||
@@ -193,6 +200,7 @@ scp_v1c_mng_get_session_list(struct SCP_CONNECTION* c, int* scount,
|
||||
}
|
||||
|
||||
ds = g_malloc(sizeof(struct SCP_DISCONNECTED_SESSION) * sescnt, 0);
|
||||
|
||||
if (ds == 0)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: internal error", __LINE__);
|
||||
@@ -203,6 +211,7 @@ scp_v1c_mng_get_session_list(struct SCP_CONNECTION* c, int* scount,
|
||||
{
|
||||
in_uint32_be(c->in_s, sestmp);
|
||||
}
|
||||
|
||||
in_uint8(c->in_s, continued);
|
||||
in_uint8(c->in_s, pktcnt);
|
||||
|
||||
@@ -223,14 +232,17 @@ scp_v1c_mng_get_session_list(struct SCP_CONNECTION* c, int* scount,
|
||||
in_uint8(c->in_s, (ds[totalcnt]).conn_hour);
|
||||
in_uint8(c->in_s, (ds[totalcnt]).conn_minute);
|
||||
in_uint8(c->in_s, (ds[totalcnt]).addr_type);
|
||||
|
||||
if ((ds[totalcnt]).addr_type == SCP_ADDRESS_TYPE_IPV4)
|
||||
{
|
||||
in_uint32_be(c->in_s, (ds[totalcnt]).ipv4addr);
|
||||
}
|
||||
|
||||
if ((ds[totalcnt]).addr_type == SCP_ADDRESS_TYPE_IPV6)
|
||||
{
|
||||
in_uint8a(c->in_s, (ds[totalcnt]).ipv6addr, 16);
|
||||
}
|
||||
|
||||
totalcnt++;
|
||||
}
|
||||
}
|
||||
@@ -339,7 +351,7 @@ scp_v1c_select_session_cancel(struct SCP_CONNECTION* c)
|
||||
}*/
|
||||
|
||||
static enum SCP_CLIENT_STATES_E
|
||||
_scp_v1c_mng_check_response(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
_scp_v1c_mng_check_response(struct SCP_CONNECTION *c, struct SCP_SESSION *s)
|
||||
{
|
||||
tui32 version;
|
||||
tui32 size;
|
||||
@@ -348,6 +360,7 @@ _scp_v1c_mng_check_response(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
char buf[257];
|
||||
|
||||
init_stream(c->in_s, c->in_s->size);
|
||||
|
||||
if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, 8))
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: network error", __LINE__);
|
||||
@@ -355,6 +368,7 @@ _scp_v1c_mng_check_response(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
}
|
||||
|
||||
in_uint32_be(c->in_s, version);
|
||||
|
||||
if (version != 1)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: version error", __LINE__);
|
||||
@@ -364,6 +378,7 @@ _scp_v1c_mng_check_response(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
in_uint32_be(c->in_s, size);
|
||||
|
||||
init_stream(c->in_s, c->in_s->size);
|
||||
|
||||
/* read the rest of the packet */
|
||||
if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, size - 8))
|
||||
{
|
||||
@@ -372,6 +387,7 @@ _scp_v1c_mng_check_response(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
}
|
||||
|
||||
in_uint16_be(c->in_s, cmd);
|
||||
|
||||
if (cmd != SCP_COMMAND_SET_MANAGE)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: sequence error", __LINE__);
|
||||
@@ -379,6 +395,7 @@ _scp_v1c_mng_check_response(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
}
|
||||
|
||||
in_uint16_be(c->in_s, cmd);
|
||||
|
||||
if (cmd == SCP_CMD_MNG_LOGIN_ALLOW) /* connection ok */
|
||||
{
|
||||
log_message(LOG_LEVEL_INFO, "[v1c_mng:%d] connection ok", __LINE__);
|
||||
@@ -387,7 +404,7 @@ _scp_v1c_mng_check_response(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
else if (cmd == SCP_CMD_MNG_LOGIN_DENY) /* connection denied */
|
||||
{
|
||||
in_uint8(c->in_s, dim);
|
||||
buf[dim]='\0';
|
||||
buf[dim] = '\0';
|
||||
in_uint8a(c->in_s, buf, dim);
|
||||
scp_session_set_errstr(s, buf);
|
||||
|
||||
|
||||
@@ -1,21 +1,20 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
+113
-80
@@ -1,21 +1,20 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -33,9 +32,9 @@
|
||||
//extern struct log_config* s_log;
|
||||
|
||||
/* server API */
|
||||
enum SCP_SERVER_STATES_E scp_v1s_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s, int skipVchk)
|
||||
enum SCP_SERVER_STATES_E scp_v1s_accept(struct SCP_CONNECTION *c, struct SCP_SESSION **s, int skipVchk)
|
||||
{
|
||||
struct SCP_SESSION* session;
|
||||
struct SCP_SESSION *session;
|
||||
tui32 version;
|
||||
tui32 size;
|
||||
tui16 cmdset;
|
||||
@@ -49,6 +48,7 @@ enum SCP_SERVER_STATES_E scp_v1s_accept(struct SCP_CONNECTION* c, struct SCP_SES
|
||||
if (0 == scp_tcp_force_recv(c->in_sck, c->in_s->data, 8))
|
||||
{
|
||||
in_uint32_be(c->in_s, version);
|
||||
|
||||
if (version != 1)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: version error", __LINE__);
|
||||
@@ -63,6 +63,7 @@ enum SCP_SERVER_STATES_E scp_v1s_accept(struct SCP_CONNECTION* c, struct SCP_SES
|
||||
}
|
||||
|
||||
in_uint32_be(c->in_s, size);
|
||||
|
||||
if (size < 12)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: size error", __LINE__);
|
||||
@@ -70,7 +71,8 @@ enum SCP_SERVER_STATES_E scp_v1s_accept(struct SCP_CONNECTION* c, struct SCP_SES
|
||||
}
|
||||
|
||||
init_stream(c->in_s, c->in_s->size);
|
||||
if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, (size-8)))
|
||||
|
||||
if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, (size - 8)))
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__);
|
||||
return SCP_SERVER_STATE_NETWORK_ERR;
|
||||
@@ -96,6 +98,7 @@ enum SCP_SERVER_STATES_E scp_v1s_accept(struct SCP_CONNECTION* c, struct SCP_SES
|
||||
|
||||
/* reading command */
|
||||
in_uint16_be(c->in_s, cmd);
|
||||
|
||||
if (cmd != 1)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: sequence error", __LINE__);
|
||||
@@ -103,20 +106,24 @@ enum SCP_SERVER_STATES_E scp_v1s_accept(struct SCP_CONNECTION* c, struct SCP_SES
|
||||
}
|
||||
|
||||
session = scp_session_create();
|
||||
|
||||
if (0 == session)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: internal error (malloc returned NULL)", __LINE__);
|
||||
return SCP_SERVER_STATE_INTERNAL_ERR;
|
||||
}
|
||||
|
||||
scp_session_set_version(session, 1);
|
||||
|
||||
in_uint8(c->in_s, sz);
|
||||
|
||||
if ((sz != SCP_SESSION_TYPE_XVNC) && (sz != SCP_SESSION_TYPE_XRDP))
|
||||
{
|
||||
scp_session_destroy(session);
|
||||
log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: unknown session type", __LINE__);
|
||||
return SCP_SERVER_STATE_SESSION_TYPE_ERR;
|
||||
}
|
||||
|
||||
scp_session_set_type(session, sz);
|
||||
|
||||
in_uint16_be(c->in_s, cmd);
|
||||
@@ -128,10 +135,11 @@ enum SCP_SERVER_STATES_E scp_v1s_accept(struct SCP_CONNECTION* c, struct SCP_SES
|
||||
in_uint8(c->in_s, sz);
|
||||
scp_session_set_rsr(session, sz);
|
||||
in_uint8a(c->in_s, buf, 17);
|
||||
buf[17]='\0';
|
||||
buf[17] = '\0';
|
||||
scp_session_set_locale(session, buf);
|
||||
|
||||
in_uint8(c->in_s, sz);
|
||||
|
||||
if (sz == SCP_ADDRESS_TYPE_IPV4)
|
||||
{
|
||||
in_uint32_be(c->in_s, size);
|
||||
@@ -146,8 +154,9 @@ enum SCP_SERVER_STATES_E scp_v1s_accept(struct SCP_CONNECTION* c, struct SCP_SES
|
||||
buf[256] = '\0';
|
||||
/* reading hostname */
|
||||
in_uint8(c->in_s, sz);
|
||||
buf[sz]='\0';
|
||||
buf[sz] = '\0';
|
||||
in_uint8a(c->in_s, buf, sz);
|
||||
|
||||
if (0 != scp_session_set_hostname(session, buf))
|
||||
{
|
||||
scp_session_destroy(session);
|
||||
@@ -157,8 +166,9 @@ enum SCP_SERVER_STATES_E scp_v1s_accept(struct SCP_CONNECTION* c, struct SCP_SES
|
||||
|
||||
/* reading username */
|
||||
in_uint8(c->in_s, sz);
|
||||
buf[sz]='\0';
|
||||
buf[sz] = '\0';
|
||||
in_uint8a(c->in_s, buf, sz);
|
||||
|
||||
if (0 != scp_session_set_username(session, buf))
|
||||
{
|
||||
scp_session_destroy(session);
|
||||
@@ -168,8 +178,9 @@ enum SCP_SERVER_STATES_E scp_v1s_accept(struct SCP_CONNECTION* c, struct SCP_SES
|
||||
|
||||
/* reading password */
|
||||
in_uint8(c->in_s, sz);
|
||||
buf[sz]='\0';
|
||||
buf[sz] = '\0';
|
||||
in_uint8a(c->in_s, buf, sz);
|
||||
|
||||
if (0 != scp_session_set_password(session, buf))
|
||||
{
|
||||
scp_session_destroy(session);
|
||||
@@ -178,20 +189,21 @@ enum SCP_SERVER_STATES_E scp_v1s_accept(struct SCP_CONNECTION* c, struct SCP_SES
|
||||
}
|
||||
|
||||
/* returning the struct */
|
||||
(*s)=session;
|
||||
(*s) = session;
|
||||
|
||||
return SCP_SERVER_STATE_OK;
|
||||
}
|
||||
|
||||
enum SCP_SERVER_STATES_E
|
||||
scp_v1s_deny_connection(struct SCP_CONNECTION* c, char* reason)
|
||||
scp_v1s_deny_connection(struct SCP_CONNECTION *c, char *reason)
|
||||
{
|
||||
int rlen;
|
||||
|
||||
init_stream(c->out_s,c->out_s->size);
|
||||
init_stream(c->out_s, c->out_s->size);
|
||||
|
||||
/* forcing message not to exceed 64k */
|
||||
rlen = g_strlen(reason);
|
||||
|
||||
if (rlen > 65535)
|
||||
{
|
||||
rlen = 65535;
|
||||
@@ -200,13 +212,13 @@ scp_v1s_deny_connection(struct SCP_CONNECTION* c, char* reason)
|
||||
out_uint32_be(c->out_s, 1);
|
||||
/* packet size: 4 + 4 + 2 + 2 + 2 + strlen(reason)*/
|
||||
/* version + size + cmdset + cmd + msglen + msg */
|
||||
out_uint32_be(c->out_s, rlen+14);
|
||||
out_uint32_be(c->out_s, rlen + 14);
|
||||
out_uint16_be(c->out_s, SCP_COMMAND_SET_DEFAULT);
|
||||
out_uint16_be(c->out_s, 2);
|
||||
out_uint16_be(c->out_s, rlen);
|
||||
out_uint8p(c->out_s, reason, rlen);
|
||||
|
||||
if (0!=scp_tcp_force_send(c->in_sck, c->out_s->data, rlen+14))
|
||||
if (0 != scp_tcp_force_send(c->in_sck, c->out_s->data, rlen + 14))
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__);
|
||||
return SCP_SERVER_STATE_NETWORK_ERR;
|
||||
@@ -216,7 +228,7 @@ scp_v1s_deny_connection(struct SCP_CONNECTION* c, char* reason)
|
||||
}
|
||||
|
||||
enum SCP_SERVER_STATES_E
|
||||
scp_v1s_request_password(struct SCP_CONNECTION* c, struct SCP_SESSION* s, char* reason)
|
||||
scp_v1s_request_password(struct SCP_CONNECTION *c, struct SCP_SESSION *s, char *reason)
|
||||
{
|
||||
tui8 sz;
|
||||
tui32 version;
|
||||
@@ -231,58 +243,63 @@ scp_v1s_request_password(struct SCP_CONNECTION* c, struct SCP_SESSION* s, char*
|
||||
|
||||
/* forcing message not to exceed 64k */
|
||||
rlen = g_strlen(reason);
|
||||
|
||||
if (rlen > 65535)
|
||||
{
|
||||
rlen = 65535;
|
||||
}
|
||||
|
||||
/* send password request */
|
||||
version=1;
|
||||
cmd=3;
|
||||
version = 1;
|
||||
cmd = 3;
|
||||
|
||||
out_uint32_be(c->out_s, version); /* version */
|
||||
out_uint32_be(c->out_s, 14+rlen); /* size */
|
||||
out_uint32_be(c->out_s, 14 + rlen); /* size */
|
||||
out_uint16_be(c->out_s, SCP_COMMAND_SET_DEFAULT); /* cmdset */
|
||||
out_uint16_be(c->out_s, cmd); /* cmd */
|
||||
|
||||
out_uint16_be(c->out_s, rlen);
|
||||
out_uint8p(c->out_s, reason, rlen);
|
||||
|
||||
if (0!=scp_tcp_force_send(c->in_sck, c->out_s->data, 14+rlen))
|
||||
if (0 != scp_tcp_force_send(c->in_sck, c->out_s->data, 14 + rlen))
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__);
|
||||
return SCP_SERVER_STATE_NETWORK_ERR;
|
||||
}
|
||||
|
||||
/* receive password & username */
|
||||
if (0!=scp_tcp_force_recv(c->in_sck, c->in_s->data, 8))
|
||||
if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, 8))
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__);
|
||||
return SCP_SERVER_STATE_NETWORK_ERR;
|
||||
}
|
||||
|
||||
in_uint32_be(c->in_s, version);
|
||||
if (version!=1)
|
||||
|
||||
if (version != 1)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: version error", __LINE__);
|
||||
return SCP_SERVER_STATE_VERSION_ERR;
|
||||
}
|
||||
|
||||
in_uint32_be(c->in_s, size);
|
||||
if (size<12)
|
||||
|
||||
if (size < 12)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: size error", __LINE__);
|
||||
return SCP_SERVER_STATE_SIZE_ERR;
|
||||
}
|
||||
|
||||
init_stream(c->in_s, c->in_s->size);
|
||||
if (0!=scp_tcp_force_recv(c->in_sck, c->in_s->data, (size-8)))
|
||||
|
||||
if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, (size - 8)))
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__);
|
||||
return SCP_SERVER_STATE_NETWORK_ERR;
|
||||
}
|
||||
|
||||
in_uint16_be(c->in_s, cmdset);
|
||||
|
||||
if (cmdset != SCP_COMMAND_SET_DEFAULT)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: sequence error", __LINE__);
|
||||
@@ -290,6 +307,7 @@ scp_v1s_request_password(struct SCP_CONNECTION* c, struct SCP_SESSION* s, char*
|
||||
}
|
||||
|
||||
in_uint16_be(c->in_s, cmd);
|
||||
|
||||
if (cmd != 4)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: sequence error", __LINE__);
|
||||
@@ -301,6 +319,7 @@ scp_v1s_request_password(struct SCP_CONNECTION* c, struct SCP_SESSION* s, char*
|
||||
in_uint8(c->in_s, sz);
|
||||
buf[sz] = '\0';
|
||||
in_uint8a(c->in_s, buf, sz);
|
||||
|
||||
if (0 != scp_session_set_username(s, buf))
|
||||
{
|
||||
scp_session_destroy(s);
|
||||
@@ -310,8 +329,9 @@ scp_v1s_request_password(struct SCP_CONNECTION* c, struct SCP_SESSION* s, char*
|
||||
|
||||
/* reading password */
|
||||
in_uint8(c->in_s, sz);
|
||||
buf[sz]='\0';
|
||||
buf[sz] = '\0';
|
||||
in_uint8a(c->in_s, buf, sz);
|
||||
|
||||
if (0 != scp_session_set_password(s, buf))
|
||||
{
|
||||
scp_session_destroy(s);
|
||||
@@ -324,26 +344,26 @@ scp_v1s_request_password(struct SCP_CONNECTION* c, struct SCP_SESSION* s, char*
|
||||
|
||||
/* 020 */
|
||||
enum SCP_SERVER_STATES_E
|
||||
scp_v1s_request_pwd_change(struct SCP_CONNECTION* c, char* reason, char* npw)
|
||||
scp_v1s_request_pwd_change(struct SCP_CONNECTION *c, char *reason, char *npw)
|
||||
{
|
||||
return SCP_SERVER_STATE_INTERNAL_ERR;
|
||||
}
|
||||
|
||||
/* 023 */
|
||||
enum SCP_SERVER_STATES_E
|
||||
scp_v1s_pwd_change_error(struct SCP_CONNECTION* c, char* error, int retry, char* npw)
|
||||
scp_v1s_pwd_change_error(struct SCP_CONNECTION *c, char *error, int retry, char *npw)
|
||||
{
|
||||
return SCP_SERVER_STATE_INTERNAL_ERR;
|
||||
}
|
||||
|
||||
/* 030 */
|
||||
enum SCP_SERVER_STATES_E
|
||||
scp_v1s_connect_new_session(struct SCP_CONNECTION* c, SCP_DISPLAY d)
|
||||
scp_v1s_connect_new_session(struct SCP_CONNECTION *c, SCP_DISPLAY d)
|
||||
{
|
||||
/* send password request */
|
||||
tui32 version=1;
|
||||
tui32 size=14;
|
||||
tui16 cmd=30;
|
||||
tui32 version = 1;
|
||||
tui32 size = 14;
|
||||
tui16 cmd = 30;
|
||||
|
||||
init_stream(c->out_s, c->out_s->size);
|
||||
|
||||
@@ -354,7 +374,7 @@ scp_v1s_connect_new_session(struct SCP_CONNECTION* c, SCP_DISPLAY d)
|
||||
|
||||
out_uint16_be(c->out_s, d); /* display */
|
||||
|
||||
if (0!=scp_tcp_force_send(c->in_sck, c->out_s->data, 14))
|
||||
if (0 != scp_tcp_force_send(c->in_sck, c->out_s->data, 14))
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__);
|
||||
return SCP_SERVER_STATE_NETWORK_ERR;
|
||||
@@ -365,12 +385,12 @@ scp_v1s_connect_new_session(struct SCP_CONNECTION* c, SCP_DISPLAY d)
|
||||
|
||||
/* 032 */
|
||||
enum SCP_SERVER_STATES_E
|
||||
scp_v1s_connection_error(struct SCP_CONNECTION* c, char* error)
|
||||
scp_v1s_connection_error(struct SCP_CONNECTION *c, char *error)
|
||||
{
|
||||
tui16 len;
|
||||
|
||||
len = g_strlen(error);
|
||||
init_stream(c->out_s,c->out_s->size);
|
||||
init_stream(c->out_s, c->out_s->size);
|
||||
|
||||
out_uint32_be(c->out_s, 1);
|
||||
/* packet size: 4 + 4 + 2 + 2 + len */
|
||||
@@ -389,16 +409,16 @@ scp_v1s_connection_error(struct SCP_CONNECTION* c, char* error)
|
||||
|
||||
/* 040 */
|
||||
enum SCP_SERVER_STATES_E
|
||||
scp_v1s_list_sessions(struct SCP_CONNECTION* c, int sescnt, struct SCP_DISCONNECTED_SESSION* ds, SCP_SID* sid)
|
||||
scp_v1s_list_sessions(struct SCP_CONNECTION *c, int sescnt, struct SCP_DISCONNECTED_SESSION *ds, SCP_SID *sid)
|
||||
{
|
||||
tui32 version=1;
|
||||
tui32 size=12;
|
||||
tui16 cmd=40;
|
||||
tui32 version = 1;
|
||||
tui32 size = 12;
|
||||
tui16 cmd = 40;
|
||||
int pktcnt;
|
||||
int idx;
|
||||
int sidx;
|
||||
int pidx;
|
||||
struct SCP_DISCONNECTED_SESSION* cds;
|
||||
struct SCP_DISCONNECTED_SESSION *cds;
|
||||
|
||||
/* first we send a notice that we have some disconnected sessions */
|
||||
init_stream(c->out_s, c->out_s->size);
|
||||
@@ -408,7 +428,7 @@ scp_v1s_list_sessions(struct SCP_CONNECTION* c, int sescnt, struct SCP_DISCONNEC
|
||||
out_uint16_be(c->out_s, SCP_COMMAND_SET_DEFAULT); /* cmdset */
|
||||
out_uint16_be(c->out_s, cmd); /* cmd */
|
||||
|
||||
if (0!=scp_tcp_force_send(c->in_sck, c->out_s->data, size))
|
||||
if (0 != scp_tcp_force_send(c->in_sck, c->out_s->data, size))
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__);
|
||||
return SCP_SERVER_STATE_NETWORK_ERR;
|
||||
@@ -418,34 +438,39 @@ scp_v1s_list_sessions(struct SCP_CONNECTION* c, int sescnt, struct SCP_DISCONNEC
|
||||
#warning maybe this message could say if the session should be resized on
|
||||
#warning server side or client side
|
||||
init_stream(c->in_s, c->in_s->size);
|
||||
if (0!=scp_tcp_force_recv(c->in_sck, c->in_s->data, 8))
|
||||
|
||||
if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, 8))
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__);
|
||||
return SCP_SERVER_STATE_NETWORK_ERR;
|
||||
}
|
||||
|
||||
in_uint32_be(c->in_s, version);
|
||||
if (version!=1)
|
||||
|
||||
if (version != 1)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: version error", __LINE__);
|
||||
return SCP_SERVER_STATE_VERSION_ERR;
|
||||
}
|
||||
|
||||
in_uint32_be(c->in_s, size);
|
||||
if (size<12)
|
||||
|
||||
if (size < 12)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: size error", __LINE__);
|
||||
return SCP_SERVER_STATE_SIZE_ERR;
|
||||
}
|
||||
|
||||
init_stream(c->in_s, c->in_s->size);
|
||||
if (0!=scp_tcp_force_recv(c->in_sck, c->in_s->data, (size-8)))
|
||||
|
||||
if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, (size - 8)))
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__);
|
||||
return SCP_SERVER_STATE_NETWORK_ERR;
|
||||
}
|
||||
|
||||
in_uint16_be(c->in_s, cmd);
|
||||
|
||||
if (cmd != SCP_COMMAND_SET_DEFAULT)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: sequence error", __LINE__);
|
||||
@@ -453,6 +478,7 @@ scp_v1s_list_sessions(struct SCP_CONNECTION* c, int sescnt, struct SCP_DISCONNEC
|
||||
}
|
||||
|
||||
in_uint16_be(c->in_s, cmd);
|
||||
|
||||
if (cmd != 41)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: sequence error", __LINE__);
|
||||
@@ -460,22 +486,23 @@ scp_v1s_list_sessions(struct SCP_CONNECTION* c, int sescnt, struct SCP_DISCONNEC
|
||||
}
|
||||
|
||||
/* calculating the number of packets to send */
|
||||
pktcnt=sescnt/SCP_SERVER_MAX_LIST_SIZE;
|
||||
if ((sescnt%SCP_SERVER_MAX_LIST_SIZE)!=0)
|
||||
pktcnt = sescnt / SCP_SERVER_MAX_LIST_SIZE;
|
||||
|
||||
if ((sescnt % SCP_SERVER_MAX_LIST_SIZE) != 0)
|
||||
{
|
||||
pktcnt++;
|
||||
}
|
||||
|
||||
for (idx=0; idx<pktcnt; idx++)
|
||||
for (idx = 0; idx < pktcnt; idx++)
|
||||
{
|
||||
/* ok, we send session session list */
|
||||
init_stream(c->out_s, c->out_s->size);
|
||||
|
||||
/* size: ver+size+cmdset+cmd+sescnt+continue+count */
|
||||
size=4+4+2+2+4+1+1;
|
||||
size = 4 + 4 + 2 + 2 + 4 + 1 + 1;
|
||||
|
||||
/* header */
|
||||
cmd=42;
|
||||
cmd = 42;
|
||||
s_push_layer(c->out_s, channel_hdr, 8);
|
||||
out_uint16_be(c->out_s, SCP_COMMAND_SET_DEFAULT);
|
||||
out_uint16_be(c->out_s, cmd);
|
||||
@@ -484,26 +511,26 @@ scp_v1s_list_sessions(struct SCP_CONNECTION* c, int sescnt, struct SCP_DISCONNEC
|
||||
out_uint32_be(c->out_s, sescnt);
|
||||
|
||||
/* setting the continue flag */
|
||||
if ((idx+1)*SCP_SERVER_MAX_LIST_SIZE >= sescnt)
|
||||
if ((idx + 1)*SCP_SERVER_MAX_LIST_SIZE >= sescnt)
|
||||
{
|
||||
out_uint8(c->out_s, 0);
|
||||
/* setting session count for this packet */
|
||||
pidx=sescnt-(idx*SCP_SERVER_MAX_LIST_SIZE);
|
||||
pidx = sescnt - (idx * SCP_SERVER_MAX_LIST_SIZE);
|
||||
out_uint8(c->out_s, pidx);
|
||||
}
|
||||
else
|
||||
{
|
||||
out_uint8(c->out_s, 1);
|
||||
/* setting session count for this packet */
|
||||
pidx=SCP_SERVER_MAX_LIST_SIZE;
|
||||
pidx = SCP_SERVER_MAX_LIST_SIZE;
|
||||
out_uint8(c->out_s, pidx);
|
||||
}
|
||||
|
||||
/* adding session descriptors */
|
||||
for (sidx=0; sidx<pidx; sidx++)
|
||||
for (sidx = 0; sidx < pidx; sidx++)
|
||||
{
|
||||
/* shortcut to the current session to send */
|
||||
cds=ds+((idx)*SCP_SERVER_MAX_LIST_SIZE)+sidx;
|
||||
cds = ds + ((idx) * SCP_SERVER_MAX_LIST_SIZE) + sidx;
|
||||
|
||||
/* session data */
|
||||
out_uint32_be(c->out_s, cds->SID); /* session id */
|
||||
@@ -549,13 +576,15 @@ scp_v1s_list_sessions(struct SCP_CONNECTION* c, int sescnt, struct SCP_DISCONNEC
|
||||
|
||||
/* we get the response */
|
||||
init_stream(c->in_s, c->in_s->size);
|
||||
if (0!=scp_tcp_force_recv(c->in_sck, c->in_s->data, (8)))
|
||||
|
||||
if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, (8)))
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__);
|
||||
return SCP_SERVER_STATE_NETWORK_ERR;
|
||||
}
|
||||
|
||||
in_uint32_be(c->in_s, version);
|
||||
|
||||
if (version != 1)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: version error", __LINE__);
|
||||
@@ -563,6 +592,7 @@ scp_v1s_list_sessions(struct SCP_CONNECTION* c, int sescnt, struct SCP_DISCONNEC
|
||||
}
|
||||
|
||||
in_uint32_be(c->in_s, size);
|
||||
|
||||
if (size < 12)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: size error", __LINE__);
|
||||
@@ -571,13 +601,15 @@ scp_v1s_list_sessions(struct SCP_CONNECTION* c, int sescnt, struct SCP_DISCONNEC
|
||||
|
||||
/* rest of the packet */
|
||||
init_stream(c->in_s, c->in_s->size);
|
||||
if (0!=scp_tcp_force_recv(c->in_sck, c->in_s->data, (size-8)))
|
||||
|
||||
if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, (size - 8)))
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__);
|
||||
return SCP_SERVER_STATE_NETWORK_ERR;
|
||||
}
|
||||
|
||||
in_uint16_be(c->in_s, cmd);
|
||||
|
||||
if (cmd != SCP_COMMAND_SET_DEFAULT)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: sequence error", __LINE__);
|
||||
@@ -585,16 +617,17 @@ scp_v1s_list_sessions(struct SCP_CONNECTION* c, int sescnt, struct SCP_DISCONNEC
|
||||
}
|
||||
|
||||
in_uint16_be(c->in_s, cmd);
|
||||
|
||||
if (cmd == 43)
|
||||
{
|
||||
/* select session */
|
||||
in_uint32_be(c->in_s, (*sid));
|
||||
|
||||
/* checking sid value */
|
||||
for (idx=0; idx<sescnt; idx++)
|
||||
for (idx = 0; idx < sescnt; idx++)
|
||||
{
|
||||
/* the sid is valid */
|
||||
if (ds[idx].SID==(*sid))
|
||||
if (ds[idx].SID == (*sid))
|
||||
{
|
||||
/* ok, session selected */
|
||||
return SCP_SERVER_STATE_OK;
|
||||
@@ -611,11 +644,11 @@ scp_v1s_list_sessions(struct SCP_CONNECTION* c, int sescnt, struct SCP_DISCONNEC
|
||||
/* cancel connection */
|
||||
return SCP_SERVER_STATE_SELECTION_CANCEL;
|
||||
}
|
||||
// else if (cmd == 45)
|
||||
// {
|
||||
// /* force new connection */
|
||||
// return SCP_SERVER_STATE_FORCE_NEW;
|
||||
// }
|
||||
// else if (cmd == 45)
|
||||
// {
|
||||
// /* force new connection */
|
||||
// return SCP_SERVER_STATE_FORCE_NEW;
|
||||
// }
|
||||
else
|
||||
{
|
||||
/* wrong response */
|
||||
@@ -628,7 +661,7 @@ scp_v1s_list_sessions(struct SCP_CONNECTION* c, int sescnt, struct SCP_DISCONNEC
|
||||
|
||||
/* 046 was: 031 struct SCP_DISCONNECTED_SESSION* ds, */
|
||||
enum SCP_SERVER_STATES_E
|
||||
scp_v1s_reconnect_session(struct SCP_CONNECTION* c, SCP_DISPLAY d)
|
||||
scp_v1s_reconnect_session(struct SCP_CONNECTION *c, SCP_DISPLAY d)
|
||||
{
|
||||
tui32 version = 1;
|
||||
tui32 size = 14;
|
||||
@@ -654,7 +687,7 @@ scp_v1s_reconnect_session(struct SCP_CONNECTION* c, SCP_DISPLAY d)
|
||||
out_uint8(c->out_s, ds->idle_minutes);*/
|
||||
/* these last three are not really needed... */
|
||||
|
||||
if (0!=scp_tcp_force_send(c->in_sck, c->out_s->data, size))
|
||||
if (0 != scp_tcp_force_send(c->in_sck, c->out_s->data, size))
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__);
|
||||
return SCP_SERVER_STATE_NETWORK_ERR;
|
||||
|
||||
+17
-18
@@ -1,21 +1,20 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@@ -1,21 +1,20 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -33,13 +32,13 @@
|
||||
//extern struct log_config* s_log;
|
||||
|
||||
static enum SCP_SERVER_STATES_E
|
||||
_scp_v1s_mng_check_response(struct SCP_CONNECTION* c, struct SCP_SESSION* s);
|
||||
_scp_v1s_mng_check_response(struct SCP_CONNECTION *c, struct SCP_SESSION *s);
|
||||
|
||||
/* server API */
|
||||
enum SCP_SERVER_STATES_E
|
||||
scp_v1s_mng_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s)
|
||||
scp_v1s_mng_accept(struct SCP_CONNECTION *c, struct SCP_SESSION **s)
|
||||
{
|
||||
struct SCP_SESSION* session;
|
||||
struct SCP_SESSION *session;
|
||||
tui32 ipaddr;
|
||||
tui16 cmd;
|
||||
tui8 sz;
|
||||
@@ -47,12 +46,14 @@ scp_v1s_mng_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s)
|
||||
|
||||
/* reading command */
|
||||
in_uint16_be(c->in_s, cmd);
|
||||
|
||||
if (cmd != 1) /* manager login */
|
||||
{
|
||||
return SCP_SERVER_STATE_SEQUENCE_ERR;
|
||||
}
|
||||
|
||||
session = scp_session_create();
|
||||
|
||||
if (0 == session)
|
||||
{
|
||||
return SCP_SERVER_STATE_INTERNAL_ERR;
|
||||
@@ -63,8 +64,9 @@ scp_v1s_mng_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s)
|
||||
|
||||
/* reading username */
|
||||
in_uint8(c->in_s, sz);
|
||||
buf[sz]='\0';
|
||||
buf[sz] = '\0';
|
||||
in_uint8a(c->in_s, buf, sz);
|
||||
|
||||
if (0 != scp_session_set_username(session, buf))
|
||||
{
|
||||
scp_session_destroy(session);
|
||||
@@ -73,8 +75,9 @@ scp_v1s_mng_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s)
|
||||
|
||||
/* reading password */
|
||||
in_uint8(c->in_s, sz);
|
||||
buf[sz]='\0';
|
||||
buf[sz] = '\0';
|
||||
in_uint8a(c->in_s, buf, sz);
|
||||
|
||||
if (0 != scp_session_set_password(session, buf))
|
||||
{
|
||||
scp_session_destroy(session);
|
||||
@@ -83,6 +86,7 @@ scp_v1s_mng_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s)
|
||||
|
||||
/* reading remote address */
|
||||
in_uint8(c->in_s, sz);
|
||||
|
||||
if (sz == SCP_ADDRESS_TYPE_IPV4)
|
||||
{
|
||||
in_uint32_be(c->in_s, ipaddr);
|
||||
@@ -96,8 +100,9 @@ scp_v1s_mng_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s)
|
||||
|
||||
/* reading hostname */
|
||||
in_uint8(c->in_s, sz);
|
||||
buf[sz]='\0';
|
||||
buf[sz] = '\0';
|
||||
in_uint8a(c->in_s, buf, sz);
|
||||
|
||||
if (0 != scp_session_set_hostname(session, buf))
|
||||
{
|
||||
scp_session_destroy(session);
|
||||
@@ -105,16 +110,16 @@ scp_v1s_mng_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s)
|
||||
}
|
||||
|
||||
/* returning the struct */
|
||||
(*s)=session;
|
||||
(*s) = session;
|
||||
|
||||
return SCP_SERVER_STATE_START_MANAGE;
|
||||
}
|
||||
|
||||
/* 002 */
|
||||
enum SCP_SERVER_STATES_E
|
||||
scp_v1s_mng_allow_connection(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
scp_v1s_mng_allow_connection(struct SCP_CONNECTION *c, struct SCP_SESSION *s)
|
||||
{
|
||||
init_stream(c->out_s,c->out_s->size);
|
||||
init_stream(c->out_s, c->out_s->size);
|
||||
|
||||
out_uint32_be(c->out_s, 1);
|
||||
/* packet size: 4 + 4 + 2 + 2 */
|
||||
@@ -133,14 +138,15 @@ scp_v1s_mng_allow_connection(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
|
||||
/* 003 */
|
||||
enum SCP_SERVER_STATES_E
|
||||
scp_v1s_mng_deny_connection(struct SCP_CONNECTION* c, char* reason)
|
||||
scp_v1s_mng_deny_connection(struct SCP_CONNECTION *c, char *reason)
|
||||
{
|
||||
int rlen;
|
||||
|
||||
init_stream(c->out_s,c->out_s->size);
|
||||
init_stream(c->out_s, c->out_s->size);
|
||||
|
||||
/* forcing message not to exceed 64k */
|
||||
rlen = g_strlen(reason);
|
||||
|
||||
if (rlen > 65535)
|
||||
{
|
||||
rlen = 65535;
|
||||
@@ -149,13 +155,13 @@ scp_v1s_mng_deny_connection(struct SCP_CONNECTION* c, char* reason)
|
||||
out_uint32_be(c->out_s, 1);
|
||||
/* packet size: 4 + 4 + 2 + 2 + 2 + strlen(reason)*/
|
||||
/* version + size + cmdset + cmd + msglen + msg */
|
||||
out_uint32_be(c->out_s, rlen+14);
|
||||
out_uint32_be(c->out_s, rlen + 14);
|
||||
out_uint16_be(c->out_s, SCP_COMMAND_SET_MANAGE);
|
||||
out_uint16_be(c->out_s, SCP_CMD_MNG_LOGIN_DENY);
|
||||
out_uint16_be(c->out_s, rlen);
|
||||
out_uint8p(c->out_s, reason, rlen);
|
||||
|
||||
if (0!=scp_tcp_force_send(c->in_sck, c->out_s->data, rlen+14))
|
||||
if (0 != scp_tcp_force_send(c->in_sck, c->out_s->data, rlen + 14))
|
||||
{
|
||||
return SCP_SERVER_STATE_NETWORK_ERR;
|
||||
}
|
||||
@@ -165,8 +171,8 @@ scp_v1s_mng_deny_connection(struct SCP_CONNECTION* c, char* reason)
|
||||
|
||||
/* 006 */
|
||||
enum SCP_SERVER_STATES_E
|
||||
scp_v1s_mng_list_sessions(struct SCP_CONNECTION* c, struct SCP_SESSION* s,
|
||||
int sescnt, struct SCP_DISCONNECTED_SESSION* ds)
|
||||
scp_v1s_mng_list_sessions(struct SCP_CONNECTION *c, struct SCP_SESSION *s,
|
||||
int sescnt, struct SCP_DISCONNECTED_SESSION *ds)
|
||||
{
|
||||
tui32 version = 1;
|
||||
tui32 size = 12;
|
||||
@@ -175,22 +181,23 @@ scp_v1s_mng_list_sessions(struct SCP_CONNECTION* c, struct SCP_SESSION* s,
|
||||
int idx;
|
||||
int sidx;
|
||||
int pidx;
|
||||
struct SCP_DISCONNECTED_SESSION* cds;
|
||||
struct SCP_DISCONNECTED_SESSION *cds;
|
||||
|
||||
/* calculating the number of packets to send */
|
||||
pktcnt=sescnt/SCP_SERVER_MAX_LIST_SIZE;
|
||||
if ((sescnt%SCP_SERVER_MAX_LIST_SIZE)!=0)
|
||||
pktcnt = sescnt / SCP_SERVER_MAX_LIST_SIZE;
|
||||
|
||||
if ((sescnt % SCP_SERVER_MAX_LIST_SIZE) != 0)
|
||||
{
|
||||
pktcnt++;
|
||||
}
|
||||
|
||||
for (idx=0; idx<pktcnt; idx++)
|
||||
for (idx = 0; idx < pktcnt; idx++)
|
||||
{
|
||||
/* ok, we send session session list */
|
||||
init_stream(c->out_s, c->out_s->size);
|
||||
|
||||
/* size: ver+size+cmdset+cmd+sescnt+continue+count */
|
||||
size=4+4+2+2+4+1+1;
|
||||
size = 4 + 4 + 2 + 2 + 4 + 1 + 1;
|
||||
|
||||
/* header */
|
||||
s_push_layer(c->out_s, channel_hdr, 8);
|
||||
@@ -201,26 +208,26 @@ scp_v1s_mng_list_sessions(struct SCP_CONNECTION* c, struct SCP_SESSION* s,
|
||||
out_uint32_be(c->out_s, sescnt);
|
||||
|
||||
/* setting the continue flag */
|
||||
if ((idx+1)*SCP_SERVER_MAX_LIST_SIZE >= sescnt)
|
||||
if ((idx + 1)*SCP_SERVER_MAX_LIST_SIZE >= sescnt)
|
||||
{
|
||||
out_uint8(c->out_s, 0);
|
||||
/* setting session count for this packet */
|
||||
pidx=sescnt-(idx*SCP_SERVER_MAX_LIST_SIZE);
|
||||
pidx = sescnt - (idx * SCP_SERVER_MAX_LIST_SIZE);
|
||||
out_uint8(c->out_s, pidx);
|
||||
}
|
||||
else
|
||||
{
|
||||
out_uint8(c->out_s, 1);
|
||||
/* setting session count for this packet */
|
||||
pidx=SCP_SERVER_MAX_LIST_SIZE;
|
||||
pidx = SCP_SERVER_MAX_LIST_SIZE;
|
||||
out_uint8(c->out_s, pidx);
|
||||
}
|
||||
|
||||
/* adding session descriptors */
|
||||
for (sidx=0; sidx<pidx; sidx++)
|
||||
for (sidx = 0; sidx < pidx; sidx++)
|
||||
{
|
||||
/* shortcut to the current session to send */
|
||||
cds=ds+((idx)*SCP_SERVER_MAX_LIST_SIZE)+sidx;
|
||||
cds = ds + ((idx) * SCP_SERVER_MAX_LIST_SIZE) + sidx;
|
||||
|
||||
/* session data */
|
||||
out_uint32_be(c->out_s, cds->SID); /* session id */
|
||||
@@ -257,7 +264,7 @@ scp_v1s_mng_list_sessions(struct SCP_CONNECTION* c, struct SCP_SESSION* s,
|
||||
out_uint32_be(c->out_s, version);
|
||||
out_uint32_be(c->out_s, size);
|
||||
|
||||
if (0!=scp_tcp_force_send(c->in_sck, c->out_s->data, size))
|
||||
if (0 != scp_tcp_force_send(c->in_sck, c->out_s->data, size))
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1s_mng:%d] connection aborted: network error", __LINE__);
|
||||
return SCP_SERVER_STATE_NETWORK_ERR;
|
||||
@@ -268,15 +275,16 @@ scp_v1s_mng_list_sessions(struct SCP_CONNECTION* c, struct SCP_SESSION* s,
|
||||
}
|
||||
|
||||
static enum SCP_SERVER_STATES_E
|
||||
_scp_v1s_mng_check_response(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
_scp_v1s_mng_check_response(struct SCP_CONNECTION *c, struct SCP_SESSION *s)
|
||||
{
|
||||
tui32 version;
|
||||
tui32 size;
|
||||
tui16 cmd;
|
||||
// tui8 dim;
|
||||
// char buf[257];
|
||||
// tui8 dim;
|
||||
// char buf[257];
|
||||
|
||||
init_stream(c->in_s, c->in_s->size);
|
||||
|
||||
if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, 8))
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1s_mng:%d] connection aborted: network error", __LINE__);
|
||||
@@ -284,6 +292,7 @@ _scp_v1s_mng_check_response(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
}
|
||||
|
||||
in_uint32_be(c->in_s, version);
|
||||
|
||||
if (version != 1)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1s_mng:%d] connection aborted: version error", __LINE__);
|
||||
@@ -293,6 +302,7 @@ _scp_v1s_mng_check_response(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
in_uint32_be(c->in_s, size);
|
||||
|
||||
init_stream(c->in_s, c->in_s->size);
|
||||
|
||||
/* read the rest of the packet */
|
||||
if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, size - 8))
|
||||
{
|
||||
@@ -301,6 +311,7 @@ _scp_v1s_mng_check_response(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
}
|
||||
|
||||
in_uint16_be(c->in_s, cmd);
|
||||
|
||||
if (cmd != SCP_COMMAND_SET_MANAGE)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1s_mng:%d] connection aborted: sequence error", __LINE__);
|
||||
@@ -308,6 +319,7 @@ _scp_v1s_mng_check_response(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
}
|
||||
|
||||
in_uint16_be(c->in_s, cmd);
|
||||
|
||||
if (cmd == SCP_CMD_MNG_LIST_REQ) /* request session list */
|
||||
{
|
||||
log_message(LOG_LEVEL_INFO, "[v1s_mng:%d] request session list", __LINE__);
|
||||
@@ -323,6 +335,7 @@ _scp_v1s_mng_check_response(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
log_message(LOG_LEVEL_INFO, "[v1s_mng:%d] action request", __LINE__);
|
||||
return SCP_SERVER_STATE_MNG_ACTION;
|
||||
}
|
||||
|
||||
/* else if (cmd == 20) / * password change * /
|
||||
{
|
||||
in_uint16_be(c->in_s, s->display);
|
||||
|
||||
@@ -1,21 +1,20 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
+19
-20
@@ -1,21 +1,20 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -28,12 +27,12 @@
|
||||
#include "libscp_vX.h"
|
||||
|
||||
/* server API */
|
||||
enum SCP_SERVER_STATES_E scp_vXs_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s)
|
||||
enum SCP_SERVER_STATES_E scp_vXs_accept(struct SCP_CONNECTION *c, struct SCP_SESSION **s)
|
||||
{
|
||||
tui32 version;
|
||||
|
||||
/* reading version and packet size */
|
||||
if (0!=scp_tcp_force_recv(c->in_sck, c->in_s->data, 8))
|
||||
if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, 8))
|
||||
{
|
||||
return SCP_SERVER_STATE_NETWORK_ERR;
|
||||
}
|
||||
|
||||
+17
-18
@@ -1,21 +1,20 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user