1 /* 2 * Copyright (c) 2022 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 AUTH_REQUEST_H 17 #define AUTH_REQUEST_H 18 19 #include <stdint.h> 20 #include <stdbool.h> 21 #include "auth_interface.h" 22 23 #ifdef __cplusplus 24 #if __cplusplus 25 extern "C" { 26 #endif 27 #endif 28 29 typedef enum { 30 REQUEST_TYPE_VERIFY = 0, 31 REQUEST_TYPE_RECONNECT, 32 REQUEST_TYPE_CONNECT, 33 } RequestType; 34 35 typedef struct { 36 uint32_t requestId; 37 AuthConnInfo connInfo; 38 AuthVerifyCallback verifyCb; 39 AuthVerifyModule module; 40 int64_t authId; 41 int64_t traceId; 42 AuthConnCallback connCb; 43 RequestType type; 44 ListNode node; 45 uint64_t addTime; 46 bool isFastAuth; 47 } AuthRequest; 48 49 bool CheckVerifyCallback(const AuthVerifyCallback *verifyCb); 50 bool CheckAuthConnCallback(const AuthConnCallback *connCb); 51 52 /* Note: return wait list num, 0 means add fail. */ 53 uint32_t AddAuthRequest(const AuthRequest *request); 54 int32_t GetAuthRequest(uint32_t requestId, AuthRequest *request); 55 int32_t FindAuthRequestByConnInfo(const AuthConnInfo *connInfo, AuthRequest *request); 56 int32_t GetAuthRequestNoLock(uint32_t requestId, AuthRequest *request); 57 int32_t FindAndDelAuthRequestByConnInfo(uint32_t requestId, const AuthConnInfo *connInfo); 58 void DelAuthRequest(uint32_t requestId); 59 void ClearAuthRequest(void); 60 61 void PerformVerifyCallback(uint32_t requestId, int32_t result, AuthHandle authHandle, const NodeInfo *info); 62 void PerformAuthConnCallback(uint32_t requestId, int32_t result, int64_t authId); 63 64 #ifdef __cplusplus 65 #if __cplusplus 66 } 67 #endif 68 #endif 69 #endif /* AUTH_REQUEST_H */ 70