1 /*
2  * Copyright (c) 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 #include "dslm_test_link.h"
16 
17 #include "socket.h"
18 
UtGetDeviceSocketManagerInstance(void)19 DeviceSocketManager *UtGetDeviceSocketManagerInstance(void)
20 {
21     return GetDeviceSocketManagerInstance();
22 }
23 
UtProcessSocketMessageReceived(const uint8_t *data, uint32_t len)24 void UtProcessSocketMessageReceived(const uint8_t *data, uint32_t len)
25 {
26     ProcessSocketMessageReceived(data, len);
27 }
28 
UtRemoveSocketNode(int32_t socket, ShutdownReason reason, bool isServer)29 void UtRemoveSocketNode(int32_t socket, ShutdownReason reason, bool isServer)
30 {
31     RemoveSocketNode(socket, reason, isServer);
32 }
33 
UtOnSocketMessageReceived(const DeviceIdentify *devId, const uint8_t *msg, uint32_t msgLen)34 void UtOnSocketMessageReceived(const DeviceIdentify *devId, const uint8_t *msg, uint32_t msgLen)
35 {
36     OnSocketMessageReceived(devId, msg, msgLen);
37 }
38 
UtGetIdentityBySocketId(int32_t socket, bool isServer, DeviceIdentify *identity)39 bool UtGetIdentityBySocketId(int32_t socket, bool isServer, DeviceIdentify *identity)
40 {
41     return GetIdentityBySocketId(socket, isServer, identity);
42 }
43 
UtServerOnBind(int32_t socket, PeerSocketInfo info)44 void UtServerOnBind(int32_t socket, PeerSocketInfo info)
45 {
46     ServerOnBind(socket, info);
47 }
48 
UtClientOnBind(int socket, const DeviceIdentify *devId)49 void UtClientOnBind(int socket, const DeviceIdentify *devId)
50 {
51     ClientOnBind(socket, devId);
52 }
53 
UtServerOnShutdown(int32_t socket, ShutdownReason reason)54 void UtServerOnShutdown(int32_t socket, ShutdownReason reason)
55 {
56     ServerOnShutdown(socket, reason);
57 }
58 
UtClientOnShutdown(int32_t socket, ShutdownReason reason)59 void UtClientOnShutdown(int32_t socket, ShutdownReason reason)
60 {
61     ClientOnShutdown(socket, reason);
62 }
63 
UtTimerProcessWaitingTimeOut(const void *context)64 void UtTimerProcessWaitingTimeOut(const void *context)
65 {
66     TimerProcessWaitingTimeOut(context);
67 }
68 
UtCreateOrRestartSocketCloseTimerWithLock(int32_t socket)69 void UtCreateOrRestartSocketCloseTimerWithLock(int32_t socket)
70 {
71     CreateOrRestartSocketCloseTimerWithLock(socket);
72 }
73 
UtGetIdentityByServerSocket(int32_t socket, DeviceIdentify *identity)74 bool UtGetIdentityByServerSocket(int32_t socket, DeviceIdentify *identity)
75 {
76     return GetIdentityByServerSocket(socket, identity);
77 }
78 
UtGetIdentityByClientSocket(int32_t socket, DeviceIdentify *identity)79 bool UtGetIdentityByClientSocket(int32_t socket, DeviceIdentify *identity)
80 {
81     return GetIdentityByClientSocket(socket, identity);
82 }
83 
UtCreateSocketNodeInfo(int32_t socket, const DeviceIdentify *identity)84 SocketNodeInfo *UtCreateSocketNodeInfo(int32_t socket, const DeviceIdentify *identity)
85 {
86     return CreateSocketNodeInfo(socket, identity);
87 }
88 
UtServerOnBytes(int32_t socket, const void *data, unsigned int dataLen)89 void UtServerOnBytes(int32_t socket, const void *data, unsigned int dataLen)
90 {
91     ServerOnBytes(socket, data, dataLen);
92 }
93 
UtClientOnBytes(int32_t socket, const void *data, unsigned int dataLen)94 void UtClientOnBytes(int32_t socket, const void *data, unsigned int dataLen)
95 {
96     ClientOnBytes(socket, data, dataLen);
97 }
98 
UtCreateServer(DeviceSocketManager *inst)99 bool UtCreateServer(DeviceSocketManager *inst)
100 {
101     return CreateServer(inst);
102 }
103 
UtBindSync(int32_t socket, const DeviceIdentify *devId)104 bool UtBindSync(int32_t socket, const DeviceIdentify *devId)
105 {
106     return BindSync(socket, devId);
107 }
108 
UtGetClientName(char *clientName, const char *name, uint32_t maskId, bool isSame)109 int32_t UtGetClientName(char *clientName, const char *name, uint32_t maskId, bool isSame)
110 {
111     return GetClientName(clientName, name, maskId, isSame);
112 }
113 
UtGetSocketBySocketList(const DeviceIdentify *devId, bool isServer, int32_t *socket)114 bool UtGetSocketBySocketList(const DeviceIdentify *devId, bool isServer, int32_t *socket)
115 {
116     return GetSocketBySocketList(devId, isServer, socket);
117 }
118 
UtPushMsgDataToPendingList(uint32_t transNo, const DeviceIdentify *devId, const uint8_t *msg, uint32_t msgLen)119 void UtPushMsgDataToPendingList(uint32_t transNo, const DeviceIdentify *devId, const uint8_t *msg, uint32_t msgLen)
120 {
121     PushMsgDataToPendingList(transNo, devId, msg, msgLen);
122 }