1 /* 2 * Copyright (c) 2021 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 TRANS_SESSION_MANAGER_H 17 #define TRANS_SESSION_MANAGER_H 18 19 #include "softbus_def.h" 20 21 #ifdef __cplusplus 22 extern "C" { 23 #endif 24 25 typedef struct { 26 ListNode node; 27 SoftBusSecType type; 28 char pkgName[PKG_NAME_SIZE_MAX]; 29 char sessionName[SESSION_NAME_SIZE_MAX]; 30 int32_t uid; 31 int32_t pid; 32 } SessionServer; 33 34 int32_t TransSessionMgrInit(void); 35 36 void TransSessionMgrDeinit(void); 37 38 bool TransSessionServerIsExist(const char *sessionName); 39 40 int32_t TransSessionServerAddItem(SessionServer *newNode); 41 42 int32_t TransSessionServerDelItem(const char *sessionName); 43 44 void TransDelItemByPackageName(const char *pkgName, int32_t pid); 45 46 int32_t TransGetPkgNameBySessionName(const char *sessionName, char *pkgName, uint16_t len); 47 48 int32_t TransGetUidAndPid(const char *sessionName, int32_t *uid, int32_t *pid); 49 50 void TransOnLinkDown(const char *networkId, const char *uuid, const char *udid, 51 const char *peerIp, int32_t routeType); 52 53 bool CheckUidAndPid(const char *sessionName, pid_t callingUid, pid_t callingPid); 54 55 #ifdef __cplusplus 56 } 57 #endif 58 #endif 59