@@ -495,6 +495,21 @@ build_encrypt_ctxt(struct smb2_encryption_neg_context *pneg_ctxt)
495
495
pneg_ctxt -> Ciphers [1 ] = SMB2_ENCRYPTION_AES128_CCM ;
496
496
}
497
497
498
+ static unsigned int
499
+ build_netname_ctxt (struct smb2_netname_neg_context * pneg_ctxt , char * hostname )
500
+ {
501
+ struct nls_table * cp = load_nls_default ();
502
+
503
+ pneg_ctxt -> ContextType = SMB2_NETNAME_NEGOTIATE_CONTEXT_ID ;
504
+
505
+ /* copy up to max of first 100 bytes of server name to NetName field */
506
+ pneg_ctxt -> DataLength = cpu_to_le16 (2 +
507
+ (2 * cifs_strtoUTF16 (pneg_ctxt -> NetName , hostname , 100 , cp )));
508
+ /* context size is DataLength + minimal smb2_neg_context */
509
+ return DIV_ROUND_UP (le16_to_cpu (pneg_ctxt -> DataLength ) +
510
+ sizeof (struct smb2_neg_context ), 8 ) * 8 ;
511
+ }
512
+
498
513
static void
499
514
build_posix_ctxt (struct smb2_posix_neg_context * pneg_ctxt )
500
515
{
@@ -559,9 +574,15 @@ assemble_neg_contexts(struct smb2_negotiate_req *req,
559
574
8 ) * 8 ;
560
575
* total_len += ctxt_len ;
561
576
pneg_ctxt += ctxt_len ;
562
- req -> NegotiateContextCount = cpu_to_le16 (4 );
577
+ req -> NegotiateContextCount = cpu_to_le16 (5 );
563
578
} else
564
- req -> NegotiateContextCount = cpu_to_le16 (3 );
579
+ req -> NegotiateContextCount = cpu_to_le16 (4 );
580
+
581
+ ctxt_len = build_netname_ctxt ((struct smb2_netname_neg_context * )pneg_ctxt ,
582
+ server -> hostname );
583
+ * total_len += ctxt_len ;
584
+ pneg_ctxt += ctxt_len ;
585
+
565
586
build_posix_ctxt ((struct smb2_posix_neg_context * )pneg_ctxt );
566
587
* total_len += sizeof (struct smb2_posix_neg_context );
567
588
}
0 commit comments