~ubuntu-branches/ubuntu/precise/virtualbox/precise-updates

« back to all changes in this revision

Viewing changes to src/VBox/RDP/client/rdp.c

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2011-07-04 13:02:31 UTC
  • mfrom: (3.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20110704130231-l843es6wqhx614n7
Tags: 4.0.10-dfsg-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - Add Apport hook.
    - debian/virtualbox-ose.files/source_virtualbox-ose.py
    - debian/virtualbox-ose.install
  - Drop *-source packages.
* Add the Modaliases control field manually for maximum backportability.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- c-basic-offset: 8 -*-
2
2
   rdesktop: A Remote Desktop Protocol client.
3
3
   Protocol services - RDP layer
4
 
   Copyright (C) Matthew Chapman 1999-2007
 
4
   Copyright (C) Matthew Chapman <matthewc.unsw.edu.au> 1999-2008
 
5
   Copyright 2003-2011 Peter Astrand <astrand@cendio.se> for Cendio AB
5
6
 
6
 
   This program is free software; you can redistribute it and/or modify
 
7
   This program is free software: you can redistribute it and/or modify
7
8
   it under the terms of the GNU General Public License as published by
8
 
   the Free Software Foundation; either version 2 of the License, or
 
9
   the Free Software Foundation, either version 3 of the License, or
9
10
   (at your option) any later version.
10
11
 
11
12
   This program is distributed in the hope that it will be useful,
14
15
   GNU General Public License for more details.
15
16
 
16
17
   You should have received a copy of the GNU General Public License
17
 
   along with this program; if not, write to the Free Software
18
 
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
18
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
19
*/
20
20
 
21
21
/*
33
33
#include <unistd.h>
34
34
#endif
35
35
#include "rdesktop.h"
 
36
#include "ssl.h"
36
37
 
37
38
#ifdef HAVE_ICONV
38
39
#ifdef HAVE_ICONV_H
45
46
#endif
46
47
 
47
48
extern uint16 g_mcs_userid;
48
 
extern char g_username[64];
 
49
extern char *g_username;
49
50
extern char g_codepage[16];
50
51
extern RD_BOOL g_bitmap_compression;
51
52
extern RD_BOOL g_orders;
61
62
extern RD_BOOL g_bitmap_cache;
62
63
extern RD_BOOL g_bitmap_cache_persist_enable;
63
64
extern RD_BOOL g_numlock_sync;
 
65
extern RD_BOOL g_pending_resize;
64
66
 
65
67
uint8 *g_next_packet;
66
68
uint32 g_rdp_shareid;
72
74
extern char g_redirect_server[64];
73
75
extern char g_redirect_domain[16];
74
76
extern char g_redirect_password[64];
75
 
extern char g_redirect_username[64];
 
77
extern char *g_redirect_username;
76
78
extern char g_redirect_cookie[128];
77
79
extern uint32 g_redirect_flags;
78
80
/* END Session Directory support */
79
81
 
 
82
extern uint32 g_reconnect_logonid;
 
83
extern char g_reconnect_random[16];
 
84
extern RD_BOOL g_has_reconnect_random;
 
85
extern uint8 g_client_random[SEC_RANDOM_SIZE];
 
86
 
80
87
#if WITH_DEBUG
81
88
static uint32 g_packetno;
82
89
#endif
341
348
        STREAM s;
342
349
        time_t t = time(NULL);
343
350
        time_t tzone;
 
351
        uint8 security_verifier[16];
344
352
 
345
353
        if (!g_use_rdp5 || 1 == g_server_rdp_version)
346
354
        {
438
446
                {
439
447
                        out_uint16_le(s, 0);
440
448
                }
441
 
                out_uint16_le(s, 2);
442
 
                out_uint16_le(s, len_ip + 2);   /* Length of client ip */
443
 
                rdp_out_unistr(s, ipaddr, len_ip);
444
 
                out_uint16_le(s, len_dll + 2);
445
 
                rdp_out_unistr(s, "C:\\WINNT\\System32\\mstscax.dll", len_dll);
 
449
                /* TS_EXTENDED_INFO_PACKET */
 
450
                out_uint16_le(s, 2);    /* clientAddressFamily = AF_INET */
 
451
                out_uint16_le(s, len_ip + 2);   /* cbClientAddress, Length of client ip */
 
452
                rdp_out_unistr(s, ipaddr, len_ip);      /* clientAddress */
 
453
                out_uint16_le(s, len_dll + 2);  /* cbClientDir */
 
454
                rdp_out_unistr(s, "C:\\WINNT\\System32\\mstscax.dll", len_dll); /* clientDir */
446
455
 
 
456
                /* TS_TIME_ZONE_INFORMATION */
447
457
                tzone = (mktime(gmtime(&t)) - mktime(localtime(&t))) / 60;
448
458
                out_uint32_le(s, tzone);
449
 
 
450
459
                rdp_out_unistr(s, "GTB, normaltid", 2 * strlen("GTB, normaltid"));
451
460
                out_uint8s(s, 62 - 2 * strlen("GTB, normaltid"));
452
 
 
453
461
                out_uint32_le(s, 0x0a0000);
454
462
                out_uint32_le(s, 0x050000);
455
463
                out_uint32_le(s, 3);
456
464
                out_uint32_le(s, 0);
457
465
                out_uint32_le(s, 0);
458
 
 
459
466
                rdp_out_unistr(s, "GTB, sommartid", 2 * strlen("GTB, sommartid"));
460
467
                out_uint8s(s, 62 - 2 * strlen("GTB, sommartid"));
461
 
 
462
468
                out_uint32_le(s, 0x30000);
463
469
                out_uint32_le(s, 0x050000);
464
470
                out_uint32_le(s, 2);
465
471
                out_uint32(s, 0);
466
 
                out_uint32_le(s, 0xffffffc4);
467
 
                out_uint32_le(s, 0xfffffffe);
 
472
                out_uint32_le(s, 0xffffffc4);   /* DaylightBias */
 
473
 
 
474
                /* Rest of TS_EXTENDED_INFO_PACKET */
 
475
                out_uint32_le(s, 0xfffffffe);   /* clientSessionId, consider changing to 0 */
468
476
                out_uint32_le(s, g_rdp5_performanceflags);
469
 
                out_uint16(s, 0);
470
477
 
 
478
                /* Client Auto-Reconnect */
 
479
                if (g_has_reconnect_random)
 
480
                {
 
481
                        out_uint16_le(s, 28);   /* cbAutoReconnectLen */
 
482
                        /* ARC_CS_PRIVATE_PACKET */
 
483
                        out_uint32_le(s, 28);   /* cbLen */
 
484
                        out_uint32_le(s, 1);    /* Version */
 
485
                        out_uint32_le(s, g_reconnect_logonid);  /* LogonId */
 
486
                        ssl_hmac_md5(g_reconnect_random, sizeof(g_reconnect_random),
 
487
                                     g_client_random, SEC_RANDOM_SIZE, security_verifier);
 
488
                        out_uint8a(s, security_verifier, sizeof(security_verifier));
 
489
                }
 
490
                else
 
491
                {
 
492
                        out_uint16_le(s, 0);    /* cbAutoReconnectLen */
 
493
                }
471
494
 
472
495
        }
473
496
        s_mark_end(s);
787
810
        out_uint16_le(s, 20);   /* Cache size */
788
811
}
789
812
 
 
813
/* Output new pointer capability set */
 
814
static void
 
815
rdp_out_newpointer_caps(STREAM s)
 
816
{
 
817
        out_uint16_le(s, RDP_CAPSET_POINTER);
 
818
        out_uint16_le(s, RDP_CAPLEN_NEWPOINTER);
 
819
 
 
820
        out_uint16_le(s, 1);    /* Colour pointer */
 
821
        out_uint16_le(s, 20);   /* Cache size */
 
822
        out_uint16_le(s, 20);   /* Cache size for new pointers */
 
823
}
 
824
 
790
825
/* Output share capability set */
791
826
static void
792
827
rdp_out_share_caps(STREAM s)
809
844
        out_uint16(s, 0);       /* pad */
810
845
}
811
846
 
 
847
/* Output brush cache capability set */
 
848
static void
 
849
rdp_out_brushcache_caps(STREAM s)
 
850
{
 
851
        out_uint16_le(s, RDP_CAPSET_BRUSHCACHE);
 
852
        out_uint16_le(s, RDP_CAPLEN_BRUSHCACHE);
 
853
        out_uint32_le(s, 1);    /* cache type */
 
854
}
 
855
 
812
856
static uint8 caps_0x0d[] = {
813
857
        0x01, 0x00, 0x00, 0x00, 0x09, 0x04, 0x00, 0x00,
814
858
        0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
855
899
        uint32 sec_flags = g_encryption ? (RDP5_FLAG | SEC_ENCRYPT) : RDP5_FLAG;
856
900
        uint16 caplen =
857
901
                RDP_CAPLEN_GENERAL + RDP_CAPLEN_BITMAP + RDP_CAPLEN_ORDER +
858
 
                RDP_CAPLEN_BMPCACHE + RDP_CAPLEN_COLCACHE +
 
902
                RDP_CAPLEN_COLCACHE +
859
903
                RDP_CAPLEN_ACTIVATE + RDP_CAPLEN_CONTROL +
860
 
                RDP_CAPLEN_POINTER + RDP_CAPLEN_SHARE +
861
 
                0x58 + 0x08 + 0x08 + 0x34 /* unknown caps */  +
862
 
                4 /* w2k fix, why? */ ;
 
904
                RDP_CAPLEN_SHARE +
 
905
                RDP_CAPLEN_BRUSHCACHE + 0x58 + 0x08 + 0x08 + 0x34 /* unknown caps */  +
 
906
                4 /* w2k fix, sessionid */ ;
 
907
 
 
908
        if (g_use_rdp5)
 
909
        {
 
910
                caplen += RDP_CAPLEN_BMPCACHE2;
 
911
                caplen += RDP_CAPLEN_NEWPOINTER;
 
912
        }
 
913
        else
 
914
        {
 
915
                caplen += RDP_CAPLEN_BMPCACHE;
 
916
                caplen += RDP_CAPLEN_POINTER;
 
917
        }
863
918
 
864
919
        s = sec_init(sec_flags, 6 + 14 + caplen + sizeof(RDP_SOURCE));
865
920
 
873
928
        out_uint16_le(s, caplen);
874
929
 
875
930
        out_uint8p(s, RDP_SOURCE, sizeof(RDP_SOURCE));
876
 
        out_uint16_le(s, 0xd);  /* num_caps */
 
931
        out_uint16_le(s, 0xe);  /* num_caps */
877
932
        out_uint8s(s, 2);       /* pad */
878
933
 
879
934
        rdp_out_general_caps(s);
880
935
        rdp_out_bitmap_caps(s);
881
936
        rdp_out_order_caps(s);
882
 
        g_use_rdp5 ? rdp_out_bmpcache2_caps(s) : rdp_out_bmpcache_caps(s);
 
937
        if (g_use_rdp5)
 
938
        {
 
939
                rdp_out_bmpcache2_caps(s);
 
940
                rdp_out_newpointer_caps(s);
 
941
        }
 
942
        else
 
943
        {
 
944
                rdp_out_bmpcache_caps(s);
 
945
                rdp_out_pointer_caps(s);
 
946
        }
883
947
        rdp_out_colcache_caps(s);
884
948
        rdp_out_activate_caps(s);
885
949
        rdp_out_control_caps(s);
886
 
        rdp_out_pointer_caps(s);
887
950
        rdp_out_share_caps(s);
 
951
        rdp_out_brushcache_caps(s);
888
952
 
889
 
        rdp_out_unknown_caps(s, 0x0d, 0x58, caps_0x0d); /* international? */
890
 
        rdp_out_unknown_caps(s, 0x0c, 0x08, caps_0x0c);
891
 
        rdp_out_unknown_caps(s, 0x0e, 0x08, caps_0x0e);
892
 
        rdp_out_unknown_caps(s, 0x10, 0x34, caps_0x10); /* glyph cache? */
 
953
        rdp_out_unknown_caps(s, 0x0d, 0x58, caps_0x0d); /* CAPSTYPE_INPUT */
 
954
        rdp_out_unknown_caps(s, 0x0c, 0x08, caps_0x0c); /* CAPSTYPE_SOUND */
 
955
        rdp_out_unknown_caps(s, 0x0e, 0x08, caps_0x0e); /* CAPSTYPE_FONT */
 
956
        rdp_out_unknown_caps(s, 0x10, 0x34, caps_0x10); /* CAPSTYPE_GLYPHCACHE */
893
957
 
894
958
        s_mark_end(s);
895
959
        sec_send(s, sec_flags);
1021
1085
}
1022
1086
 
1023
1087
/* Process a colour pointer PDU */
1024
 
void
1025
 
process_colour_pointer_pdu(STREAM s)
 
1088
static void
 
1089
process_colour_pointer_common(STREAM s, int bpp)
1026
1090
{
1027
 
        uint16 x, y, width, height, cache_idx, masklen, datalen;
1028
 
        uint8 *mask, *data;
 
1091
        uint16 width, height, cache_idx, masklen, datalen;
 
1092
        sint16 x, y;
 
1093
        uint8 *mask;
 
1094
        uint8 *data;
1029
1095
        RD_HCURSOR cursor;
1030
1096
 
1031
1097
        in_uint16_le(s, cache_idx);
1037
1103
        in_uint16_le(s, datalen);
1038
1104
        in_uint8p(s, data, datalen);
1039
1105
        in_uint8p(s, mask, masklen);
1040
 
        cursor = ui_create_cursor(x, y, width, height, mask, data);
 
1106
        if ((width != 32) || (height != 32))
 
1107
        {
 
1108
                warning("process_colour_pointer_common: " "width %d height %d\n", width, height);
 
1109
        }
 
1110
        /* sometimes x or y is out of bounds */
 
1111
        x = MAX(x, 0);
 
1112
        x = MIN(x, width - 1);
 
1113
        y = MAX(y, 0);
 
1114
        y = MIN(y, height - 1);
 
1115
        cursor = ui_create_cursor(x, y, width, height, mask, data, bpp);
1041
1116
        ui_set_cursor(cursor);
1042
1117
        cache_put_cursor(cache_idx, cursor);
1043
1118
}
1044
1119
 
 
1120
/* Process a colour pointer PDU */
 
1121
void
 
1122
process_colour_pointer_pdu(STREAM s)
 
1123
{
 
1124
        process_colour_pointer_common(s, 24);
 
1125
}
 
1126
 
 
1127
/* Process a New Pointer PDU - these pointers have variable bit depth */
 
1128
void
 
1129
process_new_pointer_pdu(STREAM s)
 
1130
{
 
1131
        int xor_bpp;
 
1132
 
 
1133
        in_uint16_le(s, xor_bpp);
 
1134
        process_colour_pointer_common(s, xor_bpp);
 
1135
}
 
1136
 
1045
1137
/* Process a cached pointer PDU */
1046
1138
void
1047
1139
process_cached_pointer_pdu(STREAM s)
1101
1193
                        process_system_pointer_pdu(s);
1102
1194
                        break;
1103
1195
 
 
1196
                case RDP_POINTER_NEW:
 
1197
                        process_new_pointer_pdu(s);
 
1198
                        break;
 
1199
 
1104
1200
                default:
1105
1201
                        unimpl("Pointer message 0x%x\n", message_type);
1106
1202
        }
1243
1339
        ui_end_update();
1244
1340
}
1245
1341
 
 
1342
 
 
1343
/* Process a Save Session Info PDU */
 
1344
void
 
1345
process_pdu_logon(STREAM s)
 
1346
{
 
1347
        uint32 infotype;
 
1348
        in_uint32_le(s, infotype);
 
1349
        if (infotype == INFOTYPE_LOGON_EXTENDED_INF)
 
1350
        {
 
1351
                uint32 fieldspresent;
 
1352
 
 
1353
                in_uint8s(s, 2);        /* Length */
 
1354
                in_uint32_le(s, fieldspresent);
 
1355
                if (fieldspresent & LOGON_EX_AUTORECONNECTCOOKIE)
 
1356
                {
 
1357
                        uint32 len;
 
1358
                        uint32 version;
 
1359
 
 
1360
                        /* TS_LOGON_INFO_FIELD */
 
1361
                        in_uint8s(s, 4);        /* cbFieldData */
 
1362
 
 
1363
                        /* ARC_SC_PRIVATE_PACKET */
 
1364
                        in_uint32_le(s, len);
 
1365
                        if (len != 28)
 
1366
                        {
 
1367
                                warning("Invalid length in Auto-Reconnect packet\n");
 
1368
                                return;
 
1369
                        }
 
1370
 
 
1371
                        in_uint32_le(s, version);
 
1372
                        if (version != 1)
 
1373
                        {
 
1374
                                warning("Unsupported version of Auto-Reconnect packet\n");
 
1375
                                return;
 
1376
                        }
 
1377
 
 
1378
                        in_uint32_le(s, g_reconnect_logonid);
 
1379
                        in_uint8a(s, g_reconnect_random, 16);
 
1380
                        g_has_reconnect_random = True;
 
1381
                        DEBUG(("Saving auto-reconnect cookie, id=%u\n", g_reconnect_logonid));
 
1382
                }
 
1383
        }
 
1384
}
 
1385
 
 
1386
 
1246
1387
/* Process a disconnect PDU */
1247
1388
void
1248
1389
process_disconnect_pdu(STREAM s, uint32 * ext_disc_reason)
1319
1460
                case RDP_DATA_PDU_LOGON:
1320
1461
                        DEBUG(("Received Logon PDU\n"));
1321
1462
                        /* User logged on */
 
1463
                        process_pdu_logon(s);
1322
1464
                        break;
1323
1465
 
1324
1466
                case RDP_DATA_PDU_DISCONNECT:
1349
1491
        /* read connection flags */
1350
1492
        in_uint32_le(s, g_redirect_flags);
1351
1493
 
1352
 
        /* read length of ip string */
1353
 
        in_uint32_le(s, len);
1354
 
 
1355
 
        /* read ip string */
1356
 
        rdp_in_unistr(s, g_redirect_server, sizeof(g_redirect_server), len);
1357
 
 
1358
 
        /* read length of cookie string */
1359
 
        in_uint32_le(s, len);
1360
 
 
1361
 
        /* read cookie string (plain ASCII) */
1362
 
        if (len > sizeof(g_redirect_cookie) - 1)
1363
 
        {
1364
 
                uint32 rem = len - (sizeof(g_redirect_cookie) - 1);
1365
 
                len = sizeof(g_redirect_cookie) - 1;
1366
 
 
1367
 
                warning("Unexpectedly large redirection cookie\n");
1368
 
                in_uint8a(s, g_redirect_cookie, len);
1369
 
                in_uint8s(s, rem);
1370
 
        }
1371
 
        else
1372
 
        {
1373
 
                in_uint8a(s, g_redirect_cookie, len);
1374
 
        }
1375
 
        g_redirect_cookie[len] = 0;
1376
 
 
1377
 
        /* read length of username string */
1378
 
        in_uint32_le(s, len);
1379
 
 
1380
 
        /* read username string */
1381
 
        rdp_in_unistr(s, g_redirect_username, sizeof(g_redirect_username), len);
1382
 
 
1383
 
        /* read length of domain string */
1384
 
        in_uint32_le(s, len);
1385
 
 
1386
 
        /* read domain string */
1387
 
        rdp_in_unistr(s, g_redirect_domain, sizeof(g_redirect_domain), len);
1388
 
 
1389
 
        /* read length of password string */
1390
 
        in_uint32_le(s, len);
1391
 
 
1392
 
        /* read password string */
1393
 
        rdp_in_unistr(s, g_redirect_password, sizeof(g_redirect_password), len);
 
1494
        if (g_redirect_flags & PDU_REDIRECT_HAS_IP)
 
1495
        {
 
1496
                /* read length of ip string */
 
1497
                in_uint32_le(s, len);
 
1498
 
 
1499
                /* read ip string */
 
1500
                rdp_in_unistr(s, g_redirect_server, sizeof(g_redirect_server), len);
 
1501
        }
 
1502
 
 
1503
        if (g_redirect_flags & PDU_REDIRECT_HAS_COOKIE)
 
1504
        {
 
1505
                /* read length of cookie string */
 
1506
                in_uint32_le(s, len);
 
1507
 
 
1508
                /* read cookie string (plain ASCII) */
 
1509
                if (len > sizeof(g_redirect_cookie) - 1)
 
1510
                {
 
1511
                        uint32 rem = len - (sizeof(g_redirect_cookie) - 1);
 
1512
                        len = sizeof(g_redirect_cookie) - 1;
 
1513
 
 
1514
                        warning("Unexpectedly large redirection cookie\n");
 
1515
                        in_uint8a(s, g_redirect_cookie, len);
 
1516
                        in_uint8s(s, rem);
 
1517
                }
 
1518
                else
 
1519
                {
 
1520
                        in_uint8a(s, g_redirect_cookie, len);
 
1521
                }
 
1522
                g_redirect_cookie[len] = 0;
 
1523
        }
 
1524
 
 
1525
        if (g_redirect_flags & PDU_REDIRECT_HAS_USERNAME)
 
1526
        {
 
1527
                /* read length of username string */
 
1528
                in_uint32_le(s, len);
 
1529
 
 
1530
                /* read username string */
 
1531
                g_redirect_username = (char *) xmalloc(len + 1);
 
1532
                rdp_in_unistr(s, g_redirect_username, strlen(g_redirect_username), len);
 
1533
        }
 
1534
 
 
1535
        if (g_redirect_flags & PDU_REDIRECT_HAS_DOMAIN)
 
1536
        {
 
1537
                /* read length of domain string */
 
1538
                in_uint32_le(s, len);
 
1539
 
 
1540
                /* read domain string */
 
1541
                rdp_in_unistr(s, g_redirect_domain, sizeof(g_redirect_domain), len);
 
1542
        }
 
1543
 
 
1544
        if (g_redirect_flags & PDU_REDIRECT_HAS_PASSWORD)
 
1545
        {
 
1546
                /* read length of password string */
 
1547
                in_uint32_le(s, len);
 
1548
 
 
1549
                /* read password string */
 
1550
                rdp_in_unistr(s, g_redirect_password, sizeof(g_redirect_password), len);
 
1551
        }
 
1552
 
 
1553
        if (g_redirect_flags & PDU_REDIRECT_DONT_STORE_USERNAME)
 
1554
        {
 
1555
                warning("PDU_REDIRECT_DONT_STORE_USERNAME set\n");
 
1556
        }
 
1557
 
 
1558
        if (g_redirect_flags & PDU_REDIRECT_USE_SMARTCARD)
 
1559
        {
 
1560
                warning("PDU_REDIRECT_USE_SMARTCARD set\n");
 
1561
        }
 
1562
 
 
1563
        if (g_redirect_flags & PDU_REDIRECT_INFORMATIONAL)
 
1564
        {
 
1565
                warning("PDU_REDIRECT_INFORMATIONAL set\n");
 
1566
        }
 
1567
 
 
1568
        if (g_redirect_flags & PDU_REDIRECT_HAS_TARGET_FQDN)
 
1569
        {
 
1570
                warning("PDU_REDIRECT_HAS_TARGET_FQDN set\n");
 
1571
        }
 
1572
 
 
1573
        if (g_redirect_flags & PDU_REDIRECT_HAS_TARGET_NETBIOS)
 
1574
        {
 
1575
                warning("PDU_REDIRECT_HAS_TARGET_NETBIOS set\n");
 
1576
        }
 
1577
 
 
1578
        if (g_redirect_flags & PDU_REDIRECT_HAS_TARGET_IP_ARRAY)
 
1579
        {
 
1580
                warning("PDU_REDIRECT_HAS_TARGET_IP_ARRAY set\n");
 
1581
        }
1394
1582
 
1395
1583
        g_redirect = True;
1396
1584
 
1398
1586
}
1399
1587
 
1400
1588
/* Process incoming packets */
1401
 
/* nevers gets out of here till app is done */
1402
1589
void
1403
1590
rdp_main_loop(RD_BOOL * deactivated, uint32 * ext_disc_reason)
1404
1591
{
1405
1592
        while (rdp_loop(deactivated, ext_disc_reason))
1406
 
                ;
 
1593
        {
 
1594
                if (g_pending_resize)
 
1595
                {
 
1596
                        return;
 
1597
                }
 
1598
        }
1407
1599
}
1408
1600
 
1409
1601
/* used in uiports and rdp_main_loop, processes the rdp packets waiting */
1411
1603
rdp_loop(RD_BOOL * deactivated, uint32 * ext_disc_reason)
1412
1604
{
1413
1605
        uint8 type;
1414
 
        RD_BOOL disc = False;   /* True when a disconnect PDU was received */
1415
1606
        RD_BOOL cont = True;
1416
1607
        STREAM s;
1417
1608
 
1434
1625
                                return process_redirect_pdu(s);
1435
1626
                                break;
1436
1627
                        case RDP_PDU_DATA:
1437
 
                                disc = process_data_pdu(s, ext_disc_reason);
 
1628
                                process_data_pdu(s, ext_disc_reason);
1438
1629
                                break;
1439
1630
                        case 0:
1440
1631
                                break;
1441
1632
                        default:
1442
1633
                                unimpl("PDU %d\n", type);
1443
1634
                }
1444
 
                if (disc)
1445
 
                        return False;
1446
1635
                cont = g_next_packet < s->end;
1447
1636
        }
1448
1637
        return True;
1451
1640
/* Establish a connection up to the RDP layer */
1452
1641
RD_BOOL
1453
1642
rdp_connect(char *server, uint32 flags, char *domain, char *password,
1454
 
            char *command, char *directory)
1455
 
{
1456
 
        if (!sec_connect(server, g_username))
1457
 
                return False;
1458
 
 
1459
 
        rdp_send_logon_info(flags, domain, g_username, password, command, directory);
1460
 
        return True;
1461
 
}
1462
 
 
1463
 
/* Establish a reconnection up to the RDP layer */
1464
 
RD_BOOL
1465
 
rdp_reconnect(char *server, uint32 flags, char *domain, char *password,
1466
 
              char *command, char *directory, char *cookie)
1467
 
{
1468
 
        if (!sec_reconnect(server))
 
1643
            char *command, char *directory, RD_BOOL reconnect)
 
1644
{
 
1645
        if (!sec_connect(server, g_username, reconnect))
1469
1646
                return False;
1470
1647
 
1471
1648
        rdp_send_logon_info(flags, domain, g_username, password, command, directory);