1 /*
2  * Copyright (c) 2024-2024 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 DSLM_UNIT_TEST_LINK_LIB_TEST_H
17 #define DSLM_UNIT_TEST_LINK_LIB_TEST_H
18 
19 #ifdef __cplusplus
20 #include <cstdint>
21 #else
22 #include <stdint.h>
23 #endif
24 
25 #include "messenger_device_socket_manager.h"
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 typedef struct DeviceSocketManager DeviceSocketManager;
31 typedef struct SocketNodeInfo SocketNodeInfo;
32 
33 DeviceSocketManager *UtGetDeviceSocketManagerInstance(void);
34 
35 void UtProcessSocketMessageReceived(const uint8_t *data, uint32_t len);
36 
37 void UtRemoveSocketNode(int32_t socket, ShutdownReason reason, bool isServer);
38 
39 void UtOnSocketMessageReceived(const DeviceIdentify *devId, const uint8_t *msg, uint32_t msgLen);
40 
41 bool UtGetIdentityBySocketId(int32_t socket, bool isServer, DeviceIdentify *identity);
42 
43 void UtServerOnBind(int32_t socket, PeerSocketInfo info);
44 
45 void UtClientOnBind(int socket, const DeviceIdentify *devId);
46 
47 void UtServerOnShutdown(int32_t socket, ShutdownReason reason);
48 
49 void UtClientOnShutdown(int32_t socket, ShutdownReason reason);
50 
51 void UtTimerProcessWaitingTimeOut(const void *context);
52 
53 void UtCreateOrRestartSocketCloseTimerWithLock(int32_t socket);
54 
55 bool UtGetIdentityByServerSocket(int32_t socket, DeviceIdentify *identity);
56 
57 bool UtGetIdentityByClientSocket(int32_t socket, DeviceIdentify *identity);
58 
59 SocketNodeInfo *UtCreateSocketNodeInfo(int32_t socket, const DeviceIdentify *identity);
60 
61 void UtServerOnBytes(int32_t socket, const void *data, unsigned int dataLen);
62 
63 void UtClientOnBytes(int32_t socket, const void *data, unsigned int dataLen);
64 
65 bool UtCreateServer(DeviceSocketManager *inst);
66 
67 bool UtBindSync(int32_t socket, const DeviceIdentify *devId);
68 
69 int32_t UtGetClientName(char *clientName, const char *name, uint32_t maskId, bool isSame);
70 
71 bool UtGetSocketBySocketList(const DeviceIdentify *devId, bool isServer, int32_t *socket);
72 
73 void UtPushMsgDataToPendingList(uint32_t transNo, const DeviceIdentify *devId, const uint8_t *msg, uint32_t msgLen);
74 
75 #ifdef __cplusplus
76 }
77 #endif
78 
79 #endif // DSLM_UNIT_TEST_LINK_LIB_TEST_H