1 /*
2  * Copyright (c) 2021-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 SOFTBUS_SERVER_H_
17 #define SOFTBUS_SERVER_H_
18 
19 #include "softbus_server_stub.h"
20 #include "softbus_common.h"
21 #include "system_ability.h"
22 
23 namespace OHOS {
24 class SoftBusServer : public SystemAbility, public SoftBusServerStub {
25     DECLARE_SYSTEM_ABILITY(SoftBusServer);
26 
27 public:
28     SoftBusServer(int32_t saId, bool runOnCreate);
29     ~SoftBusServer() = default;
30 
31     int32_t SoftbusRegisterService(const char *clientPkgName, const sptr<IRemoteObject> &object) override;
32 
33     int32_t CreateSessionServer(const char *pkgName, const char *sessionName) override;
34     int32_t RemoveSessionServer(const char *pkgName, const char *sessionName) override;
35     int32_t OpenSession(const SessionParam *param, TransInfo *info) override;
36     int32_t OpenAuthSession(const char *sessionName, const ConnectionAddr *addrInfo) override;
37     int32_t NotifyAuthSuccess(int32_t channelId, int32_t channelType) override;
38     int32_t ReleaseResources(int32_t channelId) override;
39     int32_t CloseChannel(const char *sessionName, int32_t channelId, int32_t channelType) override;
40     int32_t CloseChannelWithStatistics(int32_t channelId, int32_t channelType, uint64_t laneId, const void *dataInfo,
41         uint32_t len) override;
42     int32_t SendMessage(int32_t channelId, int32_t channelType, const void *data,
43         uint32_t len, int32_t msgType) override;
44     int32_t GetSoftbusSpecObject(sptr<IRemoteObject> &object) override;
45 
46     int32_t JoinLNN(const char *pkgName, void *addr, uint32_t addrTypeLen) override;
47     int32_t LeaveLNN(const char *pkgName, const char *networkId) override;
48     int32_t GetAllOnlineNodeInfo(const char *pkgName, void **info, uint32_t infoTypeLen, int *infoNum) override;
49     int32_t GetLocalDeviceInfo(const char *pkgName, void *info, uint32_t infoTypeLen) override;
50     int32_t GetNodeKeyInfo(const char *pkgName, const char *networkId, int key, unsigned char *buf,
51         uint32_t len) override;
52     int32_t SetNodeDataChangeFlag(const char *pkgName, const char *networkId, uint16_t dataChangeFlag) override;
53     int32_t RegDataLevelChangeCb(const char *pkgName) override;
54     int32_t UnregDataLevelChangeCb(const char *pkgName) override;
55     int32_t SetDataLevel(const DataLevel *dataLevel) override;
56     int32_t StartTimeSync(const char *pkgName, const char *targetNetworkId, int32_t accuracy,
57         int32_t period) override;
58     int32_t StopTimeSync(const char *pkgName, const char *targetNetworkId) override;
59     int32_t QosReport(int32_t channelId, int32_t chanType, int32_t appType, int32_t quality) override;
60     int32_t StreamStats(int32_t channelId, int32_t channelType, const StreamSendStats *data) override;
61     int32_t RippleStats(int32_t channelId, int32_t channelType, const TrafficStats *data) override;
62     int32_t PublishLNN(const char *pkgName, const PublishInfo *info) override;
63     int32_t StopPublishLNN(const char *pkgName, int32_t publishId) override;
64     int32_t RefreshLNN(const char *pkgName, const SubscribeInfo *info) override;
65     int32_t StopRefreshLNN(const char *pkgName, int32_t refreshId) override;
66     int32_t ActiveMetaNode(const MetaNodeConfigInfo *info, char *metaNodeId) override;
67     int32_t DeactiveMetaNode(const char *metaNodeId) override;
68     int32_t GetAllMetaNodeInfo(MetaNodeInfo *info, int32_t *infoNum) override;
69     int32_t ShiftLNNGear(const char *pkgName, const char *callerId, const char *targetNetworkId,
70         const GearMode *mode) override;
71     int Dump(int fd, const std::vector<std::u16string> &args) override;
72     int32_t GetBusCenterExObj(sptr<IRemoteObject> &object) override;
73     int32_t EvaluateQos(const char *peerNetworkId, TransDataType dataType, const QosTV *qos,
74         uint32_t qosCount) override;
75 
76 protected:
77     void OnStart() override;
78     void OnStop() override;
79     DISALLOW_COPY_AND_MOVE(SoftBusServer);
80 };
81 } // namespace OHOS
82 
83 #endif // SOFTBUS_SERVER_H_
84