1 /* 2 * Copyright (c) 2023 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 I_SOCKET_SESSION_H 17 #define I_SOCKET_SESSION_H 18 19 #include <cstdint> 20 #include <memory> 21 #include <string> 22 23 #include "net_packet.h" 24 25 namespace OHOS { 26 namespace Msdp { 27 namespace DeviceStatus { 28 enum TokenType : int32_t { 29 TOKEN_INVALID = -1, 30 TOKEN_HAP = 0, 31 TOKEN_NATIVE, 32 TOKEN_SHELL 33 }; 34 35 class ISocketSession { 36 public: 37 ISocketSession() = default; 38 virtual ~ISocketSession() = default; 39 40 virtual bool SendMsg(NetPacket &pkt) const = 0; 41 42 virtual int32_t GetUid() const = 0; 43 virtual int32_t GetPid() const = 0; 44 virtual int32_t GetFd() const = 0; 45 virtual std::string ToString() const = 0; 46 virtual std::string GetProgramName() const = 0; 47 virtual void SetProgramName(const std::string &programName) = 0; 48 }; 49 50 using SocketSessionPtr = std::shared_ptr<ISocketSession>; 51 } // namespace DeviceStatus 52 } // namespace Msdp 53 } // namespace OHOS 54 #endif // I_SOCKET_SESSION_H 55