~ubuntu-branches/ubuntu/oneiric/likewise-open/oneiric

« back to all changes in this revision

Viewing changes to lwio/server/srv/protocols/smb1/libmain.c

  • Committer: Bazaar Package Importer
  • Author(s): Scott Salley
  • Date: 2010-11-22 12:06:00 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20101122120600-8lba1fpceot71wlb
Tags: 6.0.0.53010-1
Likewise Open 6.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
90
90
{
91
91
    NTSTATUS ntStatus = STATUS_SUCCESS;
92
92
    PSRV_EXEC_CONTEXT_SMB_V1 pSmb1Context = NULL;
 
93
    UCHAR    ucCurrentCommand = 0;
 
94
    BOOLEAN  bPopStatMessage  = FALSE;
93
95
 
94
96
    if (!pExecContext->pProtocolContext->pSmb1Context)
95
97
    {
184
186
                         SrvGetCommandDescription_SMB_V1(pRequest->ucCommand),
185
187
                         pRequest->ucCommand);
186
188
 
 
189
        if (pExecContext->pStatInfo)
 
190
        {
 
191
            ucCurrentCommand = pRequest->ucCommand;
 
192
 
 
193
            ntStatus = SrvStatisticsPushMessage(
 
194
                            pExecContext->pStatInfo,
 
195
                            ucCurrentCommand,
 
196
                            pRequest->ulMessageSize);
 
197
            BAIL_ON_NT_STATUS(ntStatus);
 
198
 
 
199
            bPopStatMessage = TRUE;
 
200
        }
 
201
 
187
202
        switch (pRequest->ucCommand)
188
203
        {
189
204
            case COM_NEGOTIATE:
457
472
                    /* Terminate the chain */
458
473
                    if (pPrevResponse->pAndXHeader)
459
474
                    {
460
 
                        pPrevResponse->pAndXHeader->andXCommand = 0xFF;
 
475
                        pPrevResponse->pAndXHeader->andXCommand =
 
476
                            COM_NO_ANDX_COMMAND;
461
477
                        pPrevResponse->pAndXHeader->andXOffset = 0;
462
478
                    }
463
479
 
483
499
        }
484
500
 
485
501
        pExecContext->pSmbResponse->bufferUsed += pResponse->ulMessageSize;
 
502
 
 
503
        if (bPopStatMessage)
 
504
        {
 
505
            NTSTATUS ntStatus2 =
 
506
                    SrvStatisticsPopMessage(
 
507
                            pExecContext->pStatInfo,
 
508
                            ucCurrentCommand,
 
509
                            (pResponse->ulMessageSize ?
 
510
                                    pResponse->ulMessageSize :
 
511
                                    pResponse->ulZctMessageSize),
 
512
                            ntStatus);
 
513
            if (ntStatus2)
 
514
            {
 
515
                LWIO_LOG_ERROR( "Error: Failed to notify statistics "
 
516
                                "module on end of message processing "
 
517
                                "[error: %u]", ntStatus2);
 
518
            }
 
519
 
 
520
            bPopStatMessage = FALSE;
 
521
            ucCurrentCommand = 0;
 
522
        }
486
523
    }
487
524
 
488
525
    ntStatus = SMBPacketMarshallFooter(pExecContext->pSmbResponse);
494
531
 
495
532
error:
496
533
 
 
534
    switch (ntStatus)
 
535
    {
 
536
        case STATUS_PENDING:
 
537
 
 
538
            break;
 
539
 
 
540
        default:
 
541
 
 
542
            if (bPopStatMessage)
 
543
            {
 
544
                NTSTATUS ntStatus2 =
 
545
                        SrvStatisticsPopMessage(
 
546
                                pExecContext->pStatInfo,
 
547
                                ucCurrentCommand,
 
548
                                pExecContext->pSmbResponse->bufferUsed,
 
549
                                ntStatus);
 
550
                if (ntStatus2)
 
551
                {
 
552
                    LWIO_LOG_ERROR( "Error: Failed to notify statistics "
 
553
                                    "module on end of message processing "
 
554
                                    "[error: %u]", ntStatus2);
 
555
                }
 
556
            }
 
557
 
 
558
            break;
 
559
    }
 
560
 
497
561
    goto cleanup;
498
562
}
499
563
 
500
564
NTSTATUS
 
565
SrvProtocolCloseFile_SMB_V1(
 
566
    PLWIO_SRV_TREE pTree,
 
567
    PLWIO_SRV_FILE pFile
 
568
    )
 
569
{
 
570
    NTSTATUS ntStatus = STATUS_SUCCESS;
 
571
 
 
572
    if (!pTree || !pFile)
 
573
    {
 
574
        ntStatus = STATUS_INVALID_PARAMETER;
 
575
        BAIL_ON_NT_STATUS(ntStatus);
 
576
    }
 
577
 
 
578
    SrvFileResetOplockState(pFile);
 
579
 
 
580
    ntStatus = SrvTreeRemoveFile(
 
581
                    pTree,
 
582
                    pFile->fid);
 
583
    BAIL_ON_NT_STATUS(ntStatus);
 
584
 
 
585
    SrvFileCancelAsyncOperations(pTree, pFile);
 
586
 
 
587
    SrvFileRundown(pFile);
 
588
 
 
589
error:
 
590
 
 
591
    return ntStatus;
 
592
}
 
593
 
 
594
NTSTATUS
501
595
SrvBuildExecContext_SMB_V1(
502
596
    PLWIO_SRV_CONNECTION      pConnection,
503
597
    PSMB_PACKET               pSmbRequest,
569
663
        {
570
664
            switch (pAndXHeader->andXCommand)
571
665
            {
572
 
                case 0xFF:
 
666
                case COM_NO_ANDX_COMMAND:
573
667
 
574
668
                    pBuffer = NULL;
575
669
 
663
757
                break;
664
758
        }
665
759
 
666
 
        if (pMessage->pAndXHeader && pMessage->pAndXHeader->andXOffset)
 
760
        if (pMessage->pAndXHeader &&
 
761
            pMessage->pAndXHeader->andXOffset &&
 
762
            pMessage->pAndXHeader->andXCommand != COM_NO_ANDX_COMMAND)
667
763
        {
668
764
            ucAndXCommand = pMessage->pAndXHeader->andXCommand;
669
765
 
870
966
    goto cleanup;
871
967
}
872
968
 
873
 
NTSTATUS
 
969
VOID
874
970
SrvProtocolShutdown_SMB_V1(
875
971
    VOID
876
972
    )
877
973
{
878
 
    NTSTATUS status = STATUS_SUCCESS;
879
974
    BOOLEAN bInLock = FALSE;
880
975
 
881
976
    LWIO_LOCK_MUTEX(bInLock, &gProtocolGlobals_SMB_V1.mutex);
887
982
    /* Configuration shutdown should always come last as other shutdown
888
983
     * routines may rely on configuration parameters to be set */
889
984
    SrvConfigShutdown_SMB_V1();
890
 
 
891
 
    return status;
892
985
}
893
986
 
894
987
static