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 } RequestType; 33 34 typedef struct { 35 uint32_t requestId; 36 AuthConnInfo connInfo; 37 AuthVerifyCallback verifyCb; 38 int64_t authId; 39 AuthConnCallback connCb; 40 RequestType type; 41 ListNode node; 42 } AuthRequest; 43 44 bool CheckVerifyCallback(const AuthVerifyCallback *verifyCb); 45 bool CheckAuthConnCallback(const AuthConnCallback *connCb); 46 47 /* Note: return wait list num, 0 means add fail. */ 48 uint32_t AddAuthRequest(const AuthRequest *request); 49 int32_t GetAuthRequest(uint32_t requestId, AuthRequest *request); 50 int32_t UpdateAuthRequestConnInfo(uint32_t requestId, const AuthConnInfo *connInfo); 51 int32_t FindAuthRequestByConnInfo(const AuthConnInfo *connInfo, AuthRequest *request); 52 void DelAuthRequest(uint32_t requestId); 53 void ClearAuthRequest(void); 54 55 void PerformVerifyCallback(uint32_t requestId, int32_t result, int64_t authId, const NodeInfo *info); 56 void PerformAuthConnCallback(uint32_t requestId, int32_t result, int64_t authId); 57 58 #ifdef __cplusplus 59 #if __cplusplus 60 } 61 #endif 62 #endif 63 #endif /* AUTH_REQUEST_H */ 64