1 /* 2 * Copyright (C) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef NSTACKX_DFILE_MP_H 17 #define NSTACKX_DFILE_MP_H 18 #include "nstackx_dfile_session.h" 19 #include "nstackx_dfile_transfer.h" 20 #ifdef __cplusplus 21 extern "C" { 22 #endif 23 24 typedef struct { 25 DFileSession *session; 26 uint8_t socketIndex; 27 } SenderThreadPara; 28 29 typedef struct { 30 List list; 31 DFileTrans *trans; 32 int16_t status; 33 uint16_t deleted; 34 uint16_t vtransId; 35 } DFileVtrans; 36 37 typedef struct { 38 uint8_t fileCreated; 39 char newfileName[NSTACKX_MAX_REMOTE_PATH_LEN]; 40 } RealFileInfo; 41 42 typedef struct { 43 List list; 44 uint16_t vtransRealTransId; 45 uint16_t vtransTotalNum; 46 uint16_t vtransFinishedNum; 47 RealFileInfo *realFileInfo; 48 List vtransListHead; 49 } DFileVtransManager; 50 51 typedef struct { 52 const char *files[NSTACKX_MAX_FILE_LIST_NUM]; 53 const char *remotePath[NSTACKX_MAX_FILE_LIST_NUM]; 54 uint64_t fileSize[NSTACKX_MAX_FILE_LIST_NUM]; 55 uint64_t startOffset[NSTACKX_MAX_FILE_LIST_NUM]; 56 uint16_t realFileId[NSTACKX_MAX_FILE_LIST_NUM]; 57 uint16_t realTransId; 58 uint16_t totalFileNum; 59 uint16_t transNum; 60 uint64_t totalFileSize; 61 } DFileRebuildFileList; 62 63 typedef struct { 64 const char *file; 65 const char *remotePath; 66 uint64_t totalFileSize; 67 uint64_t vFileSize; 68 uint64_t offset; 69 uint64_t vtranSize; 70 uint16_t realFileId; 71 } VFilePara; 72 73 int32_t DFileSocketRecvSP(DFileSession *session); 74 PeerInfo *TransSelectPeerInfo(DFileSession *session); 75 PeerInfo *ClientGetPeerInfoByTransId(DFileSession *session); 76 PeerInfo *ClientGetPeerInfoBySocketIndex(uint8_t socketIndex, const DFileSession *session); 77 int32_t CreateSenderThread(DFileSession *session); 78 int32_t RebuildFilelist(const char *files[], const char *remotePath[], uint32_t fileNum, 79 DFileSession *session, DFileRebuildFileList *rebuildList); 80 int32_t InitOutboundQueueWait(DFileSession *session); 81 void DestroyOutboundQueueWait(DFileSession *session); 82 void PostOutboundQueueWait(DFileSession *session); 83 84 #ifdef __cplusplus 85 } 86 #endif 87 #endif // NSTACKX_DFILE_MP_H 88