@@ -127,38 +127,14 @@ static const char* const RTS_CMD_STRINGS[] =
127
127
128
128
#endif
129
129
130
- void rts_pdu_header_read (STREAM * s , RTS_PDU_HEADER * header )
131
- {
132
- stream_read_BYTE (s , header -> rpc_vers ); /* rpc_vers (1 byte) */
133
- stream_read_BYTE (s , header -> rpc_vers_minor ); /* rpc_vers_minor (1 byte) */
134
- stream_read_BYTE (s , header -> ptype ); /* PTYPE (1 byte) */
135
- stream_read_BYTE (s , header -> pfc_flags ); /* pfc_flags (1 byte) */
136
- stream_read_BYTE (s , header -> packed_drep [0 ]); /* packet_drep[0] (1 byte) */
137
- stream_read_BYTE (s , header -> packed_drep [1 ]); /* packet_drep[1] (1 byte) */
138
- stream_read_BYTE (s , header -> packed_drep [2 ]); /* packet_drep[2] (1 byte) */
139
- stream_read_BYTE (s , header -> packed_drep [3 ]); /* packet_drep[3] (1 byte) */
140
- stream_read_UINT16 (s , header -> frag_length ); /* frag_length (2 bytes) */
141
- stream_read_UINT16 (s , header -> auth_length ); /* auth_length (2 bytes) */
142
- stream_read_UINT32 (s , header -> call_id ); /* call_id (4 bytes) */
143
- stream_read_UINT16 (s , header -> flags ); /* flags (2 bytes) */
144
- stream_read_UINT16 (s , header -> numberOfCommands ); /* numberOfCommands (2 bytes) */
145
- }
146
-
147
- void rts_pdu_header_write (STREAM * s , RTS_PDU_HEADER * header )
148
- {
149
- stream_write_BYTE (s , header -> rpc_vers ); /* rpc_vers (1 byte) */
150
- stream_write_BYTE (s , header -> rpc_vers_minor ); /* rpc_vers_minor (1 byte) */
151
- stream_write_BYTE (s , header -> ptype ); /* PTYPE (1 byte) */
152
- stream_write_BYTE (s , header -> pfc_flags ); /* pfc_flags (1 byte) */
153
- stream_write_BYTE (s , header -> packed_drep [0 ]); /* packet_drep[0] (1 byte) */
154
- stream_write_BYTE (s , header -> packed_drep [1 ]); /* packet_drep[1] (1 byte) */
155
- stream_write_BYTE (s , header -> packed_drep [2 ]); /* packet_drep[2] (1 byte) */
156
- stream_write_BYTE (s , header -> packed_drep [3 ]); /* packet_drep[3] (1 byte) */
157
- stream_write_UINT16 (s , header -> frag_length ); /* frag_length (2 bytes) */
158
- stream_write_UINT16 (s , header -> auth_length ); /* auth_length (2 bytes) */
159
- stream_write_UINT32 (s , header -> call_id ); /* call_id (4 bytes) */
160
- stream_write_UINT16 (s , header -> flags ); /* flags (2 bytes) */
161
- stream_write_UINT16 (s , header -> numberOfCommands ); /* numberOfCommands (2 bytes) */
130
+ void rts_pdu_header_init (rdpRpc * rpc , RTS_PDU_HEADER * header )
131
+ {
132
+ header -> rpc_vers = rpc -> rpc_vers ;
133
+ header -> rpc_vers_minor = rpc -> rpc_vers_minor ;
134
+ header -> packed_drep [0 ] = rpc -> packed_drep [0 ];
135
+ header -> packed_drep [1 ] = rpc -> packed_drep [1 ];
136
+ header -> packed_drep [2 ] = rpc -> packed_drep [2 ];
137
+ header -> packed_drep [3 ] = rpc -> packed_drep [3 ];
162
138
}
163
139
164
140
void rts_receive_window_size_command_read (rdpRpc * rpc , STREAM * s )
@@ -370,14 +346,10 @@ BOOL rts_send_CONN_A1_pdu(rdpRpc* rpc)
370
346
BYTE * OUTChannelCookie ;
371
347
BYTE * VirtualConnectionCookie ;
372
348
373
- header . rpc_vers = 5 ;
374
- header . rpc_vers_minor = 0 ;
349
+ rts_pdu_header_init ( rpc , & header ) ;
350
+
375
351
header .ptype = PTYPE_RTS ;
376
352
header .pfc_flags = PFC_FIRST_FRAG | PFC_LAST_FRAG ;
377
- header .packed_drep [0 ] = 0x10 ;
378
- header .packed_drep [1 ] = 0x00 ;
379
- header .packed_drep [2 ] = 0x00 ;
380
- header .packed_drep [3 ] = 0x00 ;
381
353
header .frag_length = 76 ;
382
354
header .auth_length = 0 ;
383
355
header .call_id = 0 ;
@@ -395,7 +367,7 @@ BOOL rts_send_CONN_A1_pdu(rdpRpc* rpc)
395
367
OUTChannelCookie = (BYTE * ) & (rpc -> VirtualConnection -> DefaultOutChannelCookie );
396
368
ReceiveWindowSize = rpc -> VirtualConnection -> DefaultOutChannel -> ReceiveWindow ;
397
369
398
- rts_pdu_header_write (s , & header ); /* RTS Header (20 bytes) */
370
+ stream_write (s , (( BYTE * ) & header ), 20 ); /* RTS Header (20 bytes) */
399
371
rts_version_command_write (s ); /* Version (8 bytes) */
400
372
rts_cookie_command_write (s , VirtualConnectionCookie ); /* VirtualConnectionCookie (20 bytes) */
401
373
rts_cookie_command_write (s , OUTChannelCookie ); /* OUTChannelCookie (20 bytes) */
@@ -417,14 +389,10 @@ BOOL rts_send_CONN_B1_pdu(rdpRpc* rpc)
417
389
BYTE * AssociationGroupId ;
418
390
BYTE * VirtualConnectionCookie ;
419
391
420
- header . rpc_vers = 5 ;
421
- header . rpc_vers_minor = 0 ;
392
+ rts_pdu_header_init ( rpc , & header ) ;
393
+
422
394
header .ptype = PTYPE_RTS ;
423
395
header .pfc_flags = PFC_FIRST_FRAG | PFC_LAST_FRAG ;
424
- header .packed_drep [0 ] = 0x10 ;
425
- header .packed_drep [1 ] = 0x00 ;
426
- header .packed_drep [2 ] = 0x00 ;
427
- header .packed_drep [3 ] = 0x00 ;
428
396
header .frag_length = 104 ;
429
397
header .auth_length = 0 ;
430
398
header .call_id = 0 ;
@@ -442,7 +410,7 @@ BOOL rts_send_CONN_B1_pdu(rdpRpc* rpc)
442
410
INChannelCookie = (BYTE * ) & (rpc -> VirtualConnection -> DefaultInChannelCookie );
443
411
AssociationGroupId = (BYTE * ) & (rpc -> VirtualConnection -> AssociationGroupId );
444
412
445
- rts_pdu_header_write (s , & header ); /* RTS Header (20 bytes) */
413
+ stream_write (s , (( BYTE * ) & header ), 20 ); /* RTS Header (20 bytes) */
446
414
rts_version_command_write (s ); /* Version (8 bytes) */
447
415
rts_cookie_command_write (s , VirtualConnectionCookie ); /* VirtualConnectionCookie (20 bytes) */
448
416
rts_cookie_command_write (s , INChannelCookie ); /* INChannelCookie (20 bytes) */
@@ -463,14 +431,10 @@ BOOL rts_send_keep_alive_pdu(rdpRpc* rpc)
463
431
STREAM * s ;
464
432
RTS_PDU_HEADER header ;
465
433
466
- header . rpc_vers = 5 ;
467
- header . rpc_vers_minor = 0 ;
434
+ rts_pdu_header_init ( rpc , & header ) ;
435
+
468
436
header .ptype = PTYPE_RTS ;
469
437
header .pfc_flags = PFC_FIRST_FRAG | PFC_LAST_FRAG ;
470
- header .packed_drep [0 ] = 0x10 ;
471
- header .packed_drep [1 ] = 0x00 ;
472
- header .packed_drep [2 ] = 0x00 ;
473
- header .packed_drep [3 ] = 0x00 ;
474
438
header .frag_length = 28 ;
475
439
header .auth_length = 0 ;
476
440
header .call_id = 0 ;
@@ -480,7 +444,7 @@ BOOL rts_send_keep_alive_pdu(rdpRpc* rpc)
480
444
DEBUG_RPC ("Sending Keep-Alive RTS PDU" );
481
445
482
446
s = stream_new (header .frag_length );
483
- rts_pdu_header_write (s , & header ); /* RTS Header (20 bytes) */
447
+ stream_write (s , (( BYTE * ) & header ), 20 ); /* RTS Header (20 bytes) */
484
448
rts_client_keepalive_command_write (s , 0x00007530 ); /* ClientKeepalive (8 bytes) */
485
449
stream_seal (s );
486
450
@@ -499,14 +463,10 @@ BOOL rts_send_flow_control_ack_pdu(rdpRpc* rpc)
499
463
UINT32 AvailableWindow ;
500
464
BYTE * ChannelCookie ;
501
465
502
- header . rpc_vers = 5 ;
503
- header . rpc_vers_minor = 0 ;
466
+ rts_pdu_header_init ( rpc , & header ) ;
467
+
504
468
header .ptype = PTYPE_RTS ;
505
469
header .pfc_flags = PFC_FIRST_FRAG | PFC_LAST_FRAG ;
506
- header .packed_drep [0 ] = 0x10 ;
507
- header .packed_drep [1 ] = 0x00 ;
508
- header .packed_drep [2 ] = 0x00 ;
509
- header .packed_drep [3 ] = 0x00 ;
510
470
header .frag_length = 56 ;
511
471
header .auth_length = 0 ;
512
472
header .call_id = 0 ;
@@ -520,7 +480,7 @@ BOOL rts_send_flow_control_ack_pdu(rdpRpc* rpc)
520
480
ChannelCookie = (BYTE * ) & (rpc -> VirtualConnection -> DefaultOutChannelCookie );
521
481
522
482
s = stream_new (header .frag_length );
523
- rts_pdu_header_write (s , & header ); /* RTS Header (20 bytes) */
483
+ stream_write (s , (( BYTE * ) & header ), 20 ); /* RTS Header (20 bytes) */
524
484
rts_destination_command_write (s , FDOutProxy ); /* Destination Command (8 bytes) */
525
485
526
486
/* FlowControlAck Command (28 bytes) */
@@ -540,14 +500,10 @@ BOOL rts_send_ping_pdu(rdpRpc* rpc)
540
500
STREAM * s ;
541
501
RTS_PDU_HEADER header ;
542
502
543
- header . rpc_vers = 5 ;
544
- header . rpc_vers_minor = 0 ;
503
+ rts_pdu_header_init ( rpc , & header ) ;
504
+
545
505
header .ptype = PTYPE_RTS ;
546
506
header .pfc_flags = PFC_FIRST_FRAG | PFC_LAST_FRAG ;
547
- header .packed_drep [0 ] = 0x10 ;
548
- header .packed_drep [1 ] = 0x00 ;
549
- header .packed_drep [2 ] = 0x00 ;
550
- header .packed_drep [3 ] = 0x00 ;
551
507
header .frag_length = 20 ;
552
508
header .auth_length = 0 ;
553
509
header .call_id = 0 ;
@@ -557,7 +513,7 @@ BOOL rts_send_ping_pdu(rdpRpc* rpc)
557
513
DEBUG_RPC ("Sending Ping RTS PDU" );
558
514
559
515
s = stream_new (header .frag_length );
560
- rts_pdu_header_write (s , & header ); /* RTS Header (20 bytes) */
516
+ stream_write (s , (( BYTE * ) & header ), 20 ); /* RTS Header (20 bytes) */
561
517
stream_seal (s );
562
518
563
519
rpc_in_write (rpc , s -> data , s -> size );
@@ -669,48 +625,38 @@ int rts_recv_pdu_commands(rdpRpc* rpc, RTS_PDU* rts_pdu)
669
625
670
626
int rts_recv_pdu (rdpRpc * rpc , RTS_PDU * rts_pdu )
671
627
{
672
- STREAM * s ;
673
628
int status ;
674
629
int length ;
675
- BYTE header_buffer [20 ];
676
630
rdpTls * tls_out = rpc -> tls_out ;
677
631
678
632
/* read first 20 bytes to get RTS PDU Header */
679
- status = tls_read (tls_out , (BYTE * ) & header_buffer , 20 );
633
+ status = tls_read (tls_out , (BYTE * ) & ( rts_pdu -> header ) , 20 );
680
634
681
635
if (status <= 0 )
682
636
{
683
- printf ("rts_recv error\n" );
637
+ printf ("rts_recv_pdu error\n" );
684
638
return status ;
685
639
}
686
640
687
- s = stream_new (0 );
688
- stream_attach (s , header_buffer , 20 );
689
-
690
- rts_pdu_header_read (s , & (rts_pdu -> header ));
691
-
692
- stream_detach (s );
693
- stream_free (s );
694
-
695
641
length = rts_pdu -> header .frag_length - 20 ;
696
642
rts_pdu -> content = (BYTE * ) malloc (length );
697
643
698
644
status = tls_read (tls_out , rts_pdu -> content , length );
699
645
700
646
if (status < 0 )
701
647
{
702
- printf ("rts_recv error\n" );
648
+ printf ("rts_recv_pdu error\n" );
703
649
return status ;
704
650
}
705
651
706
652
if (rts_pdu -> header .ptype != PTYPE_RTS )
707
653
{
708
- printf ("rts_recv error: unexpected ptype:%d\n" , rts_pdu -> header .ptype );
654
+ printf ("rts_recv_pdu error: unexpected ptype: %d\n" , rts_pdu -> header .ptype );
709
655
return -1 ;
710
656
}
711
657
712
658
#ifdef WITH_DEBUG_RTS
713
- printf ("rts_recv() : length: %d\n" , length );
659
+ printf ("rts_recv_pdu : length: %d\n" , length );
714
660
freerdp_hexdump (rts_pdu -> content , length );
715
661
printf ("\n" );
716
662
#endif
0 commit comments