• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2025 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 "system_ability.h"
21 
22 namespace OHOS {
23 class SoftBusServer : public SystemAbility, public SoftBusServerStub {
24     DECLARE_SYSTEM_ABILITY(SoftBusServer);
25 
26 public:
27     SoftBusServer(int32_t saId, bool runOnCreate);
28     ~SoftBusServer() = default;
29 
30     int32_t SoftbusRegisterService(const char *clientPkgName, const sptr<IRemoteObject> &object) override;
31 
32     int32_t CreateSessionServer(const char *pkgName, const char *sessionName, uint64_t timestamp) override;
33     int32_t RemoveSessionServer(const char *pkgName, const char *sessionName, uint64_t timestamp) override;
34     int32_t OpenSession(const SessionParam *param, TransInfo *info) override;
35     int32_t OpenAuthSession(const char *sessionName, const ConnectionAddr *addrInfo) override;
36     int32_t NotifyAuthSuccess(int32_t channelId, int32_t channelType) override;
37     int32_t ReleaseResources(int32_t channelId) override;
38     int32_t CloseChannel(const char *sessionName, int32_t channelId, int32_t channelType) override;
39     int32_t CloseChannelWithStatistics(int32_t channelId, int32_t channelType, uint64_t laneId, const void *dataInfo,
40         uint32_t len) override;
41     int32_t SendMessage(int32_t channelId, int32_t channelType, const void *data,
42         uint32_t len, int32_t msgType) override;
43     int32_t GetSoftbusSpecObject(sptr<IRemoteObject> &object) override;
44 
45     int32_t JoinLNN(const char *pkgName, void *addr, uint32_t addrTypeLen, bool isForceJoin) override;
46     int32_t LeaveLNN(const char *pkgName, const char *networkId) override;
47     int32_t GetAllOnlineNodeInfo(const char *pkgName, void **info, uint32_t infoTypeLen, int *infoNum) override;
48     int32_t GetLocalDeviceInfo(const char *pkgName, void *info, uint32_t infoTypeLen) override;
49     int32_t GetNodeKeyInfo(const char *pkgName, const char *networkId, int key, unsigned char *buf,
50         uint32_t len) override;
51     int32_t SetNodeDataChangeFlag(const char *pkgName, const char *networkId, uint16_t dataChangeFlag) override;
52     int32_t RegDataLevelChangeCb(const char *pkgName) override;
53     int32_t UnregDataLevelChangeCb(const char *pkgName) override;
54     int32_t SetDataLevel(const DataLevel *dataLevel) override;
55     int32_t StartTimeSync(const char *pkgName, const char *targetNetworkId, int32_t accuracy,
56         int32_t period) override;
57     int32_t StopTimeSync(const char *pkgName, const char *targetNetworkId) override;
58     int32_t QosReport(int32_t channelId, int32_t chanType, int32_t appType, int32_t quality) override;
59     int32_t StreamStats(int32_t channelId, int32_t channelType, const StreamSendStats *data) override;
60     int32_t RippleStats(int32_t channelId, int32_t channelType, const TrafficStats *data) override;
61     int32_t PublishLNN(const char *pkgName, const PublishInfo *info) override;
62     int32_t StopPublishLNN(const char *pkgName, int32_t publishId) override;
63     int32_t RefreshLNN(const char *pkgName, const SubscribeInfo *info) override;
64     int32_t StopRefreshLNN(const char *pkgName, int32_t refreshId) override;
65     int32_t ActiveMetaNode(const MetaNodeConfigInfo *info, char *metaNodeId) override;
66     int32_t DeactiveMetaNode(const char *metaNodeId) override;
67     int32_t GetAllMetaNodeInfo(MetaNodeInfo *info, int32_t *infoNum) override;
68     int32_t ShiftLNNGear(const char *pkgName, const char *callerId, const char *targetNetworkId,
69         const GearMode *mode) override;
70     int32_t TriggerRangeForMsdp(const char *pkgName, const RangeConfig *config) override;
71     int32_t StopRangeForMsdp(const char *pkgName, const RangeConfig *config) override;
72     int32_t RegisterRangeCallbackForMsdp(const char *pkgName) override;
73     int32_t UnregisterRangeCallbackForMsdp(const char *pkgName) override;
74     int32_t SyncTrustedRelationShip(const char *pkgName, const char *msg, uint32_t msgLen) override;
75     int Dump(int fd, const std::vector<std::u16string> &args) override;
76     int32_t GetBusCenterExObj(sptr<IRemoteObject> &object) override;
77     int32_t EvaluateQos(const char *peerNetworkId, TransDataType dataType, const QosTV *qos,
78         uint32_t qosCount) override;
79     int32_t ProcessInnerEvent(int32_t eventType, uint8_t *buf, uint32_t len) override;
80     int32_t PrivilegeCloseChannel(uint64_t tokenId, int32_t pid, const char *peerNetworkId) override;
81     int32_t SetDisplayName(const char *pkgName, const char *nameData, uint32_t len) override;
82     int32_t CreateServer(const char *pkgName, const char *name) override;
83     int32_t RemoveServer(const char *pkgName, const char *name) override;
84     int32_t Connect(const char *pkgName, const char *name, const Address *address) override;
85     int32_t Disconnect(uint32_t handle) override;
86     int32_t Send(uint32_t handle, const uint8_t *data, uint32_t len) override;
87     int32_t ConnGetPeerDeviceId(uint32_t handle, char *deviceId, uint32_t len) override;
88 
89     int32_t OpenBrProxy(const char *brMac, const char *uuid) override;
90     int32_t CloseBrProxy(int32_t channelId) override;
91     int32_t SendBrProxyData(int32_t channelId, char *data, uint32_t dataLen) override;
92     int32_t SetListenerState(int32_t channelId, int32_t type, bool CbEnabled) override;
93     bool IsProxyChannelEnabled(int32_t uid) override;
94     int32_t PushRegisterHook() override;
95 protected:
96     void OnStart() override;
97     void OnStop() override;
98     DISALLOW_COPY_AND_MOVE(SoftBusServer);
99 };
100 } // namespace OHOS
101 
102 #endif // SOFTBUS_SERVER_H_
103