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 //! pack_struct 16 #![allow(missing_docs)] 17 18 extern crate libc; 19 20 use std::mem; 21 22 #[repr(C)] 23 pub struct SessionHandShakePack { 24 pub banner: *const libc::c_char, 25 pub auth_type: libc::c_uchar, 26 pub session_id: libc::c_uint, 27 pub connect_key: *const libc::c_char, 28 pub buf: *const libc::c_char, 29 pub version: *const libc::c_char, 30 } 31 32 #[repr(C)] 33 #[derive(Default)] 34 pub struct PayloadProtectPack { 35 pub channel_id: libc::c_uint, 36 pub command_flag: libc::c_uint, 37 pub check_sum: libc::c_uchar, 38 pub v_code: libc::c_uchar, 39 } 40 41 #[repr(C)] 42 pub struct TransferConfigPack { 43 pub file_size: libc::c_ulonglong, 44 pub atime: libc::c_ulonglong, 45 pub mtime: libc::c_ulonglong, 46 pub options: *const libc::c_char, 47 pub path: *const libc::c_char, 48 pub optional_name: *const libc::c_char, 49 pub update_if_new: libc::c_uchar, 50 pub compress_type: libc::c_uchar, 51 pub hold_timestamp: libc::c_uchar, 52 pub function_name: *const libc::c_char, 53 pub client_cwd: *const libc::c_char, 54 pub reserve1: *const libc::c_char, 55 pub reserve2: *const libc::c_char, 56 } 57 58 #[repr(C)] 59 pub struct FileModePack { 60 pub perm: libc::c_ulonglong, 61 pub u_id: libc::c_ulonglong, 62 pub g_id: libc::c_ulonglong, 63 pub context: *const libc::c_char, 64 pub full_name: *const libc::c_char, 65 } 66 67 #[repr(C)] 68 #[derive(Default)] 69 pub struct TransferPayloadPack { 70 pub index: libc::c_ulonglong, 71 pub compress_type: libc::c_uchar, 72 pub compress_size: libc::c_uint, 73 pub uncompress_size: libc::c_uint, 74 } 75 76 #[repr(C, packed)] 77 #[derive(Default)] 78 pub struct PayloadHeadPack { 79 pub flag: [libc::c_uchar; 2], 80 pub reserve: [libc::c_uchar; 2], 81 pub protocol_ver: libc::c_uchar, 82 pub head_size: libc::c_ushort, 83 pub data_size: libc::c_uint, 84 } 85 86 #[allow(unused)] 87 #[repr(C, packed)] 88 #[derive(Default)] 89 pub struct UartHeadPack { 90 pub flag: [libc::c_uchar; 2], 91 pub option: libc::c_ushort, 92 pub session_id: libc::c_uint, 93 pub data_size: libc::c_uint, 94 pub package_index: libc::c_uint, 95 pub data_checksum: libc::c_uint, 96 pub head_checksum: libc::c_uint, 97 } 98 99 #[allow(unused)] 100 #[repr(C, packed)] 101 #[derive(Default)] 102 pub struct UsbHeadPack { 103 pub flag: [libc::c_uchar; 2], 104 pub option: libc::c_uchar, 105 pub session_id: libc::c_uint, 106 pub data_size: libc::c_uint, 107 } 108 109 #[allow(unused)] 110 #[repr(C, packed)] 111 pub struct ChannelHandShakePack { 112 pub banner: [libc::c_char; 12], 113 pub version: [libc::c_char; BUF_SIZE_TINY as usize], 114 } 115 116 #[allow(unused)] 117 const BUF_SIZE_TINY: u16 = 64; 118 119 pub const HEAD_SIZE: usize = mem::size_of::<PayloadHeadPack>(); 120 pub const USB_HEAD_SIZE: usize = mem::size_of::<UsbHeadPack>(); 121 pub const UART_HEAD_SIZE: usize = mem::size_of::<UartHeadPack>(); 122