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_MESSAGE_H 17 #define AUTH_MESSAGE_H 18 19 #include "auth_manager.h" 20 21 #ifdef __cplusplus 22 #if __cplusplus 23 extern "C" { 24 #endif 25 #endif 26 27 typedef struct { 28 const char *msg; 29 uint32_t len; 30 int32_t linkType; 31 SoftBusVersion version; 32 } DevInfoData; 33 34 #define UDID_SHORT_HASH_HEX_STR 16 35 #define UDID_SHORT_HASH_LEN_TEMP 8 36 /* DeviceInfo-common */ 37 #define CODE "CODE" 38 /* VerifyDevice */ 39 #define CODE_VERIFY_DEVICE 2 40 #define DEVICE_ID "DEVICE_ID" 41 42 /* TcpKeepalive */ 43 #define TIME "TIME" 44 #define CODE_TCP_KEEPALIVE 3 45 46 char *PackDeviceInfoMessage(const AuthConnInfo *connInfo, SoftBusVersion version, bool isMetaAuth, 47 const char *remoteUuid, const AuthSessionInfo *info); 48 int32_t UnpackDeviceInfoMessage(const DevInfoData *devInfo, NodeInfo *nodeInfo, bool isMetaAuth, 49 const AuthSessionInfo *info); 50 51 int32_t PostDeviceIdMessage(int64_t authSeq, const AuthSessionInfo *info); 52 int32_t ProcessDeviceIdMessage(AuthSessionInfo *info, const uint8_t *data, uint32_t len); 53 54 int32_t PostDeviceInfoMessage(int64_t authSeq, const AuthSessionInfo *info); 55 int32_t ProcessDeviceInfoMessage(int64_t authSeq, AuthSessionInfo *info, const uint8_t *data, uint32_t len); 56 57 int32_t PostAuthTestInfoMessage(int64_t authSeq, const AuthSessionInfo *info); 58 int32_t ProcessAuthTestDataMessage(int64_t authSeq, AuthSessionInfo *info, const uint8_t *data, uint32_t len); 59 60 int32_t PostCloseAckMessage(int64_t authSeq, const AuthSessionInfo *info); 61 int32_t PostHichainAuthMessage(int64_t authSeq, const AuthSessionInfo *info, const uint8_t *data, uint32_t len); 62 int32_t PostDeviceMessage( 63 const AuthManager *auth, int32_t flagRelay, AuthLinkType type, const DeviceMessageParse *messageParse); 64 bool IsDeviceMessagePacket(const AuthConnInfo *connInfo, const AuthDataHead *head, const uint8_t *data, bool isServer, 65 DeviceMessageParse *messageParse); 66 int32_t UpdateLocalAuthState(int64_t authSeq, AuthSessionInfo *info); 67 68 #ifdef __cplusplus 69 #if __cplusplus 70 } 71 #endif 72 #endif 73 #endif /* AUTH_MESSAGE_H */ 74