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