10704ebd2Sopenharmony_ci/*
20704ebd2Sopenharmony_ci * Copyright (c) 2021 Huawei Device Co., Ltd.
30704ebd2Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
40704ebd2Sopenharmony_ci * you may not use this file except in compliance with the License.
50704ebd2Sopenharmony_ci * You may obtain a copy of the License at
60704ebd2Sopenharmony_ci *
70704ebd2Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
80704ebd2Sopenharmony_ci *
90704ebd2Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
100704ebd2Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
110704ebd2Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
120704ebd2Sopenharmony_ci * See the License for the specific language governing permissions and
130704ebd2Sopenharmony_ci * limitations under the License.
140704ebd2Sopenharmony_ci */
150704ebd2Sopenharmony_ci
160704ebd2Sopenharmony_ci#include <gtest/gtest.h>
170704ebd2Sopenharmony_ci
180704ebd2Sopenharmony_ci#include "net_trans_common.h"
190704ebd2Sopenharmony_ci#include "wifi_utils.h"
200704ebd2Sopenharmony_ci#include "accesstoken_kit.h"
210704ebd2Sopenharmony_ci
220704ebd2Sopenharmony_ciusing namespace std;
230704ebd2Sopenharmony_ciusing namespace testing::ext;
240704ebd2Sopenharmony_ci
250704ebd2Sopenharmony_cistatic INodeStateCb* g_nodeStateCallback = NULL;
260704ebd2Sopenharmony_cistatic ISessionListener* g_sessionlist4Data = NULL;
270704ebd2Sopenharmony_cistatic ISessionListener* g_sessionlist4Ctrl = NULL;
280704ebd2Sopenharmony_cistatic ISessionListener* g_sessionlist4Perf = NULL;
290704ebd2Sopenharmony_cistatic ISessionListener* g_sessionlist4Pass = NULL;
300704ebd2Sopenharmony_cistatic ISessionListener* g_sessionlist4File = NULL;
310704ebd2Sopenharmony_cistatic ISessionListener* g_sessionlist4Proxy = NULL;
320704ebd2Sopenharmony_cistatic ISessionListener  *g_sessionlist4Stream  = NULL;
330704ebd2Sopenharmony_ci
340704ebd2Sopenharmony_cistatic uint64_t g_transTimeEnd;
350704ebd2Sopenharmony_ci
360704ebd2Sopenharmony_cistatic const char* def_passwd = "OH2022@xa";
370704ebd2Sopenharmony_cistatic const char* def_ssid = "OpenHarmony_Private_Net_01";
380704ebd2Sopenharmony_cistatic const char* slave_ssid = "OpenHarmony_Private_Net_02";
390704ebd2Sopenharmony_ci
400704ebd2Sopenharmony_cistatic const int three_seconds = 3;
410704ebd2Sopenharmony_cistatic const int six_seconds = 6;
420704ebd2Sopenharmony_cistatic const int ten_seconds = 10;
430704ebd2Sopenharmony_ci
440704ebd2Sopenharmony_cistatic void SetupCallback(void);
450704ebd2Sopenharmony_cistatic void TeardownCallback(void);
460704ebd2Sopenharmony_ci
470704ebd2Sopenharmony_ciclass dsoftbusTest : public testing::Test {
480704ebd2Sopenharmony_cipublic:
490704ebd2Sopenharmony_ci    static void SetUpTestCase();
500704ebd2Sopenharmony_ci    static void TearDownTestCase();
510704ebd2Sopenharmony_ci    void SetUp();
520704ebd2Sopenharmony_ci    void TearDown();
530704ebd2Sopenharmony_ci};
540704ebd2Sopenharmony_ci
550704ebd2Sopenharmony_civoid dsoftbusTest ::SetUp() {}
560704ebd2Sopenharmony_ci
570704ebd2Sopenharmony_civoid dsoftbusTest ::TearDown() {}
580704ebd2Sopenharmony_ci
590704ebd2Sopenharmony_civoid dsoftbusTest ::SetUpTestCase()
600704ebd2Sopenharmony_ci{
610704ebd2Sopenharmony_ci    LOG("SetUpTestCase");
620704ebd2Sopenharmony_ci    AddPermission();
630704ebd2Sopenharmony_ci    sleep(1);
640704ebd2Sopenharmony_ci    OHOS::Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo();
650704ebd2Sopenharmony_ci    sleep(1);
660704ebd2Sopenharmony_ci    TestSetUp();
670704ebd2Sopenharmony_ci    SetupCallback();
680704ebd2Sopenharmony_ci    int ret = RegNodeDeviceStateCb(DEF_PKG_NAME, g_nodeStateCallback);
690704ebd2Sopenharmony_ci    EXPECT_EQ(SOFTBUS_OK, ret) << "call reg node state callback fail";
700704ebd2Sopenharmony_ci}
710704ebd2Sopenharmony_ci
720704ebd2Sopenharmony_civoid dsoftbusTest::TearDownTestCase()
730704ebd2Sopenharmony_ci{
740704ebd2Sopenharmony_ci    LOG("TearDownTestCase");
750704ebd2Sopenharmony_ci    int ret = UnregNodeDeviceStateCb(g_nodeStateCallback);
760704ebd2Sopenharmony_ci    EXPECT_EQ(SOFTBUS_OK, ret) << "call unReg node state callback fail";
770704ebd2Sopenharmony_ci    TeardownCallback();
780704ebd2Sopenharmony_ci    TestTearDown();
790704ebd2Sopenharmony_ci}
800704ebd2Sopenharmony_ci
810704ebd2Sopenharmony_cistatic int OnFileSessionOpened(int sessionId, int result)
820704ebd2Sopenharmony_ci{
830704ebd2Sopenharmony_ci    LOG("[cb][file]open session sid[%d],rst[%d]", sessionId, result);
840704ebd2Sopenharmony_ci    return SOFTBUS_OK;
850704ebd2Sopenharmony_ci}
860704ebd2Sopenharmony_ci
870704ebd2Sopenharmony_cistatic void OnFileSessionClosed(int sessionId)
880704ebd2Sopenharmony_ci{
890704ebd2Sopenharmony_ci    LOG("[cb][file]close session sid[%d]", sessionId);
900704ebd2Sopenharmony_ci}
910704ebd2Sopenharmony_ci
920704ebd2Sopenharmony_cistatic void OnFileBytesReceived(int sessionId, const void* data, unsigned int dataLen)
930704ebd2Sopenharmony_ci{
940704ebd2Sopenharmony_ci    LOG("[cb][file]ByteRec sid:%d, data len:%d", sessionId, dataLen);
950704ebd2Sopenharmony_ci    if (data == NULL) {
960704ebd2Sopenharmony_ci        LOG("[cb][file]ByteRec invalid data=null sid[%d]", sessionId);
970704ebd2Sopenharmony_ci    }
980704ebd2Sopenharmony_ci}
990704ebd2Sopenharmony_ci
1000704ebd2Sopenharmony_cistatic void OnFileMessageReceived(int sessionId, const void* data, unsigned int dataLen)
1010704ebd2Sopenharmony_ci{
1020704ebd2Sopenharmony_ci    LOG("[cb][file]MessageRec sid:%d, data len:%d", sessionId, dataLen);
1030704ebd2Sopenharmony_ci    if (data == NULL) {
1040704ebd2Sopenharmony_ci        LOG("[cb][file]MessageRec invalid data=null sid[%d]", sessionId);
1050704ebd2Sopenharmony_ci    }
1060704ebd2Sopenharmony_ci}
1070704ebd2Sopenharmony_ci
1080704ebd2Sopenharmony_cistatic int OnStreamSessionOpened(int sessionId, int result)
1090704ebd2Sopenharmony_ci{
1100704ebd2Sopenharmony_ci    LOG("[cb][stream]open session sid[%d],rst[%d]", sessionId, result);
1110704ebd2Sopenharmony_ci    return SOFTBUS_OK;
1120704ebd2Sopenharmony_ci}
1130704ebd2Sopenharmony_ci
1140704ebd2Sopenharmony_cistatic void OnStreamSessionClosed(int sessionId)
1150704ebd2Sopenharmony_ci{
1160704ebd2Sopenharmony_ci    LOG("[cb][stream]close session sid[%d]", sessionId);
1170704ebd2Sopenharmony_ci}
1180704ebd2Sopenharmony_ci
1190704ebd2Sopenharmony_cistatic inline int GetNumberInStreamData(const char *streamData)
1200704ebd2Sopenharmony_ci{
1210704ebd2Sopenharmony_ci    if (streamData[0] == '1') {
1220704ebd2Sopenharmony_ci        return (streamData[1] - '0');
1230704ebd2Sopenharmony_ci    } else if (streamData[0] == '2') {
1240704ebd2Sopenharmony_ci        return (streamData[1] - '0') * 10 + (streamData[2] - '0');
1250704ebd2Sopenharmony_ci    } else if (streamData[0] == '3') {
1260704ebd2Sopenharmony_ci        return (streamData[1] - '0') * 100 + (streamData[2] - '0') * 10 + (streamData[3] - '0');
1270704ebd2Sopenharmony_ci    } else if (streamData[0] == '4') {
1280704ebd2Sopenharmony_ci        return (streamData[1] - '0') * 1000 + (streamData[2] - '0') * 100 + (streamData[3] - '0' * 10 + (streamData[4] - '0'));
1290704ebd2Sopenharmony_ci    }
1300704ebd2Sopenharmony_ci    return -1;
1310704ebd2Sopenharmony_ci}
1320704ebd2Sopenharmony_ci
1330704ebd2Sopenharmony_cistatic void StreamReceived(int sessionId, const StreamData *data, const StreamData *ext, const StreamFrameInfo *frame)
1340704ebd2Sopenharmony_ci{
1350704ebd2Sopenharmony_ci    g_transTimeEnd = GetCurrentTimeOfMs();
1360704ebd2Sopenharmony_ci    int i = GetNumberInStreamData((const char *)data->buf);
1370704ebd2Sopenharmony_ci    if (i < 0) {
1380704ebd2Sopenharmony_ci        return;
1390704ebd2Sopenharmony_ci    }
1400704ebd2Sopenharmony_ci    if (i % 60 == 0)
1410704ebd2Sopenharmony_ci    {
1420704ebd2Sopenharmony_ci        LOG("### RECV counts = %d ", i );
1430704ebd2Sopenharmony_ci    } else
1440704ebd2Sopenharmony_ci    {
1450704ebd2Sopenharmony_ci        LOG("### RECV counts = %d ", i );
1460704ebd2Sopenharmony_ci    }
1470704ebd2Sopenharmony_ci    if (data != NULL) {
1480704ebd2Sopenharmony_ci        LOG("[cb][stream]Rec sid:%d, data= %.*s.\n", sessionId, data->bufLen, data->buf);
1490704ebd2Sopenharmony_ci    }
1500704ebd2Sopenharmony_ci}
1510704ebd2Sopenharmony_ci
1520704ebd2Sopenharmony_ci/* session callback for data */
1530704ebd2Sopenharmony_cistatic int OnDataSessionOpened(int sessionId, int result)
1540704ebd2Sopenharmony_ci{
1550704ebd2Sopenharmony_ci    LOG("[cb][data]session opened  sid:%d,ret:%d", sessionId, result);
1560704ebd2Sopenharmony_ci    return SOFTBUS_OK;
1570704ebd2Sopenharmony_ci}
1580704ebd2Sopenharmony_ci
1590704ebd2Sopenharmony_cistatic void OnDataSessionClosed(int sessionId)
1600704ebd2Sopenharmony_ci{
1610704ebd2Sopenharmony_ci    LOG("[cb][data]session closed  sid:%d", sessionId);
1620704ebd2Sopenharmony_ci}
1630704ebd2Sopenharmony_ci
1640704ebd2Sopenharmony_cistatic void OnDataBytesReceived(int sessionId, const void* data, unsigned int dataLen)
1650704ebd2Sopenharmony_ci{
1660704ebd2Sopenharmony_ci    if (sessionId < 0) {
1670704ebd2Sopenharmony_ci        LOG("[cb][data]byte received invalid session id[%d]", sessionId);
1680704ebd2Sopenharmony_ci        return;
1690704ebd2Sopenharmony_ci    }
1700704ebd2Sopenharmony_ci    LOG("[cb][data]byte received   sid:%d, data-len:%d", sessionId, dataLen);
1710704ebd2Sopenharmony_ci    int ret = SendBytes(sessionId, data, dataLen);
1720704ebd2Sopenharmony_ci    LOG("[cb][data]byte received   send back:%d", ret);
1730704ebd2Sopenharmony_ci}
1740704ebd2Sopenharmony_ci
1750704ebd2Sopenharmony_cistatic void OnDataMessageReceived(int sessionId, const void* data, unsigned int dataLen)
1760704ebd2Sopenharmony_ci{
1770704ebd2Sopenharmony_ci    if (sessionId < 0) {
1780704ebd2Sopenharmony_ci        LOG("[cb][data]mesg received   invalid session id[%d]", sessionId);
1790704ebd2Sopenharmony_ci        return;
1800704ebd2Sopenharmony_ci    }
1810704ebd2Sopenharmony_ci    LOG("[cb][data]mesg received   sid:%d, data-len:%d", sessionId, dataLen);
1820704ebd2Sopenharmony_ci    int ret = SendMessage(sessionId, data, dataLen);
1830704ebd2Sopenharmony_ci    LOG("[cb][data]mesg received   send back:%d", ret);
1840704ebd2Sopenharmony_ci}
1850704ebd2Sopenharmony_ci
1860704ebd2Sopenharmony_ci/* session callback for control */
1870704ebd2Sopenharmony_cistatic int GetCodeByMsg(const string& msg)
1880704ebd2Sopenharmony_ci{
1890704ebd2Sopenharmony_ci    LOG("[ctrl] recv msg content[%s]", msg.c_str());
1900704ebd2Sopenharmony_ci    int ret = -1;
1910704ebd2Sopenharmony_ci    if (strncmp(msg.c_str(), CTRL_MSG_CLOSE_WIFI_TEN_SEC, strlen(CTRL_MSG_CLOSE_WIFI_TEN_SEC)) == 0) {
1920704ebd2Sopenharmony_ci        ret = CTRL_CODE_CLOSE_WIFI_TEN_SEC;
1930704ebd2Sopenharmony_ci    } else if (strncmp(msg.c_str(), CTRL_MSG_CLOSE_WIFI_THREE_SEC, strlen(CTRL_MSG_CLOSE_WIFI_THREE_SEC)) == 0) {
1940704ebd2Sopenharmony_ci        ret = CTRL_CODE_CLOSE_WIFI_THREE_SEC;
1950704ebd2Sopenharmony_ci    } else if (strncmp(msg.c_str(), CTRL_MSG_CLOSE_WIFI_TEN_MIN, strlen(CTRL_MSG_CLOSE_WIFI_TEN_MIN)) == 0) {
1960704ebd2Sopenharmony_ci        ret = CTRL_CODE_CLOSE_WIFI_TEN_MIN;
1970704ebd2Sopenharmony_ci    } else if (strncmp(msg.c_str(), CTRL_MSG_CLOSE_WIFI_FIVE_MIN, strlen(CTRL_MSG_CLOSE_WIFI_FIVE_MIN)) == 0) {
1980704ebd2Sopenharmony_ci        ret = CTRL_CODE_CLOSE_WIFI_FIVE_MIN;
1990704ebd2Sopenharmony_ci    } else if (strncmp(msg.c_str(), CTRL_MSG_CHANGE_WIFI_TEN_SEC, strlen(CTRL_MSG_CHANGE_WIFI_TEN_SEC)) == 0) {
2000704ebd2Sopenharmony_ci        ret = CTRL_CODE_CHANGE_WIFI_TEN_SEC;
2010704ebd2Sopenharmony_ci    } else if (strncmp(msg.c_str(), CTRL_MSG_CHANGE_WIFI_SIXTY_SEC, strlen(CTRL_MSG_CHANGE_WIFI_SIXTY_SEC)) == 0) {
2020704ebd2Sopenharmony_ci        ret = CTRL_CODE_CHANGE_WIFI_SIXTY_SEC;
2030704ebd2Sopenharmony_ci    } else if (strncmp(msg.c_str(), CTRL_MSG_CLOSE_BR, strlen(CTRL_MSG_CLOSE_BR)) == 0) {
2040704ebd2Sopenharmony_ci        ret = CTRL_CODE_CLOSE_BR;
2050704ebd2Sopenharmony_ci    } else if (strncmp(msg.c_str(), CTRL_MSG_CLOSE_OPEN_BR, strlen(CTRL_MSG_CLOSE_OPEN_BR)) == 0) {
2060704ebd2Sopenharmony_ci        ret = CTRL_CODE_CLOSE_OPEN_BR;
2070704ebd2Sopenharmony_ci    } else if (strncmp(msg.c_str(), CTRL_MSG_OPEN_SESSION, strlen(CTRL_MSG_OPEN_SESSION)) == 0) {
2080704ebd2Sopenharmony_ci        ret = CTRL_CODE_OPEN_SESSION;
2090704ebd2Sopenharmony_ci    } else if (strncmp(msg.c_str(), CTRL_MSG_OPEN_SESSION_MSG, strlen(CTRL_MSG_OPEN_SESSION_MSG)) == 0) {
2100704ebd2Sopenharmony_ci        ret = CTRL_CODE_OPEN_SESSION_MSG;
2110704ebd2Sopenharmony_ci    } else if (strncmp(msg.c_str(), CTRL_MSG_OPEN_SESSION_NOT_EXIST, strlen(CTRL_MSG_OPEN_SESSION_NOT_EXIST)) == 0) {
2120704ebd2Sopenharmony_ci        ret = CTRL_CODE_OPEN_SESSION_NOT_EXIST;
2130704ebd2Sopenharmony_ci    }
2140704ebd2Sopenharmony_ci    return ret;
2150704ebd2Sopenharmony_ci}
2160704ebd2Sopenharmony_ci
2170704ebd2Sopenharmony_civoid* CtrlOperateTask(void* param)
2180704ebd2Sopenharmony_ci{
2190704ebd2Sopenharmony_ci    LOG("[operate] start...");
2200704ebd2Sopenharmony_ci    int code = -1;
2210704ebd2Sopenharmony_ci    if (param != NULL) {
2220704ebd2Sopenharmony_ci        code = *((int*)param);
2230704ebd2Sopenharmony_ci    }
2240704ebd2Sopenharmony_ci    LOG("[operate] code:%d", code);
2250704ebd2Sopenharmony_ci    int ret;
2260704ebd2Sopenharmony_ci    int sleepTime;
2270704ebd2Sopenharmony_ci    switch (code) {
2280704ebd2Sopenharmony_ci        case CTRL_CODE_CLOSE_WIFI_TEN_SEC:
2290704ebd2Sopenharmony_ci            WiFiUtils ::DisableThenEnableAndConnect(ten_seconds, def_ssid, def_passwd);
2300704ebd2Sopenharmony_ci            break;
2310704ebd2Sopenharmony_ci        case CTRL_CODE_CLOSE_WIFI_THREE_SEC:
2320704ebd2Sopenharmony_ci            WiFiUtils ::DisableThenEnableAndConnect(three_seconds, def_ssid, def_passwd);
2330704ebd2Sopenharmony_ci            break;
2340704ebd2Sopenharmony_ci        case CTRL_CODE_CLOSE_WIFI_TEN_MIN:
2350704ebd2Sopenharmony_ci            sleepTime = six_seconds * ten_seconds * ten_seconds;
2360704ebd2Sopenharmony_ci            WiFiUtils ::DisableWifi();
2370704ebd2Sopenharmony_ci            while (sleepTime > 0) {
2380704ebd2Sopenharmony_ci                sleep(ten_seconds);
2390704ebd2Sopenharmony_ci                sleepTime -= ten_seconds;
2400704ebd2Sopenharmony_ci                LOG("[operate][close wifi 10mins] wait:%d", sleepTime);
2410704ebd2Sopenharmony_ci            }
2420704ebd2Sopenharmony_ci            WiFiUtils ::EnableThenConnect(def_ssid, def_passwd);
2430704ebd2Sopenharmony_ci            break;
2440704ebd2Sopenharmony_ci        case CTRL_CODE_CLOSE_WIFI_FIVE_MIN:
2450704ebd2Sopenharmony_ci            sleepTime = three_seconds * ten_seconds * ten_seconds;
2460704ebd2Sopenharmony_ci            WiFiUtils ::DisableWifi();
2470704ebd2Sopenharmony_ci            while (sleepTime > 0) {
2480704ebd2Sopenharmony_ci                sleep(ten_seconds);
2490704ebd2Sopenharmony_ci                sleepTime -= ten_seconds;
2500704ebd2Sopenharmony_ci                LOG("[operate][close wifi 5mins] wait:%d", sleepTime);
2510704ebd2Sopenharmony_ci            }
2520704ebd2Sopenharmony_ci            WiFiUtils ::EnableThenConnect(def_ssid, def_passwd);
2530704ebd2Sopenharmony_ci            break;
2540704ebd2Sopenharmony_ci        case CTRL_CODE_CHANGE_WIFI_TEN_SEC:
2550704ebd2Sopenharmony_ci            sleepTime = ten_seconds;
2560704ebd2Sopenharmony_ci            ret = WiFiUtils ::ConnectToNew(slave_ssid, def_passwd);
2570704ebd2Sopenharmony_ci            LOG("[operate]connect to salve ret:%d", ret);
2580704ebd2Sopenharmony_ci            LOG("[operate]start sleep:%d", sleepTime);
2590704ebd2Sopenharmony_ci            sleep(sleepTime);
2600704ebd2Sopenharmony_ci            ret = WiFiUtils ::ConnectToNew(def_ssid, def_passwd);
2610704ebd2Sopenharmony_ci            LOG("[operate]connect to default ret:%d", ret);
2620704ebd2Sopenharmony_ci            break;
2630704ebd2Sopenharmony_ci        case CTRL_CODE_CHANGE_WIFI_SIXTY_SEC:
2640704ebd2Sopenharmony_ci            sleepTime = six_seconds * ten_seconds;
2650704ebd2Sopenharmony_ci            ret = WiFiUtils ::ConnectToNew(slave_ssid, def_passwd);
2660704ebd2Sopenharmony_ci            LOG("[operate]connect to salve ret:%d", ret);
2670704ebd2Sopenharmony_ci            LOG("[operate]start sleep:%d", sleepTime);
2680704ebd2Sopenharmony_ci            sleep(sleepTime);
2690704ebd2Sopenharmony_ci            ret = WiFiUtils ::ConnectToNew(def_ssid, def_passwd);
2700704ebd2Sopenharmony_ci            LOG("[operate]connect to default ret:%d", ret);
2710704ebd2Sopenharmony_ci            break;
2720704ebd2Sopenharmony_ci        case CTRL_CODE_CLOSE_BR:
2730704ebd2Sopenharmony_ci            // close br
2740704ebd2Sopenharmony_ci            LOG("[operate]close br TODO...");
2750704ebd2Sopenharmony_ci            break;
2760704ebd2Sopenharmony_ci        case CTRL_CODE_CLOSE_OPEN_BR:
2770704ebd2Sopenharmony_ci            // close open br
2780704ebd2Sopenharmony_ci            LOG("[operate]close-open br TODO...");
2790704ebd2Sopenharmony_ci            break;
2800704ebd2Sopenharmony_ci        case CTRL_CODE_OPEN_SESSION:
2810704ebd2Sopenharmony_ci            // open session and send byte
2820704ebd2Sopenharmony_ci            LOG("[operate]open session TODO...");
2830704ebd2Sopenharmony_ci            break;
2840704ebd2Sopenharmony_ci        case CTRL_CODE_OPEN_SESSION_NOT_EXIST:
2850704ebd2Sopenharmony_ci            // open session not exist
2860704ebd2Sopenharmony_ci            LOG("[operate]open session not exist TODO...");
2870704ebd2Sopenharmony_ci            break;
2880704ebd2Sopenharmony_ci        case CTRL_CODE_OPEN_SESSION_MSG:
2890704ebd2Sopenharmony_ci            // open session and send msg
2900704ebd2Sopenharmony_ci            LOG("[operate]open session not exist TODO...");
2910704ebd2Sopenharmony_ci            break;
2920704ebd2Sopenharmony_ci        default:
2930704ebd2Sopenharmony_ci            LOG("[operate]not support this code");
2940704ebd2Sopenharmony_ci            break;
2950704ebd2Sopenharmony_ci    }
2960704ebd2Sopenharmony_ci    free(param);
2970704ebd2Sopenharmony_ci    LOG("[operate] end");
2980704ebd2Sopenharmony_ci    return nullptr;
2990704ebd2Sopenharmony_ci}
3000704ebd2Sopenharmony_ci
3010704ebd2Sopenharmony_cistatic int OnCtrlSessionOpened(int sessionId, int result)
3020704ebd2Sopenharmony_ci{
3030704ebd2Sopenharmony_ci    LOG("[cb][ctrl]session opened sid:%d, ret:%d", sessionId, result);
3040704ebd2Sopenharmony_ci    return SOFTBUS_OK;
3050704ebd2Sopenharmony_ci}
3060704ebd2Sopenharmony_ci
3070704ebd2Sopenharmony_cistatic void OnCtrlSessionClosed(int sessionId)
3080704ebd2Sopenharmony_ci{
3090704ebd2Sopenharmony_ci    LOG("[cb][ctrl]session closed sid:%d", sessionId);
3100704ebd2Sopenharmony_ci}
3110704ebd2Sopenharmony_ci
3120704ebd2Sopenharmony_cistatic void OnCtrlBytesReceived(int sessionId, const void* data, unsigned int dataLen)
3130704ebd2Sopenharmony_ci{
3140704ebd2Sopenharmony_ci    if (sessionId < 0) {
3150704ebd2Sopenharmony_ci        LOG("[cb][ctrl]byte received invalid session id[%d]", sessionId);
3160704ebd2Sopenharmony_ci        return;
3170704ebd2Sopenharmony_ci    }
3180704ebd2Sopenharmony_ci    LOG("[cb][ctrl]byte received sid:%d, data-len:%d", sessionId, dataLen);
3190704ebd2Sopenharmony_ci    int ret = SendBytes(sessionId, data, dataLen);
3200704ebd2Sopenharmony_ci    LOG("[cb][ctrl]byte received send back:%d", ret);
3210704ebd2Sopenharmony_ci}
3220704ebd2Sopenharmony_ci
3230704ebd2Sopenharmony_cistatic void OnCtrlMessageReceived(int sessionId, const void* data, unsigned int dataLen)
3240704ebd2Sopenharmony_ci{
3250704ebd2Sopenharmony_ci    if (sessionId < 0) {
3260704ebd2Sopenharmony_ci        LOG("[cb][ctrl]mesg received invalid session id[%d]", sessionId);
3270704ebd2Sopenharmony_ci        return;
3280704ebd2Sopenharmony_ci    }
3290704ebd2Sopenharmony_ci    LOG("[cb][ctrl]mesg received sid:%d, data-len:%d", sessionId, dataLen);
3300704ebd2Sopenharmony_ci    int ret = SendMessage(sessionId, data, dataLen);
3310704ebd2Sopenharmony_ci    LOG("[cb][ctrl]mesg received send back:%d", ret);
3320704ebd2Sopenharmony_ci
3330704ebd2Sopenharmony_ci    // operate
3340704ebd2Sopenharmony_ci    unsigned int maxCtrlLen = 25;
3350704ebd2Sopenharmony_ci    if (dataLen < maxCtrlLen) {
3360704ebd2Sopenharmony_ci        int* code = (int*)malloc(sizeof(int));
3370704ebd2Sopenharmony_ci        *code = GetCodeByMsg((char*)data);
3380704ebd2Sopenharmony_ci        LOG("[cb][ctrl]GetCodeByMsg is:%d", *code);
3390704ebd2Sopenharmony_ci        if (*code != -1) {
3400704ebd2Sopenharmony_ci            pthread_t ctrlThread;
3410704ebd2Sopenharmony_ci            ret = pthread_create(&ctrlThread, nullptr, CtrlOperateTask, code);
3420704ebd2Sopenharmony_ci            LOG("[cb][ctrl]create ctrl thread ret:%d", ret);
3430704ebd2Sopenharmony_ci        } else {
3440704ebd2Sopenharmony_ci            free(code);
3450704ebd2Sopenharmony_ci        }
3460704ebd2Sopenharmony_ci    }
3470704ebd2Sopenharmony_ci}
3480704ebd2Sopenharmony_ci
3490704ebd2Sopenharmony_ci/* session callback for performance */
3500704ebd2Sopenharmony_cistatic int OnPerfSessionOpened(int sessionId, int result)
3510704ebd2Sopenharmony_ci{
3520704ebd2Sopenharmony_ci    LOG("[cb][perf]session opened sid:%d, ret:%d", sessionId, result);
3530704ebd2Sopenharmony_ci    return SOFTBUS_OK;
3540704ebd2Sopenharmony_ci}
3550704ebd2Sopenharmony_ci
3560704ebd2Sopenharmony_cistatic void OnPerfSessionClosed(int sessionId)
3570704ebd2Sopenharmony_ci{
3580704ebd2Sopenharmony_ci    LOG("[cb][perf]session closed sid:%d", sessionId);
3590704ebd2Sopenharmony_ci}
3600704ebd2Sopenharmony_ci
3610704ebd2Sopenharmony_cistatic void OnPerfBytesReceived(int sessionId, const void* data, unsigned int dataLen)
3620704ebd2Sopenharmony_ci{
3630704ebd2Sopenharmony_ci    if (sessionId < 0) {
3640704ebd2Sopenharmony_ci        LOG("[cb][perf]byte received invalid session id[%d]", sessionId);
3650704ebd2Sopenharmony_ci        return;
3660704ebd2Sopenharmony_ci    }
3670704ebd2Sopenharmony_ci    LOG("[cb][perf]byte received sid:%d, data-len:%d", sessionId, dataLen);
3680704ebd2Sopenharmony_ci    int ret = SendBytes(sessionId, data, dataLen);
3690704ebd2Sopenharmony_ci    LOG("[cb][perf]byte received send back:%d", ret);
3700704ebd2Sopenharmony_ci}
3710704ebd2Sopenharmony_ci
3720704ebd2Sopenharmony_cistatic void OnPerfMessageReceived(int sessionId, const void* data, unsigned int dataLen)
3730704ebd2Sopenharmony_ci{
3740704ebd2Sopenharmony_ci    if (sessionId < 0) {
3750704ebd2Sopenharmony_ci        LOG("[cb][perf]mesg received invalid session id[%d]", sessionId);
3760704ebd2Sopenharmony_ci        return;
3770704ebd2Sopenharmony_ci    }
3780704ebd2Sopenharmony_ci    LOG("[cb][perf]mesg received sid:%d, data-len:%d", sessionId, dataLen);
3790704ebd2Sopenharmony_ci    int ret = SendMessage(sessionId, data, dataLen);
3800704ebd2Sopenharmony_ci    LOG("[cb][perf]mesg received send back:%d", ret);
3810704ebd2Sopenharmony_ci}
3820704ebd2Sopenharmony_ci
3830704ebd2Sopenharmony_cistatic int OnPassSessionOpened(int sessionId, int result)
3840704ebd2Sopenharmony_ci{
3850704ebd2Sopenharmony_ci    LOG("[cb][pass]session opened sid:%d, ret:%d", sessionId, result);
3860704ebd2Sopenharmony_ci    return SOFTBUS_OK;
3870704ebd2Sopenharmony_ci}
3880704ebd2Sopenharmony_ci
3890704ebd2Sopenharmony_cistatic void OnPassSessionClosed(int sessionId)
3900704ebd2Sopenharmony_ci{
3910704ebd2Sopenharmony_ci    LOG("[cb][pass]session closed sid:%d", sessionId);
3920704ebd2Sopenharmony_ci}
3930704ebd2Sopenharmony_ci
3940704ebd2Sopenharmony_cistatic void OnPassBytesReceived(int sessionId, const void* data, unsigned int dataLen)
3950704ebd2Sopenharmony_ci{
3960704ebd2Sopenharmony_ci    if (sessionId < 0) {
3970704ebd2Sopenharmony_ci        LOG("[cb][pass]byte received invalid session id[%d]", sessionId);
3980704ebd2Sopenharmony_ci        return;
3990704ebd2Sopenharmony_ci    }
4000704ebd2Sopenharmony_ci    LOG("[cb][pass]byte received sid:%d, data-len:%d", sessionId, dataLen);
4010704ebd2Sopenharmony_ci}
4020704ebd2Sopenharmony_ci
4030704ebd2Sopenharmony_cistatic void OnPassMessageReceived(int sessionId, const void* data, unsigned int dataLen)
4040704ebd2Sopenharmony_ci{
4050704ebd2Sopenharmony_ci    if (sessionId < 0) {
4060704ebd2Sopenharmony_ci        LOG("[cb][pass]mesg received invalid session id[%d]", sessionId);
4070704ebd2Sopenharmony_ci        return;
4080704ebd2Sopenharmony_ci    }
4090704ebd2Sopenharmony_ci    LOG("[cb][pass]mesg received sid:%d, data-len:%d", sessionId, dataLen);
4100704ebd2Sopenharmony_ci}
4110704ebd2Sopenharmony_ci
4120704ebd2Sopenharmony_cistatic int OnProxySessionOpened(int sessionId, int result)
4130704ebd2Sopenharmony_ci{
4140704ebd2Sopenharmony_ci    LOG("[cb][Proxy]session opened sid:%d, ret:%d", sessionId, result);
4150704ebd2Sopenharmony_ci    return SOFTBUS_OK;
4160704ebd2Sopenharmony_ci}
4170704ebd2Sopenharmony_ci
4180704ebd2Sopenharmony_cistatic void OnProxySessionClosed(int sessionId)
4190704ebd2Sopenharmony_ci{
4200704ebd2Sopenharmony_ci    LOG("[cb][Proxy]session closed sid:%d", sessionId);
4210704ebd2Sopenharmony_ci}
4220704ebd2Sopenharmony_ci
4230704ebd2Sopenharmony_cistatic void OnProxyBytesReceived(int sessionId, const void* data, unsigned int dataLen)
4240704ebd2Sopenharmony_ci{
4250704ebd2Sopenharmony_ci    if (sessionId < 0) {
4260704ebd2Sopenharmony_ci        LOG("[cb][Proxy]byte received invalid session id[%d]", sessionId);
4270704ebd2Sopenharmony_ci        return;
4280704ebd2Sopenharmony_ci    }
4290704ebd2Sopenharmony_ci    LOG("[cb][Proxy]byte received sid:%d, data-len:%d", sessionId, dataLen);
4300704ebd2Sopenharmony_ci    int ret = SendBytes(sessionId, data, dataLen);
4310704ebd2Sopenharmony_ci    LOG("[cb][Proxy]byte received send back:%d", ret);
4320704ebd2Sopenharmony_ci}
4330704ebd2Sopenharmony_ci
4340704ebd2Sopenharmony_cistatic void OnProxyMessageReceived(int sessionId, const void* data, unsigned int dataLen)
4350704ebd2Sopenharmony_ci{
4360704ebd2Sopenharmony_ci   if (sessionId < 0) {
4370704ebd2Sopenharmony_ci        LOG("[cb][Proxy]mesg received   invalid session id[%d]", sessionId);
4380704ebd2Sopenharmony_ci        return;
4390704ebd2Sopenharmony_ci    }
4400704ebd2Sopenharmony_ci    LOG("[cb][Proxy]mesg received   sid:%d, data-len:%d", sessionId, dataLen);
4410704ebd2Sopenharmony_ci    int ret = SendMessage(sessionId, data, dataLen);
4420704ebd2Sopenharmony_ci    LOG("[cb][Proxy]mesg received   send back:%d", ret);
4430704ebd2Sopenharmony_ci}
4440704ebd2Sopenharmony_ci
4450704ebd2Sopenharmony_ci/* net state callback */
4460704ebd2Sopenharmony_cistatic void OnNodeOnline(NodeBasicInfo* info)
4470704ebd2Sopenharmony_ci{
4480704ebd2Sopenharmony_ci    if (info == NULL) {
4490704ebd2Sopenharmony_ci        LOG("[cb]Online: info is null");
4500704ebd2Sopenharmony_ci    }
4510704ebd2Sopenharmony_ci
4520704ebd2Sopenharmony_ci    LOG("[cb]Online id:%s, name:%s ,type id:%u", info->networkId, info->deviceName, info->deviceTypeId);
4530704ebd2Sopenharmony_ci}
4540704ebd2Sopenharmony_ci
4550704ebd2Sopenharmony_cistatic void OnNodeOffline(NodeBasicInfo* info)
4560704ebd2Sopenharmony_ci{
4570704ebd2Sopenharmony_ci    if (info == NULL) {
4580704ebd2Sopenharmony_ci        LOG("[cb]Offline: info is null");
4590704ebd2Sopenharmony_ci        return;
4600704ebd2Sopenharmony_ci    }
4610704ebd2Sopenharmony_ci
4620704ebd2Sopenharmony_ci    LOG("[cb]Offline id:%s, name:%s ,type id:%u", info->networkId, info->deviceName, info->deviceTypeId);
4630704ebd2Sopenharmony_ci}
4640704ebd2Sopenharmony_ci
4650704ebd2Sopenharmony_cistatic void OnNodeBasicInfoChanged(NodeBasicInfoType type, NodeBasicInfo* info)
4660704ebd2Sopenharmony_ci{
4670704ebd2Sopenharmony_ci    if (info == NULL) {
4680704ebd2Sopenharmony_ci        LOG("[cb]InfoChanged: info is null, type[%d]", type);
4690704ebd2Sopenharmony_ci        return;
4700704ebd2Sopenharmony_ci    }
4710704ebd2Sopenharmony_ci    LOG("[cb]InfoChanged id: %s, name: %s", info->networkId, info->deviceName);
4720704ebd2Sopenharmony_ci}
4730704ebd2Sopenharmony_ci
4740704ebd2Sopenharmony_cistatic void onDefNodeStatusChanged(NodeStatusType type, NodeStatus *status)
4750704ebd2Sopenharmony_ci{
4760704ebd2Sopenharmony_ci    if (status == NULL) {
4770704ebd2Sopenharmony_ci        LOG("[cb]StatusChanged: info is null, type[%d]", type);
4780704ebd2Sopenharmony_ci        return;
4790704ebd2Sopenharmony_ci    }
4800704ebd2Sopenharmony_ci    LOG("[cb]StatusChanged id: %s,status: %d", status->basicInfo.networkId, status->authStatus);
4810704ebd2Sopenharmony_ci}
4820704ebd2Sopenharmony_ci
4830704ebd2Sopenharmony_cistatic void SetupCallback(void)
4840704ebd2Sopenharmony_ci{
4850704ebd2Sopenharmony_ci    if (g_sessionlist4Data == NULL) {
4860704ebd2Sopenharmony_ci        g_sessionlist4Data = (ISessionListener*)calloc(1, sizeof(ISessionListener));
4870704ebd2Sopenharmony_ci        g_sessionlist4Data->OnSessionOpened = OnDataSessionOpened;
4880704ebd2Sopenharmony_ci        g_sessionlist4Data->OnSessionClosed = OnDataSessionClosed;
4890704ebd2Sopenharmony_ci        g_sessionlist4Data->OnMessageReceived = OnDataMessageReceived;
4900704ebd2Sopenharmony_ci        g_sessionlist4Data->OnBytesReceived = OnDataBytesReceived;
4910704ebd2Sopenharmony_ci    }
4920704ebd2Sopenharmony_ci
4930704ebd2Sopenharmony_ci    if (g_sessionlist4Ctrl == NULL) {
4940704ebd2Sopenharmony_ci        g_sessionlist4Ctrl = (ISessionListener*)calloc(1, sizeof(ISessionListener));
4950704ebd2Sopenharmony_ci        g_sessionlist4Ctrl->OnSessionOpened = OnCtrlSessionOpened;
4960704ebd2Sopenharmony_ci        g_sessionlist4Ctrl->OnSessionClosed = OnCtrlSessionClosed;
4970704ebd2Sopenharmony_ci        g_sessionlist4Ctrl->OnMessageReceived = OnCtrlMessageReceived;
4980704ebd2Sopenharmony_ci        g_sessionlist4Ctrl->OnBytesReceived = OnCtrlBytesReceived;
4990704ebd2Sopenharmony_ci    }
5000704ebd2Sopenharmony_ci
5010704ebd2Sopenharmony_ci    if (g_sessionlist4Perf == NULL) {
5020704ebd2Sopenharmony_ci        g_sessionlist4Perf = (ISessionListener*)calloc(1, sizeof(ISessionListener));
5030704ebd2Sopenharmony_ci        g_sessionlist4Perf->OnSessionOpened = OnPerfSessionOpened;
5040704ebd2Sopenharmony_ci        g_sessionlist4Perf->OnSessionClosed = OnPerfSessionClosed;
5050704ebd2Sopenharmony_ci        g_sessionlist4Perf->OnMessageReceived = OnPerfMessageReceived;
5060704ebd2Sopenharmony_ci        g_sessionlist4Perf->OnBytesReceived = OnPerfBytesReceived;
5070704ebd2Sopenharmony_ci    }
5080704ebd2Sopenharmony_ci
5090704ebd2Sopenharmony_ci    if (g_sessionlist4Pass == NULL) {
5100704ebd2Sopenharmony_ci        g_sessionlist4Pass = (ISessionListener*)calloc(1, sizeof(ISessionListener));
5110704ebd2Sopenharmony_ci        g_sessionlist4Pass->OnSessionOpened = OnPassSessionOpened;
5120704ebd2Sopenharmony_ci        g_sessionlist4Pass->OnSessionClosed = OnPassSessionClosed;
5130704ebd2Sopenharmony_ci        g_sessionlist4Pass->OnMessageReceived = OnPassMessageReceived;
5140704ebd2Sopenharmony_ci        g_sessionlist4Pass->OnBytesReceived = OnPassBytesReceived;
5150704ebd2Sopenharmony_ci    }
5160704ebd2Sopenharmony_ci
5170704ebd2Sopenharmony_ci    if (g_sessionlist4Proxy == NULL) {
5180704ebd2Sopenharmony_ci        g_sessionlist4Proxy = (ISessionListener*)calloc(1, sizeof(ISessionListener));
5190704ebd2Sopenharmony_ci        g_sessionlist4Proxy->OnSessionOpened = OnProxySessionOpened;
5200704ebd2Sopenharmony_ci        g_sessionlist4Proxy->OnSessionClosed = OnProxySessionClosed;
5210704ebd2Sopenharmony_ci        g_sessionlist4Proxy->OnMessageReceived = OnProxyMessageReceived;
5220704ebd2Sopenharmony_ci        g_sessionlist4Proxy->OnBytesReceived = OnProxyBytesReceived;
5230704ebd2Sopenharmony_ci    }
5240704ebd2Sopenharmony_ci
5250704ebd2Sopenharmony_ci    if (g_sessionlist4File == NULL) {
5260704ebd2Sopenharmony_ci        g_sessionlist4File = (ISessionListener*)calloc(1, sizeof(ISessionListener));
5270704ebd2Sopenharmony_ci        g_sessionlist4File->OnSessionOpened = OnFileSessionOpened;
5280704ebd2Sopenharmony_ci        g_sessionlist4File->OnSessionClosed = OnFileSessionClosed;
5290704ebd2Sopenharmony_ci        g_sessionlist4File->OnMessageReceived = OnFileMessageReceived;
5300704ebd2Sopenharmony_ci        g_sessionlist4File->OnBytesReceived = OnFileBytesReceived;
5310704ebd2Sopenharmony_ci    }
5320704ebd2Sopenharmony_ci
5330704ebd2Sopenharmony_ci    if (g_nodeStateCallback == NULL) {
5340704ebd2Sopenharmony_ci        g_nodeStateCallback = (INodeStateCb*)calloc(1, sizeof(INodeStateCb));
5350704ebd2Sopenharmony_ci        g_nodeStateCallback->events = EVENT_NODE_STATE_MASK;
5360704ebd2Sopenharmony_ci        g_nodeStateCallback->onNodeOnline = OnNodeOnline;
5370704ebd2Sopenharmony_ci        g_nodeStateCallback->onNodeOffline = OnNodeOffline;
5380704ebd2Sopenharmony_ci        g_nodeStateCallback->onNodeBasicInfoChanged = OnNodeBasicInfoChanged;
5390704ebd2Sopenharmony_ci        g_nodeStateCallback->onNodeStatusChanged = onDefNodeStatusChanged;
5400704ebd2Sopenharmony_ci    }
5410704ebd2Sopenharmony_ci
5420704ebd2Sopenharmony_ci    if (g_sessionlist4Stream == NULL) {
5430704ebd2Sopenharmony_ci        g_sessionlist4Stream= (ISessionListener*)calloc(1, sizeof(ISessionListener));
5440704ebd2Sopenharmony_ci        g_sessionlist4Stream->OnSessionOpened = OnStreamSessionOpened;
5450704ebd2Sopenharmony_ci        g_sessionlist4Stream->OnSessionClosed = OnStreamSessionClosed;
5460704ebd2Sopenharmony_ci        g_sessionlist4Stream->OnStreamReceived = StreamReceived;
5470704ebd2Sopenharmony_ci    }
5480704ebd2Sopenharmony_ci}
5490704ebd2Sopenharmony_ci
5500704ebd2Sopenharmony_cistatic void TeardownCallback(void)
5510704ebd2Sopenharmony_ci{
5520704ebd2Sopenharmony_ci    if (g_sessionlist4Data != NULL) {
5530704ebd2Sopenharmony_ci        free(g_sessionlist4Data);
5540704ebd2Sopenharmony_ci        g_sessionlist4Data = NULL;
5550704ebd2Sopenharmony_ci    }
5560704ebd2Sopenharmony_ci    if (g_sessionlist4Ctrl != NULL) {
5570704ebd2Sopenharmony_ci        free(g_sessionlist4Ctrl);
5580704ebd2Sopenharmony_ci        g_sessionlist4Ctrl = NULL;
5590704ebd2Sopenharmony_ci    }
5600704ebd2Sopenharmony_ci    if (g_sessionlist4Perf != NULL) {
5610704ebd2Sopenharmony_ci        free(g_sessionlist4Perf);
5620704ebd2Sopenharmony_ci        g_sessionlist4Perf = NULL;
5630704ebd2Sopenharmony_ci    }
5640704ebd2Sopenharmony_ci    if (g_sessionlist4Pass != NULL) {
5650704ebd2Sopenharmony_ci        free(g_sessionlist4Pass);
5660704ebd2Sopenharmony_ci        g_sessionlist4Pass = NULL;
5670704ebd2Sopenharmony_ci    }
5680704ebd2Sopenharmony_ci    if (g_sessionlist4Proxy != NULL) {
5690704ebd2Sopenharmony_ci        free(g_sessionlist4Proxy);
5700704ebd2Sopenharmony_ci        g_sessionlist4Proxy = NULL;
5710704ebd2Sopenharmony_ci    }
5720704ebd2Sopenharmony_ci    if (g_sessionlist4File != NULL) {
5730704ebd2Sopenharmony_ci        free(g_sessionlist4File);
5740704ebd2Sopenharmony_ci        g_sessionlist4File = NULL;
5750704ebd2Sopenharmony_ci    }
5760704ebd2Sopenharmony_ci    if (g_nodeStateCallback != NULL) {
5770704ebd2Sopenharmony_ci        free(g_nodeStateCallback);
5780704ebd2Sopenharmony_ci        g_nodeStateCallback = NULL;
5790704ebd2Sopenharmony_ci    }
5800704ebd2Sopenharmony_ci    if (g_sessionlist4Stream != NULL) {
5810704ebd2Sopenharmony_ci        free(g_sessionlist4Stream);
5820704ebd2Sopenharmony_ci        g_sessionlist4Stream = NULL;
5830704ebd2Sopenharmony_ci    }
5840704ebd2Sopenharmony_ci}
5850704ebd2Sopenharmony_ci
5860704ebd2Sopenharmony_ci/**
5870704ebd2Sopenharmony_ci * @tc.number : SUB_Softbus_Trans_SelfNet_0100
5880704ebd2Sopenharmony_ci * @tc.name     : 创建SS,等待opensession和消息传输
5890704ebd2Sopenharmony_ci * @tc.desc       : 测试自组网下传输功能,模拟服务端
5900704ebd2Sopenharmony_ci * @tc.type       : FUNC
5910704ebd2Sopenharmony_ci * @tc.size        : MediumTest
5920704ebd2Sopenharmony_ci */
5930704ebd2Sopenharmony_ciHWTEST_F(dsoftbusTest, test_create_ss, TestSize.Level3)
5940704ebd2Sopenharmony_ci{
5950704ebd2Sopenharmony_ci    int dataRet = CreateSessionServer(DEF_PKG_NAME, SESSION_NAME_DATA, g_sessionlist4Data);
5960704ebd2Sopenharmony_ci    LOG("CreateSs[data] ret:%d", dataRet);
5970704ebd2Sopenharmony_ci    int ctrlRet = CreateSessionServer(DEF_PKG_NAME, SESSION_NAME_CTL, g_sessionlist4Ctrl);
5980704ebd2Sopenharmony_ci    LOG("CreateSs[ctrl] ret:%d", ctrlRet);
5990704ebd2Sopenharmony_ci    int perfRet = CreateSessionServer(DEF_PKG_NAME, SESSION_NAME_PERF, g_sessionlist4Perf);
6000704ebd2Sopenharmony_ci    LOG("CreateSs[perf] ret:%d", perfRet);
6010704ebd2Sopenharmony_ci    int passRet = CreateSessionServer(DEF_PKG_NAME, SESSION_NAME_PASS, g_sessionlist4Pass);
6020704ebd2Sopenharmony_ci    LOG("CreateSs[pass] ret:%d", passRet);
6030704ebd2Sopenharmony_ci    int proxyRet = CreateSessionServer(DEF_PKG_NAME, SESSION_NAME_PROXY, g_sessionlist4Proxy);
6040704ebd2Sopenharmony_ci    LOG("CreateSs[Proxy] ret:%d", proxyRet);
6050704ebd2Sopenharmony_ci    int fileRet = CreateSessionServer(DEF_PKG_NAME, SESSION_NAME_FILE, g_sessionlist4File);
6060704ebd2Sopenharmony_ci    LOG("CreateSs[file] ret:%d", fileRet);
6070704ebd2Sopenharmony_ci    int streamRet = CreateSessionServer(DEF_PKG_NAME, SESSION_NAME_STREAM, g_sessionlist4Stream);
6080704ebd2Sopenharmony_ci    LOG("CreateSs[stream] ret:%d", streamRet);
6090704ebd2Sopenharmony_ci
6100704ebd2Sopenharmony_ci    int runtime = 0;
6110704ebd2Sopenharmony_ci    if (dataRet == SOFTBUS_OK && ctrlRet == SOFTBUS_OK && perfRet == SOFTBUS_OK
6120704ebd2Sopenharmony_ci    && passRet == SOFTBUS_OK && fileRet == SOFTBUS_OK && streamRet == SOFTBUS_OK && proxyRet == SOFTBUS_OK) {
6130704ebd2Sopenharmony_ci        LOG("CreateSs ok");
6140704ebd2Sopenharmony_ci    }
6150704ebd2Sopenharmony_ci
6160704ebd2Sopenharmony_ci    int ret = SetFileSendListener(DEF_PKG_NAME, SESSION_NAME_FILE, GetSendFileListener());
6170704ebd2Sopenharmony_ci    if (ret != SOFTBUS_OK) {
6180704ebd2Sopenharmony_ci        LOG("##set send listener fail:%d", ret);
6190704ebd2Sopenharmony_ci    }
6200704ebd2Sopenharmony_ci    ret = SetFileReceiveListener(DEF_PKG_NAME, SESSION_NAME_FILE, GetRecvFileListener(), RECV_FILE_PATH);
6210704ebd2Sopenharmony_ci    if (ret != SOFTBUS_OK) {
6220704ebd2Sopenharmony_ci        LOG("##set recv listener fail:%d", ret);
6230704ebd2Sopenharmony_ci    }
6240704ebd2Sopenharmony_ci
6250704ebd2Sopenharmony_ci    while (1) {
6260704ebd2Sopenharmony_ci        sleep(1);
6270704ebd2Sopenharmony_ci        runtime += 1;
6280704ebd2Sopenharmony_ci        if (runtime % 60 == 0) {
6290704ebd2Sopenharmony_ci            LOG("### test run:%d s", runtime);
6300704ebd2Sopenharmony_ci        }
6310704ebd2Sopenharmony_ci    }
6320704ebd2Sopenharmony_ci
6330704ebd2Sopenharmony_ci    ret = RemoveSessionServer(DEF_PKG_NAME, SESSION_NAME_DATA);
6340704ebd2Sopenharmony_ci    LOG("RemoveSs[data] ret:%d", ret);
6350704ebd2Sopenharmony_ci    ret = RemoveSessionServer(DEF_PKG_NAME, SESSION_NAME_CTL);
6360704ebd2Sopenharmony_ci    LOG("RemoveSs[ctrl] ret:%d", ret);
6370704ebd2Sopenharmony_ci    ret = RemoveSessionServer(DEF_PKG_NAME, SESSION_NAME_PERF);
6380704ebd2Sopenharmony_ci    LOG("RemoveSs[perf] ret:%d", ret);
6390704ebd2Sopenharmony_ci    ret = RemoveSessionServer(DEF_PKG_NAME, SESSION_NAME_PASS);
6400704ebd2Sopenharmony_ci    LOG("RemoveSs[pass] ret:%d", ret);
6410704ebd2Sopenharmony_ci    ret = RemoveSessionServer(DEF_PKG_NAME, SESSION_NAME_PROXY);
6420704ebd2Sopenharmony_ci    LOG("RemoveSs[Proxy] ret:%d", ret);
6430704ebd2Sopenharmony_ci    ret = RemoveSessionServer(DEF_PKG_NAME, SESSION_NAME_FILE);
6440704ebd2Sopenharmony_ci    LOG("RemoveSs[file] ret:%d", ret);
6450704ebd2Sopenharmony_ci    ret = RemoveSessionServer(DEF_PKG_NAME, SESSION_NAME_FILE);
6460704ebd2Sopenharmony_ci    LOG("RemoveSs[stram] ret:%d", ret);
6470704ebd2Sopenharmony_ci}