Leaked source code of windows server 2003

775 lines
26 KiB

  1. //---------------------------------------------------------------------
  2. // Copyright (c)1998 Microsoft Corporation, All Rights Reserved.
  3. //
  4. // complete.cpp
  5. //
  6. // This is the main for the IrTran-P service.
  7. //---------------------------------------------------------------------
  8. #include "precomp.h"
  9. extern HINSTANCE g_hInst; // Instance of ircamera.dll
  10. extern void *g_pvIrUsdDevice; // Devined: irtranp.cpp
  11. extern CCONNECTION_MAP *g_pConnectionMap; // Defined: irtranp.cpp
  12. extern BOOL ReceivesAllowed(); // Defined: irtranp.cpp
  13. extern BOOL CheckSaveAsUPF(); // Defined: irtranp.cpp
  14. extern DWORD SignalWIA( IN char *pszFileName,
  15. IN void *pvIrUsdDevice ); // see ../device.cpp
  16. //---------------------------------------------------------------------
  17. // Constants:
  18. //---------------------------------------------------------------------
  19. #define DEFAULT_TIMEOUT 10000
  20. //---------------------------------------------------------------------
  21. // ReceiveComplete()
  22. //
  23. //---------------------------------------------------------------------
  24. void ReceiveComplete( IN CCONNECTION *pConnection,
  25. IN DWORD dwStatusCode )
  26. {
  27. DWORD dwError = 0;
  28. if ( (dwStatusCode == NO_ERROR)
  29. || (dwStatusCode == ERROR_SCEP_UNSPECIFIED_DISCONNECT)
  30. || (dwStatusCode == ERROR_SCEP_USER_DISCONNECT)
  31. || (dwStatusCode == ERROR_SCEP_PROVIDER_DISCONNECT) )
  32. {
  33. //
  34. // A new picture has just been received, so we need to signal
  35. // WIA...
  36. //
  37. SignalWIA( pConnection->GetPathPlusFileName(), g_pvIrUsdDevice );
  38. }
  39. }
  40. //---------------------------------------------------------------------
  41. // ProcessConnectRequest()
  42. //
  43. // Called by ProcessClient() when the input PDU message type is
  44. // MSG_TYPE_CONNECT_REQ.
  45. //
  46. // pConnection - The newly established Winsock connection with the
  47. // camera.
  48. //
  49. // pPdu - The SCEP PDU holding the connect request. It was
  50. // allocated in ProcessClient() by AssemblePdu() and
  51. // will always be free'd when ProcessConnectRequest()
  52. // finishes.
  53. //
  54. // dwPduSize - The size of the input PDU in bytes.
  55. //
  56. //---------------------------------------------------------------------
  57. DWORD ProcessConnectRequest( IN CCONNECTION *pConnection,
  58. IN SCEP_HEADER *pPdu,
  59. IN DWORD dwPduSize )
  60. {
  61. DWORD dwStatus;
  62. DWORD dwRespPduSize;
  63. BOOL fReceivesAllowed = ::ReceivesAllowed();
  64. SCEP_HEADER *pRespPdu;
  65. CIOPACKET *pNewIoPacket; // Posted IO packet (by SendPdu()).
  66. CSCEP_CONNECTION *pScepConnection
  67. = (CSCEP_CONNECTION*)pConnection->GetScepConnection();
  68. if (fReceivesAllowed)
  69. {
  70. // Build an connection accept acknowledgement:
  71. dwStatus = pScepConnection->BuildConnectRespPdu(&pRespPdu,
  72. &dwRespPduSize);
  73. }
  74. else
  75. {
  76. // Build a connect NACK:
  77. dwStatus = pScepConnection->BuildConnectNackPdu(&pRespPdu,
  78. &dwRespPduSize);
  79. }
  80. if (dwStatus == NO_ERROR)
  81. {
  82. pConnection->SendPdu(pRespPdu,dwRespPduSize,&pNewIoPacket);
  83. if (pNewIoPacket)
  84. {
  85. pNewIoPacket->SetWritePdu(pRespPdu);
  86. }
  87. else
  88. {
  89. DeletePdu(pRespPdu);
  90. }
  91. if (!fReceivesAllowed)
  92. {
  93. // Note: After sending a NACK, the camera should close
  94. // the connection, but at lease some don't, so I'm
  95. // forced to slam the connection...
  96. pConnection->CloseSocket(); // Was: ShutdownSocket().
  97. }
  98. }
  99. DeletePdu(pPdu);
  100. return dwStatus;
  101. }
  102. //---------------------------------------------------------------------
  103. // ProcessConnectResponse()
  104. //
  105. // Called by ProcessClient() when the input PDU message type is
  106. // MSG_TYPE_CONNECT_RESP.
  107. //
  108. // NOTE: Note implemented in the IrTran-P server, because the server
  109. // is not currently setup to connect to a camera to download
  110. // pictures back to the camera... We should never get this PDU
  111. // during normal operation.
  112. //
  113. // pConnection - The newly established Winsock connection with the
  114. // camera.
  115. //
  116. // pPdu - The SCEP PDU holding the connect request. It was
  117. // allocated in ProcessClient() by AssemblePdu() and
  118. // will always be free'd when ProcessConnectResponse()
  119. // finishes.
  120. //
  121. // dwPduSize - The size of the input PDU in bytes.
  122. //
  123. //---------------------------------------------------------------------
  124. DWORD ProcessConnectResponse( CCONNECTION *pConnection,
  125. SCEP_HEADER *pPdu,
  126. DWORD dwPduSize )
  127. {
  128. DWORD dwStatus = NO_ERROR;
  129. WIAS_TRACE((g_hInst,"ProcessClient(): Unimplemented MSG_TYPE_CONNECT_RESP"));
  130. DeletePdu(pPdu);
  131. return dwStatus;
  132. }
  133. //---------------------------------------------------------------------
  134. // ProcessData()
  135. //
  136. // Called by ProcessClient() when the input PDU message type is
  137. // MSG_TYPE_DATA.
  138. //
  139. // pConnection - The newly established Winsock connection with the
  140. // camera.
  141. //
  142. // pPdu - The SCEP PDU holding the connect request. It was
  143. // allocated in ProcessClient() by AssemblePdu() and
  144. // will always be free'd when ProcessConnectResponse()
  145. // finishes.
  146. //
  147. // dwPduSize - The size of the input PDU in bytes.
  148. //
  149. //---------------------------------------------------------------------
  150. DWORD ProcessData( CCONNECTION *pConnection,
  151. SCEP_HEADER *pPdu,
  152. DWORD dwPduSize,
  153. COMMAND_HEADER *pCommandHeader,
  154. UCHAR *pUserData,
  155. DWORD dwUserDataSize )
  156. {
  157. DWORD dwStatus = NO_ERROR;
  158. DWORD dwRespPduSize;
  159. DWORD dwBftpOp;
  160. UCHAR *pPutData;
  161. DWORD dwPutDataSize;
  162. DWORD dwJpegOffset;
  163. DWORD dwJpegSize;
  164. SCEP_HEADER *pRespPdu;
  165. CIOPACKET *pNewIoPacket; // Posted IO packet (by SendPdu()).
  166. CSCEP_CONNECTION *pScepConnection
  167. = (CSCEP_CONNECTION*)pConnection->GetScepConnection();
  168. // First, check to see if this is an abort PDU, send by the camera:
  169. if ( (pCommandHeader) && (pCommandHeader->PduType == PDU_TYPE_ABORT) )
  170. {
  171. DeletePdu(pPdu);
  172. return ERROR_SCEP_ABORT;
  173. }
  174. // Is one of the 2nd through Nth fragments of a fragmented PDU?
  175. if ( (pScepConnection->IsFragmented())
  176. && (pScepConnection->GetSequenceNo() > 0))
  177. {
  178. #ifdef DBG_IO
  179. WIAS_TRACE((g_hInst,"ProcessClient(): Put Fragment: SequenceNo: %d RestNo: %d", pScepConnection->GetSequenceNo(), pScepConnection->GetRestNo() ));
  180. #endif
  181. pConnection->WritePictureFile( pUserData,
  182. dwUserDataSize,
  183. &pNewIoPacket );
  184. if (pNewIoPacket)
  185. {
  186. pNewIoPacket->SetWritePdu(pPdu);
  187. }
  188. else
  189. {
  190. DeletePdu(pPdu);
  191. }
  192. if (pScepConnection->GetDFlag() == DFLAG_LAST_FRAGMENT)
  193. {
  194. pScepConnection->BuildPutRespPdu( PDU_TYPE_REPLY_ACK,
  195. ERROR_PUT_NO_ERROR,
  196. &pRespPdu,
  197. &dwRespPduSize);
  198. pConnection->SendPdu( pRespPdu,
  199. dwRespPduSize,
  200. &pNewIoPacket);
  201. if (pNewIoPacket)
  202. {
  203. pNewIoPacket->SetWritePdu(pRespPdu);
  204. }
  205. else
  206. {
  207. DeletePdu(pRespPdu);
  208. }
  209. }
  210. }
  211. else if (pCommandHeader)
  212. {
  213. // Length4 in the COMMAN_HEADER is the user data size
  214. // plus the bytes for machine ids (16), the DestPid (2),
  215. // SrcPid (2) and CommandId (2) so offset by 22.
  216. dwStatus = pScepConnection->ParseBftp( pUserData,
  217. dwUserDataSize,
  218. pConnection->CheckSaveAsUPF(),
  219. &dwBftpOp,
  220. &pPutData,
  221. &dwPutDataSize );
  222. if ((dwStatus == NO_ERROR) && (IsBftpQuery(dwBftpOp)))
  223. {
  224. pScepConnection->BuildWht0RespPdu(dwBftpOp,
  225. &pRespPdu,
  226. &dwRespPduSize);
  227. pConnection->SendPdu( pRespPdu,
  228. dwRespPduSize,
  229. &pNewIoPacket );
  230. if (pNewIoPacket)
  231. {
  232. pNewIoPacket->SetWritePdu(pRespPdu);
  233. }
  234. else
  235. {
  236. DeletePdu(pRespPdu);
  237. }
  238. DeletePdu(pPdu);
  239. }
  240. else if ((dwStatus == NO_ERROR) && (IsBftpPut(dwBftpOp)))
  241. {
  242. //
  243. // Ok, we have a bFTP PUT command, so open a file
  244. // and get ready to start collecting image data.
  245. //
  246. dwStatus = pScepConnection->ParseUpfHeaders( pPutData,
  247. dwPutDataSize,
  248. &dwJpegOffset,
  249. &dwJpegSize );
  250. pConnection->SetJpegOffsetAndSize(dwJpegOffset,dwJpegSize);
  251. dwStatus = pConnection->Impersonate();
  252. dwStatus = pConnection->CreatePictureFile();
  253. dwStatus = pConnection->SetPictureFileTime( pScepConnection->GetCreateTime() );
  254. dwStatus = pConnection->RevertToSelf();
  255. dwStatus = pConnection->WritePictureFile( pPutData,
  256. dwPutDataSize,
  257. &pNewIoPacket );
  258. if (pNewIoPacket)
  259. {
  260. pNewIoPacket->SetWritePdu(pPdu);
  261. }
  262. else
  263. {
  264. DeletePdu(pPdu);
  265. }
  266. }
  267. else if (IsBftpError(dwBftpOp))
  268. {
  269. #ifdef DBG_ERROR
  270. WIAS_ERROR((g_hInst,"ProcessClient(): bFTP Error: %d", dwStatus));
  271. #endif
  272. DeletePdu(pPdu);
  273. dwStatus = ERROR_BFTP_INVALID_PROTOCOL;
  274. }
  275. else
  276. {
  277. #ifdef DBG_ERROR
  278. WIAS_ERROR((g_hInst,"ProcessClient(): Unknown bFTP Command: %d",dwBftpOp));
  279. #endif
  280. DeletePdu(pPdu);
  281. dwStatus = ERROR_BFTP_INVALID_PROTOCOL;
  282. }
  283. }
  284. return dwStatus;
  285. }
  286. //---------------------------------------------------------------------
  287. // ProcessDisconnect()
  288. //
  289. // Called by ProcessClient() when the input PDU message type is
  290. // MSG_TYPE_DISCONNECT.
  291. //
  292. // pConnection - The newly established Winsock connection with the
  293. // camera.
  294. //
  295. // pPdu - The SCEP PDU holding the connect request. It was
  296. // allocated in ProcessClient() by AssemblePdu() and
  297. // will always be free'd when ProcessConnectResponse()
  298. // finishes.
  299. //
  300. // dwPduSize - The size of the input PDU in bytes.
  301. //
  302. //---------------------------------------------------------------------
  303. DWORD ProcessDisconnect( CCONNECTION *pConnection,
  304. SCEP_HEADER *pPdu,
  305. DWORD dwPduSize )
  306. {
  307. DWORD dwStatus = NO_ERROR;
  308. // Don't need to do anything special here, since
  309. // ParsePdu() will set dwStatus to one of:
  310. // ERROR_SCEP_UNSPECIFIED_DISCONNECT (5002)
  311. // ERROR_SCEP_USER_DISCONNECT (5003)
  312. // or ERROR_SCEP_PROVIDER_DISCONNECT (5004)
  313. pConnection->SetReceiveComplete(TRUE);
  314. DeletePdu(pPdu);
  315. return dwStatus;
  316. }
  317. //---------------------------------------------------------------------
  318. // ProcessClient() Synchronous Version
  319. //
  320. //---------------------------------------------------------------------
  321. DWORD ProcessClient( CIOSTATUS *pIoStatus,
  322. CCONNECTION *pConnection,
  323. char *pBuffer,
  324. DWORD dwNumBytes )
  325. {
  326. DWORD dwStatus = NO_ERROR;
  327. CSCEP_CONNECTION *pScepConnection;
  328. SCEP_HEADER *pPdu;
  329. DWORD dwPduSize;
  330. COMMAND_HEADER *pCommandHeader;
  331. UCHAR *pUserData; // Location of bFTP data.
  332. DWORD dwUserDataSize;
  333. DWORD dwError = 0;
  334. pScepConnection = (CSCEP_CONNECTION*)pConnection->GetScepConnection();
  335. WIAS_ASSERT(g_hInst,pScepConnection!=NULL);
  336. while (dwStatus == NO_ERROR)
  337. {
  338. dwStatus = pScepConnection->AssemblePdu( pBuffer,
  339. dwNumBytes,
  340. &pPdu,
  341. &dwPduSize );
  342. if (dwStatus == NO_ERROR)
  343. {
  344. dwStatus = pScepConnection->ParsePdu( pPdu,
  345. dwPduSize,
  346. &pCommandHeader,
  347. &pUserData,
  348. &dwUserDataSize );
  349. switch (pPdu->MsgType)
  350. {
  351. case MSG_TYPE_CONNECT_REQ:
  352. //
  353. // Message was an SCEP Connection Request:
  354. //
  355. dwStatus = ProcessConnectRequest(pConnection,
  356. pPdu,
  357. dwPduSize );
  358. if ((dwStatus) || (!ReceivesAllowed()))
  359. {
  360. pConnection->ClosePictureFile();
  361. ReceiveComplete(pConnection,dwStatus);
  362. }
  363. else
  364. {
  365. pConnection->StartProgress();
  366. }
  367. break;
  368. case MSG_TYPE_CONNECT_RESP:
  369. // Message was a reply from a connection request:
  370. dwStatus = ProcessConnectResponse(pConnection,
  371. pPdu,
  372. dwPduSize );
  373. break;
  374. case MSG_TYPE_DATA:
  375. // Message is a SCEP command of some sort:
  376. dwStatus = ProcessData(pConnection,
  377. pPdu,
  378. dwPduSize,
  379. pCommandHeader,
  380. pUserData,
  381. dwUserDataSize );
  382. pConnection->UpdateProgress();
  383. break;
  384. case MSG_TYPE_DISCONNECT:
  385. // Message from the camera was a disconnect:
  386. ProcessDisconnect(pConnection,
  387. pPdu,
  388. dwPduSize );
  389. pConnection->ClosePictureFile();
  390. ReceiveComplete(pConnection,dwStatus);
  391. pConnection->EndProgress();
  392. break;
  393. default:
  394. #ifdef DBG_ERROR
  395. WIAS_ERROR((g_hInst,"ProcessClient(): Unknown MSG_TYPE_xxx: %d", pPdu->MsgType));
  396. #endif
  397. DeletePdu(pPdu);
  398. pConnection->EndProgress();
  399. break;
  400. }
  401. }
  402. else
  403. {
  404. break;
  405. }
  406. pBuffer = 0;
  407. dwNumBytes = 0;
  408. }
  409. if (dwStatus == ERROR_CONTINUE)
  410. {
  411. dwStatus = NO_ERROR;
  412. }
  413. return dwStatus;
  414. }
  415. //---------------------------------------------------------------------
  416. // SendAbortPdu()
  417. //
  418. // Stop the camera.
  419. //
  420. // I should be able to send a Stop PDU, followed by a Disconnect, or
  421. // maybe an Abort PDU, but these don't work on all the cameras, so I
  422. // currently end up just doing a hard close on the connection to the
  423. // camera.
  424. //---------------------------------------------------------------------
  425. DWORD SendAbortPdu( IN CCONNECTION *pConnection )
  426. {
  427. DWORD dwStatus = NO_ERROR;
  428. #if TRUE
  429. pConnection->CloseSocket();
  430. #else
  431. DWORD dwPduSize;
  432. SCEP_HEADER *pPdu;
  433. CIOPACKET *pNewIoPacket = 0;
  434. CSCEP_CONNECTION *pScepConnection
  435. = (CSCEP_CONNECTION*)pConnection->GetScepConnection();
  436. if (pScepConnection)
  437. {
  438. dwStatus = pScepConnection->BuildStopPdu(&pPdu,&dwPduSize);
  439. if (dwStatus != NO_ERROR)
  440. {
  441. pConnection->CloseSocket();
  442. return dwStatus;
  443. }
  444. dwStatus = pConnection->SendPdu(pPdu,dwPduSize,&pNewIoPacket);
  445. if (dwStatus != NO_ERROR)
  446. {
  447. DeletePdu(pPdu);
  448. pConnection->CloseSocket();
  449. return dwStatus;
  450. }
  451. if (pNewIoPacket)
  452. {
  453. pNewIoPacket->SetWritePdu(pPdu);
  454. }
  455. dwStatus = pScepConnection->BuildDisconnectPdu(
  456. REASON_CODE_PROVIDER_DISCONNECT,
  457. &pPdu,
  458. &dwPduSize);
  459. if (dwStatus != NO_ERROR)
  460. {
  461. pConnection->CloseSocket();
  462. return dwStatus;
  463. }
  464. dwStatus = pConnection->SendPdu(pPdu,dwPduSize,&pNewIoPacket);
  465. if (dwStatus != NO_ERROR)
  466. {
  467. DeletePdu(pPdu);
  468. pConnection->CloseSocket();
  469. return dwStatus;
  470. }
  471. if (pNewIoPacket)
  472. {
  473. pNewIoPacket->SetWritePdu(pPdu);
  474. }
  475. }
  476. #endif
  477. return dwStatus;
  478. }
  479. //---------------------------------------------------------------------
  480. // MapStatusCode()
  481. //
  482. //---------------------------------------------------------------------
  483. DWORD MapStatusCode( DWORD dwStatus,
  484. DWORD dwDefaultStatus )
  485. {
  486. // The Facility part of an error code are the first 12 bits of the
  487. // high word (16bits):
  488. #define FACILITY_MASK 0x0FFF0000
  489. // If the error code is already an IrTran-P error code, then don't
  490. // remap it:
  491. if ( ((dwStatus&FACILITY_MASK) >> 16) == FACILITY_IRTRANP)
  492. {
  493. return dwStatus;
  494. }
  495. // Map other errors:
  496. if (dwStatus != NO_ERROR)
  497. {
  498. if ( (dwStatus == ERROR_DISK_FULL)
  499. || (dwStatus == ERROR_WRITE_FAULT)
  500. || (dwStatus == ERROR_WRITE_PROTECT)
  501. || (dwStatus == ERROR_GEN_FAILURE)
  502. || (dwStatus == ERROR_NOT_DOS_DISK) )
  503. {
  504. dwStatus = ERROR_IRTRANP_DISK_FULL;
  505. }
  506. else
  507. {
  508. dwStatus = dwDefaultStatus;
  509. }
  510. }
  511. return dwStatus;
  512. }
  513. //---------------------------------------------------------------------
  514. // ProcessIoPackets() Synchronous Version
  515. //
  516. //---------------------------------------------------------------------
  517. DWORD ProcessIoPackets( CIOSTATUS *pIoStatus )
  518. {
  519. DWORD dwStatus = NO_ERROR;
  520. DWORD dwProcessStatus = NO_ERROR; // Processing IO status.
  521. DWORD dwNumBytes;
  522. DWORD dwState;
  523. SOCKET Socket = INVALID_SOCKET;
  524. CCONNECTION *pConnection;
  525. CCONNECTION *pNewConnection;
  526. CSCEP_CONNECTION *pScepConnection;
  527. DWORD dwKind = PACKET_KIND_LISTEN;
  528. int iCount;
  529. while (TRUE)
  530. {
  531. if (dwKind == PACKET_KIND_LISTEN)
  532. {
  533. dwState = 0;
  534. Socket = g_pConnectionMap->ReturnNextSocket(&dwState);
  535. pConnection = g_pConnectionMap->Lookup(Socket);
  536. if (!pConnection)
  537. {
  538. #ifdef DBG_ERROR
  539. WIAS_ERROR((g_hInst,"ProcessIoPackets(): Lookup(%d) Failed."));
  540. #endif
  541. continue;
  542. }
  543. //
  544. // New connection:
  545. //
  546. SOCKET NewSocket = accept(Socket,NULL,NULL);
  547. if (NewSocket == INVALID_SOCKET)
  548. {
  549. dwStatus = WSAGetLastError();
  550. #ifdef DBG_ERROR
  551. WIAS_ERROR((g_hInst,"ProcessIoPackets(): Accept() failed: %d",dwStatus));
  552. #endif
  553. break;
  554. }
  555. WIAS_TRACE((g_hInst,"ProcessIoPackets(): Accept(): Socket: %d",NewSocket));
  556. pScepConnection = new CSCEP_CONNECTION;
  557. if (!pScepConnection)
  558. {
  559. #ifdef DBG_ERROR
  560. WIAS_ERROR((g_hInst,"ProcessIoPackets(): Out of memeory on allocate of new SCEP connection object."));
  561. #endif
  562. closesocket(NewSocket);
  563. continue;
  564. }
  565. pNewConnection = new CCONNECTION(
  566. PACKET_KIND_READ,
  567. NewSocket,
  568. NULL, // No IO Completion port...
  569. pScepConnection,
  570. ::CheckSaveAsUPF() );
  571. if (!pNewConnection)
  572. {
  573. #ifdef DBG_ERROR
  574. WIAS_ERROR((g_hInst,"ProcessIoPackets(): Out of memeory on allocate of new connection object."));
  575. #endif
  576. delete pScepConnection;
  577. closesocket(NewSocket);
  578. continue;
  579. }
  580. g_pConnectionMap->Add(pNewConnection,
  581. pNewConnection->GetSocket() );
  582. Socket = NewSocket;
  583. dwKind = PACKET_KIND_READ;
  584. }
  585. else
  586. {
  587. //
  588. // Incomming data from connected client:
  589. //
  590. DWORD dwFlags = 0;
  591. char ReadBuffer[DEFAULT_READ_BUFFER_SIZE];
  592. int iReadBufferSize = DEFAULT_READ_BUFFER_SIZE;
  593. pConnection = g_pConnectionMap->Lookup(Socket);
  594. if (!pConnection)
  595. {
  596. #ifdef DBG_ERROR
  597. WIAS_ERROR((g_hInst,"ProcessIoPackets(): Lookup(%d) Failed."));
  598. #endif
  599. dwKind = PACKET_KIND_LISTEN;
  600. continue;
  601. }
  602. iCount = recv(Socket,ReadBuffer,iReadBufferSize,dwFlags);
  603. if (iCount == SOCKET_ERROR)
  604. {
  605. //
  606. // Error on Recv().
  607. //
  608. dwStatus = WSAGetLastError();
  609. #ifdef DBG_ERROR
  610. WIAS_ERROR((g_hInst,"ProcessIoPackets(): Recv() failed: %d",dwStatus));
  611. #endif
  612. g_pConnectionMap->Remove(Socket);
  613. delete pConnection;
  614. dwKind = PACKET_KIND_LISTEN;
  615. continue;
  616. }
  617. if (iCount == 0)
  618. {
  619. //
  620. // Graceful close.
  621. //
  622. g_pConnectionMap->Remove(Socket);
  623. delete pConnection;
  624. dwKind = PACKET_KIND_LISTEN;
  625. continue;
  626. }
  627. WIAS_ASSERT(g_hInst, iCount>0 );
  628. dwNumBytes = iCount;
  629. dwProcessStatus
  630. = ProcessClient(pIoStatus,
  631. pConnection,
  632. ReadBuffer,
  633. dwNumBytes);
  634. if (dwProcessStatus != NO_ERROR)
  635. {
  636. #ifdef DBG_ERROR
  637. if ( (dwProcessStatus != ERROR_SCEP_UNSPECIFIED_DISCONNECT)
  638. && (dwProcessStatus != ERROR_SCEP_USER_DISCONNECT)
  639. && (dwProcessStatus != ERROR_SCEP_PROVIDER_DISCONNECT) )
  640. {
  641. WIAS_ERROR((g_hInst,"ProcessIoPackets(): ProcessClient(): Failed: 0x%x",dwProcessStatus));
  642. }
  643. #endif
  644. SendAbortPdu(pConnection);
  645. pConnection->ClosePictureFile();
  646. pConnection->EndProgress();
  647. pConnection->DeletePictureFile();
  648. g_pConnectionMap->Remove(Socket);
  649. delete pConnection;
  650. dwProcessStatus = MapStatusCode(
  651. dwProcessStatus,
  652. ERROR_SCEP_INVALID_PROTOCOL );
  653. // pConnection->ClosePictureFile();
  654. // ReceiveComplete(pConnection,dwProcessStatus);
  655. dwKind = PACKET_KIND_LISTEN;
  656. }
  657. }
  658. }
  659. return 0;
  660. }